System used: CentOS
Suitable for most other distributions of Linux
Let's say you are given a new disk stored as /dev/xvdb, how can you use this piece of disk to enlarge you space, like /home directory?
Partition the new given hard disk.
parted /dev/sdc mklabel gpt mkpart primary 2048s 100%Create file system for it.
mkfs -t ext4 /dev/xvdfBack up original files in the directory.
You can move all files and directories under /home to another place first, because the following manipulations will cover the /home directory.Mount partitions for it.
mount /dev/xvdb /homeUpdate /etc/fstab
After adding a disk to VM/PH, we need to configure fstab so that the disk is mounted whenever the vm starts. In general, we first mount the disk to the VM manually, then use "blkid" to get the "uuid" of the disk and add configuration to "fstab".Check if there's errors
sudo mount -a
By now, you've successfully expanded /home directory with the given new hard disk!
Used tool - Parted: https://www.gnu.org/software/parted/manual/parted.html
Useful commands
parted /dev/xvdb: list partitions in xvdb
blkid: check the uuid of disks
df -h: show the file systems and spaces