Upgrading hard disk drive resources
Perform the following steps to upgrade the hard disk drive (HDD) resources on a VM.
Procedure
Back up the
home
directory. Enter:tar -czvf /root/home.tgz -C /home
Verify the contents of the backup directory. Enter:
tar -tvf /root/home.tgz
Unmount the
home
directory. Enter:umount /dev/mapper/centos-home
Remove the logical volume for the
home
directory. Enter:lvremove /dev/mapper/centos-home
Create a new 50 GB logical volume for the
home
directory. Enter:lvcreate -L 50GB -n home centos
Format the
home
directory. Enter:mkfs.xfs /dev/centos/home
Remount the
home
directory. Enter:mount /dev/mapper/centos-home
Extend the
root
directory volume to the remaining space, and then resize the file system. Enter:lvextend -r -l +100%FREE /dev/mapper/centos-root
Restore the backed-up contents of the
home
directory. Enter:tar -xzvf /root/home.tgz -C /home
Synchronize the changes. Enter:
dracut --regenerate-all --force
Display the existing disk space. Enter:
lsblk
Increase the disk space so that the total disk space is 400 GB. For example, if the existing disk space is 337 GB, then you must increase the disk space by 63 GB.
Log on to vSphere Client, right-click the VM, and then select Edit Settings.
Click ADD NEW DEVICE, and then Hard Disk.
For New Hard disk, enter the amount the disk space is to be increased, and then click OK. For example, 70 GB.
Verify the newly added hard disk. Enter:
lsblk
Create a primary partition for the newly added hard disk. Enter:
fdisk /dev/sdb
Select the following options:- n for new disk
- p for primary partition
- 1 for number of partitions
- default to set the first sector as default
- default to set the last sector as default
- w to save the configuration and exit
Verify if the disk partition was successful. Enter:
lsblk
Create a physical drive in the logical volume. Enter:
pvcreate /dev/sdb1
Extend the logical volume for the
root
directory. Enter:vgextend centos /dev/sdb1
Verify the logical volume configuration changes. Enter the following commands:
pvs vgs lvs df -h
where:pvs
is to verify the physical drive.vgs
is to verify the updated volume group size.lvs
is to verify the logical volume size.df -h
is to verify the updated root file system size.