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*
- This can be found by running
- That your volume group name is 'ubuntu-vg'
- This can be found by running
vgdisplay
- This can be found by running
- That your logical volume path is '/dev/ubuntu-vg/root'
- This can be found by running
lvdisplay
- This can be found by running
- Your new disk is 20GB
- Hopefully you know how big the disk is.
Install Logical Volume Manager (you may or may not need to do this).
sudo apt-get install system-config-lvm
Convert your new disk to a physical volume (in this case, the new disk is 'sdb').
sudo pvcreate /dev/sdb
Add the physical volume to the volume group via 'vgextend'.
sudo vgextend ubuntu-vg /dev/sdb
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
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.