Proxmox - Reducing root disk size on an LXC

Proxmox - Reducing root disk size on an LXC

In this post I go through how I resized the root disk on a Linux Container in Proxmox as it proved to be a challenge to find a way to shrink the size of the root disk.

The Problem

I had a LXC container which was hosting emby. In emby there is an option to enable transcoding. How emby transcodes is different to plex. Plex transcodes little sections and then deletes the sections as it goes along where as with emby, the whole move is transcoded so if the movie is 50gb you would end up with a large transcoding file. There are numerous benefits to this, one major advantage being quicker seek times. This meant that I had to increase the size of my root disk so that the transcoded file could be stored. So I resized my root disk to 128GB so that it could cope with at least one 4k movie file. A typical 4k movie is around 80GB so that means I could only have one user streaming at a time.

The Solution

To combat this, already had a 512GB SSD however my motherboard did not have another free NVME slot. So I bought a PCIE NVME Add-in card. I did have the option to buy an add-in card that did not require motherboard bifurication however I jut didn't need it at this point, but possibly one for the future. Link below if you are interested. https://forums.servethehome.com/index.php?threads/multi-nvme-m-2-u-2-adapters-that-do-not-require-bifurcation.31172/

Anyway, to reduce the size of the root disk, I went down the backup and restore route. Firstly, I created a backup of the container and then I deleted the container. Next I ran the below command and this overrides the size of the root file system, in my case to 16GB. This is because in the backup file, the root file system size is going to be 128GB.

pct restore 108 /mnt/pve/directory-nvme/dump/vzdump-lxc-108-2024_10_02-19_48_05.tar.zst --rootfs local-lvm:16

The above command restores to a container with a vmid of 108, using the backup file in the /mnt/pve directory and then we override the rootfs.

Once this is done, we will need to add the mountpoints to our media folder which in my case is on my hard drive in a ZFS pool.

Go to shell, navigate to etc/pve/lxc and "nano 108.conf ". Next, add in the mountpoint with the value of the zfs pool. Then press Ctrl + O, Ctrl + X.

mp1: /zfspool/subvol-102-disk-0,mp=/mnt/media

The resouces should look something like the below.

Next we need to give permissions to the transcoding folder and then in emby need to set the transcoding folder. In the LXC console, run the below commands.

cd /mnt/pve
chmod 777 /directory-nvme

That's it. The emby LXC has now successfully been restored with a reduced root disk.