Adding Disks With LVM

After reviewing a combination of random guides and tutorials on the net, I was able to successfully add a disk to my Ubuntu Server 14.04 machine, and essentially set it up so I have multiple hard drives appearing as one single drive. To do this, I used LVM.

To help anyone else who might want to do this at some point, I will post here what I did.


These steps assume that you are essentially starting from scratch except having already installed Ubuntu on your machine (via "Guided - use the entire disk and setup LVM"), and physically added the additional disk. These steps may work if you have existing data on the machine but I can't say for sure if it would be safe to do this.

These commands assume the following information, and will vary depending on your setup:

  • Your new disk is 'sdb'
    • This can be found by running ls /dev/sd*
  • That your volume group name is 'ubuntu-vg'
    • This can be found by running vgdisplay
  • That your logical volume path is '/dev/ubuntu-vg/root'
    • This can be found by running lvdisplay
  • Your new disk is 20GB
    • Hopefully you know how big the disk is.

  1. Install Logical Volume Manager (you may or may not need to do this).

    sudo apt-get install system-config-lvm
    
  2. Convert your new disk to a physical volume (in this case, the new disk is 'sdb').

    sudo pvcreate /dev/sdb
    
  3. Add the physical volume to the volume group via 'vgextend'.

    sudo vgextend ubuntu-vg /dev/sdb
    
  4. Allocate the physical volume to a logical volume (extend the volume size by your new disk size).

    sudo lvextend -l +100%FREE /dev/ubuntu-vg/root
    
  5. Resize the file system on the logical volume so it uses the additional space.

    sudo resize2fs /dev/ubuntu-vg/root
    

That should do it. Five simple steps! You also don't have to reboot. Just run df -h and your new disk space should show allocated correctly, as well as any webapps you may be running will pick up the new disk space amount.