Add a new 5G hard drive to VMware
Show current partition
# fdisk-l
Usually when you add a new hard disk to a virtual machine, you may see that the new drive is not loaded automatically. This is because the SCSI bus connected to the hard drive needs to be re-scanned to make the new hard drive visible.
Here is a simple command to rescan the SCSI bus and SCSI devices.
Determine the host bus number
# LS /sys/class/scsi_host/
Host0 host11 host14 host17 host2 host22 host25 host28 host30 Host4 host7host1 host12 host15 host18 host20 host23 host26 host29 host31 host5 host8host10 host13 host16 host19 host21 host24 Host27 host3 host32 host6 host9
Re-scan the SCSI bus to add devices
# For I in $ (ls/sys/class/scsi_host/), do echo "---" > /sys/class/SC Si_host/$i/scan; Done
Re-display the partition. This time found that the new hard drive has been automatically loaded.
# fdisk -l
... 5368536870912010485760 sectors1 + bytessector size (logical bytesi bytes
Display the filesystem, you can see that the root partition of the VG is RHEL,VL is root, the partition type is XFS
# DF-HT
Filesystem Type Size used Avail use%mounted on/dev/mapper/rhel-root XFS 4. 0G 1. 8G 2. 3G /Devtmpfs Devtmpfs 227M0227M0% /Devtmpfs Tmpfs 237M0237M0%/dev/Shmtmpfs Tmpfs 237M8.5M229M4% /Runtmpfs Tmpfs 237M0237M0%/sys/fs/Cgroup/DEV/SDA1 XFS 497M 168M 329M the% /Boottmpfs Tmpfs 48M058,0%/run/user/0
Build/dev/sda2 as PV
# PVCREATE/DEV/SDB
" /dev/sdb " successfully created
Since the system already has Vg:rhel, the new PV is added to this VG directly.
# Vgextend Rhel/dev/sdb
" Rhel " successfully extended
Add 5G of space to Vl:root
# lvextend-l +5g/dev/rhel/root
3.97 Gib (10168.97 Gib (2296 extents). Logical volume root successfully resized.
Add the remaining space to the Vl:root
# lvextend-l +100%free/dev/rhel/root
8.97 Gib (22969.00 Gib (2305 extents). Logical volume root successfully resized.
The modified configuration needs to be activated after LV expansion
# Xfs_growfs/dev/rhel/root
Meta-data=/dev/mapper/rhel-root isize= theAgcount=4, agsize=260096Blks= sectsz= +Attr=2, projid32bit=1= crc=0finobt=0Data= bsize=4096blocks=1040384, imaxpct= -= sunit=0Swidth=0blksnaming=version2Bsize=4096Ascii-ci=0Ftype=0Log=internal bsize=4096blocks=2560, version=2= sectsz= +sunit=0Blks, lazy-count=1Realtime=none extsz=4096blocks=0, rtextents=0data blocks changed from1040384To2360320
Re-display the file system, you can see the root partition size increased from 4G to 9G
# DF-HT
Filesystem Type Size used Avail use%mounted on/dev/mapper/rhel-root XFS 9. 0G 1. 8G 7. 3G /Devtmpfs Devtmpfs 227M0227M0% /Devtmpfs Tmpfs 237M0237M0%/dev/Shmtmpfs Tmpfs 237M8.5M229M4% /Runtmpfs Tmpfs 237M0237M0%/sys/fs/Cgroup/DEV/SDA1 XFS 497M 168M 329M the% /Boottmpfs Tmpfs 48M058,0%/run/user/0
Add a new hard disk and expand the root partition capacity without rebooting in the RHEL7 virtual machine