Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of increasing the disk space of root directory in linux

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "the method of linux increasing root disk space". In daily operation, I believe that many people have doubts about the method of increasing root disk space in linux. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "linux how to increase root disk space". Next, please follow the editor to study!

First, shut down your virtual machine system and find the following: select "Edit Virtual mache settings"

Click "Expand"

Expand the space of the virtual machine to "40G" (fill in the space according to individual needs). But it is not visible under the linux.

Second, use the fdisk tool under linux to partition.

Log in to your linux system with root users and view the partition of your system

# fdisk-l

The following message appears:

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 64 512000 83 Linux

/ dev/sda2 64 2611 20458496 8e Linux LVM

Disk / dev/mapper/vg_zxw-lv_root: 18.8 GB, 18832424960 bytes

255 heads, 63 sectors/track, 2289 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk / dev/mapper/vg_zxw-lv_root doesn't contain a valid partition table

Disk / dev/mapper/vg_zxw-lv_swap: 2113 MB, 2113929216 bytes

255 heads, 63 sectors/track, 257 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk / dev/mapper/vg_zxw-lv_swap doesn't contain a valid partition table

According to the prompt, we can judge that the disk interface of this system is SCSI, corresponding to "sda". If the red font above is "hda", then the disk interface of this system is IDE corresponding to "hda", so let me do something:

# fdisk / dev/sda/

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

Switch off the mode (command 'c') and change display units to

Sectors (command'u').

Command (m for help): M / / "list help for fdisk"

Command action

A toggle a bootable flag

B edit bsd disklabel

C toggle the dos compatibility flag

D delete a partition

L list known partition types

M print this menu

N add a new partition

O create a new empty DOS partition table

P print the partition table

Q quit without saving changes

S create a new empty Sun disklabel

T change a partition's system id

U change display/entry units

V verify the partition table

W write table to disk and exit

X extra functionality (experts only)

Command (m for help): n / / "Command n to add a new partition"

Command action

E extended

P primary partition (1-4)

P / / "choose to create primary partition" at this time

Partition number (1-4): 3 / / fdisk will let you choose the number of the primary partition. If you already have the primary partition sda1,sda2, select 3, that is, the partition you want to create is sda3.

First cylinder (2611-3916, default 2611): / / at this point, fdisk will ask you to select the starting value of the partition. This is the Start value (start cylinder) of the partition. It is best to press enter directly here.

Using default value 2611

Last cylinder, + cylinders or + size {KJM MagneG} (2611-3916, default 3916): / / at this point, fdisk will ask you to select the starting value of the partition, which is the End value of the partition. Here, it is best to press enter directly.

Using default value 3916

Command (m for help): W / / w "Save all and exit, partition complete"

The partition table has been altered!

Calling ioctl () to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table. The new table will be used at

The next reboot or after you run partprobe (8) or kpartx (8)

Syncing disks.

Third, our new partition / dev/sda3 is not LVM's. So, next, use fdisk to change it to LVM.

# fdisk / dev/sda

Command (m for help): M

Command (m for help): t / / change the partition system id

Partition number (1-4): 3 / / specify the partition number

Hex code (type L to list codes): 8e / / specifies the id number to be changed, and 8e represents LVM.

Command (m for help): W

Fourth, after restarting the system, log in to the system. (be sure to restart the system, otherwise the new partition cannot be expanded)

5. Format the newly added partition:

# fdisk-l

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 64 512000 83 Linux

/ dev/sda2 64 2611 20458496 8e Linux LVM

/ dev/sda3 2611 3916 10483750 8e Linux LVM

You will find that there is an extra partition.

# mkfs-t ext3 / dev/sda3 / / create a "ext3" file system on the hard disk partition "/ dev/sda3".

At this point, we can use the new partition:

VI. Expansion of the new partition

# lvs

The # pvcreate / dev/sda3 / / pvcreate directive is used to initialize a physical hard disk partition into a physical volume for use by LVM. To create a physical volume, you must partition the hard disk and set the partition type to "8e" before you can initialize the partition to a physical volume using the pvcreat directive.

Physical volume "/ dev/sda3" successfully created

# vgextend VolGroup00 / dev/sda3 (where is the lvm group name that currently needs to be expanded, which can be viewed through df-h, for example, mine is: / dev/mapper/VolGroup00-LogVol00) / / vgextend directive is used to dynamically extend the volume group, which increases the capacity of the volume group by adding physical volumes to the volume group.

# vgdisplay / / is used to display metadata information for LNM volume groups.

-Volume group

VG Name vg_zxw

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 3

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 2

Open LV 2

Max PV 0

Cur PV 1

Act PV 1

VG Size 19.51 GiB

PE Size 4.00 MiB

Total PE 4994

Alloc PE / Size 4994 / 19.51 GiB

Free PE / Size 4994 / 10.01GB

VG UUID sqBgTs-iA8x-tCXZ-KYxK-SyWS-TfXQ-uBsLaR

(the main view is Free PE / Size 4994 / 10.01GB, which shows that we can expand 10.01GB at most. I usually choose less than 10.01GB)

# lvextend-Log 9.8g / dev/VolGroup00/LogVol00 / dev/sda3

Logical volume LogVol00 successfully resized

# e2fsck-a / dev/VolGroup00/LogVol00 / / use the e2fsck directive to check for file system errors. You can also check the ext2 file system with "fsck-t ext2-V / dev/sda3/."

(do fsck, check file system)

The # resize2fs / dev/VolGroup00/LogVol00 / / resize2fs instruction is used to increase or shrink the size of an unloaded "ext2/ext3" file system.

# df-h / / check your system disk space "/" directory has become 40GB

Ok, this is done.

At this point, the study on "linux's method of increasing root disk space" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report