Recently, I noticed that one of my mount points (the one with all my recorded TV and movies) was starting to fill up.  I scanned the web for cheap WD Red drives and finally settled on a nice shiny new 4TB drive.  After I received the new drive, I thought for a few days on how I could transfer the data and perhaps even pool the storage to maximize my new space.  So after much reading, I finally eschewed the idea of using BtrFS (too unstable) and ZFS (not-native) and just decided to use LVM (built into Ubuntu Server 14.04.2).

Configuration notes:

  • Existing Drive (old) @ /dev/sdb
  • New Drive @ /dev/sdc
  • Mount Point Name: ‘dionysus’ (this could be whatever you want)

 

Without further adieu, after installing the new hardware and booting up here is what I did:

First find the drive:

sudo lshw -C disk

Partition the drive (use gdisk for large disks over 2TB – I had to install it manually):

sudo apt-get install gdisk

sudo gdisk /dev/sdc

At the prompts, type n to create a new partition, 1 to assign it partition number 1, Enter to accept the default starting cylinder, and Enter to set the size. Then type t to set the partition type. LVM partitions are type 8e00, so enter it at the prompt. Finally, type w to write the new partition table to the disk.

You can check your work with:

sudo gdisk -l

Create Physical Volume in LVM:

sudo pvcreate /dev/sdc1

Double-check with:

sudo pvdisplay

Create Volume Group named ‘dionysus’ (I append vg or lv to the front of volume groups or logical volumes so I can keep the naming straight):

sudo vgcreate vg_dionysus /dev/sdc1

Double-check with:

sudo vgdisplay

sudo pvdisplay

Create LV Group

sudo lvcreate --name lv_dionysus --size 100%FREE vg_dionysus

Double-check with:

sudo lvdisplay

Format the Logical Volume

sudo mkfs -t ext4 /dev/vg_dionysus/lv_dionysus

Make a temporary mount point

sudo mkdir /mnt/temp_dionysus
sudo mount -t ext4 /dev/vg_dionysus/lv_dionysus /mnt/temp_dionysus

Copy files from old drive to new:

sudo rsync -avrtP /mnt/dionysus/ /mnt/temp_dionysus/


Unmount the old drive (may just need to remove from fstab and reboot):

sudo umount /mnt/dionysus

Partition the old drive:

sudo gdisk /dev/sdb

At the prompts, type d to delete a partition (type p to see partitions).  Enter 1 to delete partition one(/sdb1).  type n to create a new partition, p to make it primary, 1 to assign it partition number 1, Enter to accept the default starting cylinder, and Enter to set the size. Then type t to set the partition type. LVM partitions are type 8e, so enter it at the prompt. Finally, type w to write the new partition table to the disk.

You can check your work with:

sudo gdisk -l

Create Physical Volume in LVM:

sudo pvcreate /dev/sdb1

Double-check with:

sudo pvdisplay

Add the old drive to the volume group with the extend command:

sudo vgextend vg_dionysus /dev/sdb1

Double-check with:

sudo vgdisplay

Resize the logical volume:

sudo lvextend -l +100%FREE /dev/vg_dionysus/lv_dionysus

Resize the filesystem to expand to the full size of the logical volume

sudo resize2fs /dev/vg_dionysus/lv_dionysus

Open fstab:

sudo nano /etc/fstab

Then append [use nomenclature (/dev/mapper/vgname-lvname)]:

/dev/mapper/vg_dionysus-lv_dionysus /mnt/dionysus ext4 defaults 0 0

Save and exit.

Test by mounting all:

sudo mount -a

There you go, back in business with a big, new drive with all your old stuff on it.  I hope this helps someone trying to do the same.

Was this post helpful?
  • Thanks 
  • Sort-of 
  • Not Helpful 

Leave a Reply

Your email address will not be published. Required fields are marked *