Full disclosure, as someone who’s spent most of his career designing and building software, I don’t often get the opportunity to tackle good old fashioned system administration tasks, especially on Linux. However, since my introduction to PLEX –an open source home media server—I’ve had more opportunities.

I’ve recently acquired a new server that I plan on installing PLEX on to replace my current server. I purchased a Dell R610 server that was on sale from homelabhero. The Dell R610 includes 6 drive bays so I loaded it with disks and setup a RAID-6 to create one large disk and protecting against two simultaneous disk failures.

I did a clean install of Ubuntu and due to the size of the disk, it only allowed me to use LVM (Logical Volume Manager) which started me with a single 4GB partition for the OS. After the install and a couple rounds of patching I started running low on disk space in the OS partition. Therefore I needed to increase the OS partition size to take up some of the free space.

markti@bill:~$ df

Filesystem 1K-blocks Used Available Use% Mounted on

udev 24689964 0 24689964 0% /dev

tmpfs 4944112 1636 4942476 1% /run

/dev/mapper/ubuntu--vg-ubuntu--lv 4062912 2614680 1222136 69% /

tmpfs 24720556 0 24720556 0% /dev/shm

tmpfs 5120 0 5120 0% /run/lock

tmpfs 24720556 0 24720556 0% /sys/fs/cgroup

/dev/sda2 999320 214240 716268 24% /boot

/dev/loop0 90368 90368 0 100% /snap/core/5897

/dev/loop2 91648 91648 0 100% /snap/core/6034

/dev/loop3 91648 91648 0 100% /snap/core/6130

tmpfs 4944108 0 4944108 0% /run/user/1000

I had already setup a new logical volume called “/dev/ubuntu-vg/data-lv”. When I created this logical volume I left it in the same volume group as I didn’t see a good reason to separate the volume groups. However, when I did this I had this logical volume take 100% of free space.

markti@bill:~$ sudo lvdisplay

--- Logical volume ---

LV Path /dev/ubuntu-vg/ubuntu-lv

LV Name ubuntu-lv

VG Name ubuntu-vg

LV UUID Q22bkl-oA9q-1zcL-HMWS-ff40-WsP9-tJdwvM

LV Write Access read/write

LV Creation host, time ubuntu-server, 2018-09-20 22:21:05 +0000

LV Status available

# open 1

LV Size 4.00 GiB

Current LE 1024

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:0

--- Logical volume ---

LV Path /dev/ubuntu-vg/data-lv

LV Name data-lv

VG Name ubuntu-vg

LV UUID y7khLv-2pDw-2GCu-qYae-nMkc-Zq4A-hZPFcR

LV Write Access read/write

LV Creation host, time bill, 2018-11-16 19:02:02 +0000

LV Status available

# open 0

LV Size 3.63 TiB

Current LE 952063

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:1

So the first step was to reduce my “data” logical volume by 8GB in size to make room for me to expand my OS logical volume. I used the lvreduce command giving it a size of negative “8G” (8 gigabytes).

markti@bill:~$ sudo lvreduce -L -8G /dev/ubuntu-vg/data-lv

WARNING: Reducing active logical volume to 3.62 TiB.

THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce ubuntu-vg/data-lv? [y/n]: y

Size of logical volume ubuntu-vg/data-lv changed from 3.63 TiB (952063 extents) to 3.62 TiB (950015 extents).

Logical volume ubuntu-vg/data-lv successfully resized.

After doing that, I verified that the data logical volume has been reduced in size and it looks like it did. It went from 3.63TB to 3.62TB. Not a hugely noticeable reduction given the size of the volume but those 8GB should be more than enough for my clean install of ubuntu for the time being.

markti@bill:~$ sudo lvscan

ACTIVE '/dev/ubuntu-vg/ubuntu-lv' [4.00 GiB] inherit

ACTIVE '/dev/ubuntu-vg/data-lv' [3.62 TiB] inherit

Now that I have confirmed I’ve reduced my data volume’s space I need to expand my OS logical volume from 4GB to 12GB (to include the 8GB I freed from the data logical volume).

markti@bill:~$ sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

[sudo] password for markti:

Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to 12.00 GiB (3072 extents).

Logical volume ubuntu-vg/ubuntu-lv successfully resized.

Even though the logical volume has been resized, the filesystem has not been grown to accommodate the new logical volume size. As you can see, the used storage is still at 69%.

markti@bill:~$ df -h

Filesystem Size Used Avail Use% Mounted on

udev 24G 0 24G 0% /dev

tmpfs 4.8G 1.6M 4.8G 1% /run

/dev/mapper/ubuntu--vg-ubuntu--lv 3.9G 2.5G 1.2G 69% /

tmpfs 24G 0 24G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 24G 0 24G 0% /sys/fs/cgroup

/dev/sda2 976M 210M 700M 24% /boot

/dev/loop0 89M 89M 0 100% /snap/core/5897

/dev/loop2 90M 90M 0 100% /snap/core/6034

/dev/loop3 90M 90M 0 100% /snap/core/6130

tmpfs 4.8G 0 4.8G 0% /run/user/1000

Therefore, I need to resize the filesystem to include the entire size of the logical volume.

markti@bill:~$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu—lv

Once done we can verify the filesystem has been resized and see that the freespace on the “/” mount point has increased to 23%….

markti@bill:~$ df -h

Filesystem Size Used Avail Use% Mounted on

udev 24G 0 24G 0% /dev

tmpfs 4.8G 1.6M 4.8G 1% /run

/dev/mapper/ubuntu--vg-ubuntu--lv 12G 2.5G 8.8G 23% /

tmpfs 24G 0 24G 0% /dev/shm

tmpfs 5.0M 0 5.0M 0% /run/lock

tmpfs 24G 0 24G 0% /sys/fs/cgroup

/dev/sda2 976M 210M 700M 24% /boot

/dev/loop0 89M 89M 0 100% /snap/core/5897

/dev/loop2 90M 90M 0 100% /snap/core/6034

/dev/loop3 90M 90M 0 100% /snap/core/6130

tmpfs 4.8G 0 4.8G 0% /run/user/1000