How to Add Disk Space to Linux Virtual Machine

Verify the that you are on the correct system → hostname -f Output should match what you would expect for the name of the server →

Check the current size of the disk → df -h

Check to see if there are users actively working on the server. → who

Shutdown the vm so that we can make the snapshot of the volume. → sudo shutdown -h +10 Going Down for Maintance in 10 min The number after the + is how long before the server will halt. The message is after the number and will be sent to all users logged in till the system halts. If for some reason the shutdown needs to be cancelled use the following command → sudo shutdown -c

You will then need to make a snapshot of the volume. Use tecktrak to verify which block storage volume is being used. Label the snapshot with the following format “accountID”-Date-BK → example 967228-7-28-BK If you are unsure how to make a snapshot please refer to “Dell Equallogic Snapshot how to”

Then resize the account to the new size.

At the host level. Login to the host where the VM resides. Verify you are on the correct host → hostname -f Verify that the VM is on the host. → virsh list –all Verify that the block storage for the VM is the one that has been resized. → vrish edit “VM” Check the /dev/mapper line to make sure the ID match.

Find the starting block → parted /dev/mapper/“accountID” unit b print → looking for “1 1048576B”

Do a file system check before the resize operation. → e2fsck -fp /dev/mapper/“AccountP1” Rediscover the iscsi sessions → iscsiadm -m session -R Restart the multipath → multipath -r Remove the current map to the disk → kpartx -dv /dev/mapper/“accountID”

1. > del devmap : “accountID”p2
2. > del devmap : “accountID”p1
Remove the partitions → parted /dev/mapper/“accountID” rm 2

1. > parted /dev/mapper/“accountID” rm 1 Find the end block parted /dev/mapper/“accountID” → Looking for “Disk
/dev/mapper/accountID: 536881397760B” Make the primary partition → parted /dev/mapper/“accountID” mkpart primary ext4 1048576B 535807655936B → you will need to make the end block smaller by the size of the swap. Make the swap partition → parted /dev/mapper/“accountID” mkpart primary 535807655937B 536881397759B

Resize the first partition → resize2fs -p /dev/mapper/967228p1

Do another file system check to ensure there is not curruption. → e2fsck -fp /dev/mapper/967228p1

Make the swap → mkswap /dev/mapper/967228p2 Mount the file system to make sure data is still intact. mount /dev/mapper/967228p1 /mnt/ → ls /mnt/

If using uuid, update the swap uuid. Edit the fstab → vim /mnt/etc/fstab → replace the current uuid with the new uuid.

Then unmount the drive.→ umount -l /mnt/

Start the vm → virsh start “VM” Login to the vm. On the VM run → df-h to ensure it shows the correct size.