expand Hard disk space process records for CENTOS7 in VMware virtual machines
Reference Links:
http://blog.csdn.net/remote_roamer/article/details/50670802
Http://www.cnblogs.com/juandx/p/5618162.html
1. Turn off virtual machines, virtual machine settings, disk utilities--Extensions
The original Linux HDD only 30G, extended to 100G
2. Partition and format the newly added hard drive
2.1 Partitioning The newly added hard drive
Input command: FDISK/DEV/SDA (because the above selection is an extension, that is, in the original hard disk SDA expansion, so the space to increase the hard disk is/DEV/SDA)
Follow the prompts to enter:
[root@centos7dev~]# FDISK/DEV/SDA
Welcome to Fdisk (Util-linux 2.23.2).
Changes'll remainin memory only, until you decide to write them.
Be careful beforeusing the write command.
Command (M for help):p (View the number of partitions with two/dev/sda1/dev/sda2))
DISK/DEV/SDA:107.4GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1* = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label Type:dos
Disk identifier:0x0003f424
Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 1026047 512000 Linux
/dev/sda2 1026048 62914559 30944256 8e Linux LVM (original 30G HDD)
Command (M for help): N (add a new partition)
Partition Type:
P Primary (2 primary, 0 extended, 2 free)
E Extended
Select (Default p):p (partition type selected as primary partition)
Partition Number (3,4, default 3):3 (3 of the area code)
First sector (62914560-209715199, default 62914560): Entre (enter, select default Start Sector)
Using default value62914560
Last sector, +sectors or +size{k,m,g} (62914560-209715199, default209715199): Entre (enter, select default End sector)
Using default value209715199
Partition 3 of Typelinux and of size the GiB is set
Command (M for help):t (t modify partition Type)
Partition Number (1-3, default 3):3 (select partition 3)
Hex Code (type L to list all codes):8e (modified to LVM (8es is the ID found above p option) LVM is Logicalvolume Manager (logical Volume management))
Changed type ofpartition ' Linux ' to ' Linux LVM '
Command (M for help):W (Save)
The partition Tablehas been altered!
Calling IOCTL () tore-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 would be Usedat
The next reboot or after you run partprobe(8) or KPARTX (8)
Syncing disks.
[root@centos7dev~]# Partprobe (according to the above prompt input)
[root@centos7dev~]# reboot (restart Linux)
2.2 To format the newly added hard drive
After restarting the Linux format partition: mkfs.xfs/dev/sda3(Sda3 is the area just divided, also note : The format of what file system to use the df-th command to first see what your current Linux system uses the file system, What I'm looking at here is printed:
Filesystem Type Size used Avail use% mounted on
/dev/mapper/centos-root xfs 28G 12G 17G 42%/
So use the MKFS.XFS command
2.3. Add new LVM to existing LVM group for capacity expansion
LVM into LVM management:
Lvm> Pvcreate/dev/sda3 Initialize the partition just now
lvm> Vgdisplay View Volume Group (volumegroup) name
---volumegroup---
Vgname CentOS
... ... ...
Lvm> vgextend Centos/dev/sda3 Add the initialized partition to the virtual volume group centos
Lvm> Lvdisplay View the Logical volume (Logical volume), you can see the new 70G logical volume
---physical volume---
PV Name/dev/sda2
VG Name CentOS
PV Size 29.51 gib/not usable 3.00 MiB
Allocatable Yes
... ... ...
"/dev/sda3" is a new physicalvolume of "70.00 GiB"
---NEW physical volume---
PV Name/dev/sda3
VG Name
PV Size 70.00 GiB
Allocatable NO
... ... ...
Lvm> lvextend-l +70g/dev/centos/root Add the physical volume to the root directory, from the print information above you can see that the root directory is in the/dev/centos/root
3. The above is only the volume expansion, the following is the real expansion of the file system, enter the following command:
Xfs_growfs/dev/mapper/centos-root
4. Results View
[root@centos7dev~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/centos-root 97G 12G 86G 12%/
...