Skip to content

Instantly share code, notes, and snippets.

@cowboy-cod3r
Last active January 1, 2016 05:39
Show Gist options
  • Save cowboy-cod3r/8100002 to your computer and use it in GitHub Desktop.
Save cowboy-cod3r/8100002 to your computer and use it in GitHub Desktop.
Disk: Extend Disk Space on a Linux VM
1. Add disk space to the vm by adding another virtual disk.
2. In the linux VM, issue the following commands:
# List existing disks
fdisk -l
# Scan for the new disk created in step 1.
echo "- - -" >/sys/class/scsi_host/host0/scan
# List existing disks (should see the new disk)
# and it should contain a message saying the
# partition table is invalid
fdisk -l
# Partition the Disk
fdisk /dev/sdb
# Select 'n' to add/create a partition
n
# Select 'p' to create a primary partition
p
# Select '1' to create the 1st primary partition
1
# Press enter to select the default cylinder (which is 1)
<enter>
# Press enter to select the default last cylinder (depends on the size of the disk)
<enter>
# Press 't' change the partition's system id
t
# Select hex code '8e' to create an LVM
8e
# Select 'w' to write table to disk and exit
w
# Create your physical volume for the partion created with the fdisk command above
pvcreate /dev/sdb1
# Determine the VolGroup you want to extend
vgdisplay
# Extend the volume group by adding the new physical volume to it
vgextend <volgroup> /dev/sdb1
# List volumes
ls /dev/<volgroup>
# Resize the lvm (Change +10G to what is appropriate)
lvresize -L +10G /dev/<volgroup>/<vol>
resize4fs /dev/<volgroup>/<vol> # may need to do resize2fs on fedora 20 and ubuntu
# Check your partition sizes again
df -h
YOU ARE DONE!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment