Skip to content

Instantly share code, notes, and snippets.

@GSchutz
Last active November 19, 2017 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GSchutz/4319a05b3b64eee4fe36dd816b9d8fb0 to your computer and use it in GitHub Desktop.
Save GSchutz/4319a05b3b64eee4fe36dd816b9d8fb0 to your computer and use it in GitHub Desktop.
One volume with multiple drives

One Volume (with multiple drives)

This steps are based on this answer https://askubuntu.com/a/7841/153797.

We want to join more SSDs to make appear as one single volume, at were we keep the home folder of the server.

  • Samsung (sda 931.5G)
  • ScanDisk (sdc 447.1G)

Make an LVM volume with both

sudo fdisk /dev/sda

Create a dos partition table: o

List all partitions: p

Delete all partitions: d (you can keep any partition that will not be used in LVM)

Create new: n [p, 1, blank, blank]

Set the filesystem: t [8e]

Write the changes: w

sudo pvcreate /dev/sda1

all this steps can be repeated with another sdx disk

Create volume group

creating a volume group with name "home" sudo vgcreate home /dev/sda1 sudo lvcreate -l100%FREE -nvolume home sudo mke2fs -t ext4 /dev/home/volume

Add new disk to volume "home"

Now if the drive name is /dev/sdc1 then do sudo vgextend home /dev/sdc1 to add it to the volume.

Now we need to unmount the volume, if mounted. sudo umount /dev/home/volume

Now you can see the stats on your volume now by running sudo vgdisplay. The important part is Free PE / Size. You need to know how much space you can add to the volume for the next step.

So if you had 150 Gb of space you would do sudo lvextend -L+150G /dev/home/volume. Now run sudo e2fsck -f /dev/home/volume to check the filesystem. Now run sudo resize2fs /dev/home/volume to resize everything. You can run the stats again and verify that Free PE / Size has dropped to what you expect. Remount the volume by doing sudo mount /dev/home/volume /mnt/home Rinse and repeat for any other drives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment