create lvm from the beginning

I have 2 USB Drives - which are showing up as sdb and sdc

Initialize the Drives

Everythng on these drives is about to get lost - so backup data you may want to keep.

assuming you have done that

fdisk /dev/sdb

Amazingly quick to mess up a disk - not lets try the other one

fdisk /dev/sdc

Scan existing

To check what is already there


As this is being install on an Ubuntu Server with LVM already - it showed

 Reading all physical volumes.  This may take a while...
  Found volume group "timemachine-vg" using metadata type lvm2

I am not sure why I need to do this - just following orders.

Create PV - Physical Volume

Using the new partitions we have just created

root@timemachine:/media# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

Create VG - Volume Group

As I want a VG called timemachine, I use this command

vgcreate timemachine /dev/sdb1

Create LV - Logical Volume

Now create the Logical Volume

lvcreate -l100%FREE -nvolume timemachine

Format the Voluma

Using the LV Name - the format of this command is

mke2fs -t ext4 /dev/timemachine/volume

Mounting LV

mkdir /mnt/timemachine
mount /dev/timemachine/volume /mnt/timemachine


We need to modify the fstab

/dev/timemachine/volume /mnt/timemachine ext4 defaults 0 1

Adding a new Drive to the LV

I am assuming you have fdisk the new drive as shown at the start of this script.

I will assume that the new drive is called sdc - and it has a primary partition of sdc1.

PV Create

root@timemachine:/media# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created

Add PV to VG - extend

vgextend timemachine /dev/sdc1

You shoudl see

Volume group "timemachine" successfully extended

Unmount the Volume

umount /dev/timemachine/volume

See how much extra is available

use the vgdisplay command to see how much FREE PE / Size there is.

As I can see 931 Gb free, my command is

lvextend -L+931G /dev/timemachine/volume

I got this nice message

Extending logical volume volume to 1.82 TiB
Logical volume volume successfully resized

Check Volume

To check the volume use this command next

e2fsck -f /dev/timemachine/volume

I got the following output

e2fsck 1.42.9 (4-Feb-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/timemachine/volume: 15/61054976 files (6.7% non-contiguous), 3883103/244189184 blocks

Resize Filesystem

We need to inform the filesystem of the new size

resize2fs /dev/timemachine/volume

The output I got was

Resizing the filesystem on /dev/timemachine/volume to 488245248 (4k) blocks.
The filesystem on /dev/timemachine/volume is now 488245248 blocks long.


As I have added this to fstab - I just do

fstab -a