Plex transcoding using a RAM disk
My home server is a server in software only. Hardware wise it's an old Dell Inspiron desktop which was my main machine for a good five years. It's a core 2 duo with 6gb of RAM and on-board graphics.
I run the Plex media server on it, as well as some other services, all on Ubuntu Server 18.04. Without a fancy GPU, Plex does all the transcoding of media files using software, something which can tax an old system like mine given I encode to HEVC to save space.
Plex allows us to specify a directory where the transcoding data is written as it is used. It doesn't need to be very big. It occurred to me I could use a RAM disk for this and make it nice and snappy. Not to mention saving wear on the drive.
To create the drive first create a directory, then mount it as
sudo mkdir /mnt/ramdisk sudo mount -t tmpfs -o size=512M tmpfs /mnt/ramdisk
It's important the location is owned by root as we want to remount it at reboot. The default permissions for tmpfs make it writable by everyone, but just in case it's not chmod it to 1777.
To ensure the drive is remounted at boot add the following to the
tmpfs /mnt/ramdisk tmpfs rw,size=512M 0 0
We can use the
df -h command to view the usage. The following shows my 1gb RAM disk with Plex using 67mb to transcode an SD video of a Porky Pig cartoon encoded in HEVC:
Filesystem Size Used Avail Use% Mounted on udev 2.9G 0 2.9G 0% /dev tmpfs 594M 33M 561M 6% /run /dev/sdc1 50G 9.3G 38G 20% / tmpfs 2.9G 20K 2.9G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup /dev/sdb1 1.8T 1.1T 664G 62% /mnt/media /dev/sda1 688G 282G 372G 44% /mnt/tor cgmfs 100K 0 100K 0% /run/cgmanager/fs tmpfs 594M 0 594M 0% /run/user/1000 tmpfs 1.0G 67M 958M 7% /mnt/ramdisk