Monday, February 2, 2015

Add disk space to the root directory on a VM

# Suppose the second disk is /dev/sdb
fdisk /dev/sdb

### In the fdisk shell ###
# Create a new partition using command 'n' (default options are fine)
# Set its type with command 't' as '8e' (for making it 'Linux LVM')
# Write and exit shell with command 'w'

# Format the partition you require using mkfs command
mkfs -t ext4 -c /dev/sdb1

# Now you can mount /dev/sdb1 on a directory. Go on if you want to
# merge it into the root logic volume
# create LVM & merging it into root, first creating physical volume
pvcreate /dev/sdb1

# Look up the name of the root Volume Group using vgdisplay
vgdisplay

# Add the newly created physical volume into logical volume group
vgextend /dev/<vg_name> /dev/sdb1

# extend it (<logical_volume> is usually 'lv_root')
lvextend /dev/<vg_name>/<logical_volume> /dev/sdb1

# resize it
resize2fs /dev/<vg_name>/<logical_volume>

# Done!

No comments:

Post a Comment