Linux, extending the root directory (LVM) __linux

Source: Internet
Author: User
Tags hex code

Df-h View/directory has been used more than 90%, so the root directory needs to be expanded
One, close your virtual machine system, find the following: Select "Edit Virtual mache settings"

Click "Expand"

Enlarge the space of the virtual machine to "40G" (according to the individual needs to fill in the space size). But Linux is not visible below.
Second, use the Fdisk tool under Linux to partition.
Log in to your Linux system with root user, and view your system's partitions
#fdisk-L
The following information appears:
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 512000 Linux
/dev/sda2 2611 20458496 8e Linux LVM

disk/dev/mapper/vg_zxw-lv_root:18.8 GB, 18832424960 bytes
255 heads, Sectors/track, 2289 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): 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, Sectors/track, 257 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

Disk/dev/mapper/vg_zxw-lv_swap doesn ' t contain a valid partition table
According to the hint information can determine that the disk interface of this system is SCSI, corresponding to "SDA" if the red font above is "HDA", then this system's disk interface for the IDE corresponds to "HDA" so I do the operation:

#fdisk/dev/sda/

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off "mode" (Command ' C ') and change display units to
Sectors (Command ' u ').

Command (M for help): M//"List assistance 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//"Select Create Primary Partition" at this time

Partition Number (1-4): 3//fdisk will let you select the primary partition, if you already have a primary partition sda1,sda2, then the number is 3, that is, the partition you want to create is Sda3.
First Cylinder (2611-3916, default 2611)://At this point, Fdisk will let you select the partition's starting value, which is the partition's start value (start cylinder); it's best to press ENTER directly,
Using Default value 2611
Last cylinder, +cylinders or +size{k,m,g} (2611-3916, default 3916)://At this point, Fdisk will let you select the start value of the partition. Is the end value of the partition. It's best to press ENTER directly,
Using default value 3916

Command (M for help): w  //w "Save all and exit, Partition completed" br> the partition table has been altered!

Calling IOCTL () to re-read partition table.
The
Warning:re-reading the partition table failed with error 16:device or resource busy.
The kernel still uses the old table. The new table is used at
the next reboot or after you run Partprobe (8) or KPARTX (8)
Syncing disks.
Third, our new Partition/dev/sda3, but not LVM. So, then use Fdisk to change it to LVM.
#fdisk/dev/sda
Command (M for help): M
Command (M to help): T  //change partition system ID

Partition number (1-4): 3//Designated Partition No.
Hex code (type L to list codes): 8e//Specify the ID number to be changed, 8e represents LVM
Command (M for help): W
Four, restart the system, the landing system.
Five, format the newly added partition:
#fdisk-L

Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 512000 Linux
/dev/sda2 2611 20458496 8e Linux LVM
/dev/sda3 2611 3916 10483750 8e Linux LVM
You'll find an extra partition.
#mkfs-T EXT3/DEV/SDA3//formatted partition
Now we can use the new partition:
Vi. expansion of the new zoning
#lvs
#pvcreate/dev/sda3//Create a physical volume
Physical volume "/dev/sda3" successfully created
#vgextend Volgroup00/dev/sda3//(VolGroup00 is the currently required extension of the LVM group name, can be viewed through df-h, for example, my is:/dev/mapper/ VOLGROUP00-LOGVOL00) to add a physical volume to a volume group
#vgdisplay

---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 free pe/size 4994/10.01GB, we can have a maximum of 10.01GB expansion space.) I generally choose less than 10.01GB)


# Lvextend-l+9.8g/dev/volgroup00/logvol00/dev/sda3

Logical Volume LogVol00 successfully resized
#e2fsck-A/dev/volgroup00/logvol00
(Do fsck, check file system)
#resize2fs/dev/volgroup00/logvol00
#fdisk-L//view your system disk space "/" Directory becomes 40GB
OK, that's it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.