How to migrate Plex Media Server from one OS with ZFS to another.

Intro

I have current NAS/Plex server running on Ubuntu 21.10 with ZFSonLinux, but I’d like to install Fedora instead.

Major steps for this project are:

  1. Backup Plex config to tarball
  2. Export the ZFS pool
  3. Install Fedora
  4. Install ZFS
  5. Import ZFS Pool
  6. Install Plex Media Server
  7. Import Plex data from backup
  8. Enable Service and Create Firewall Rule

Backup Plex

Prepare for Backup

Disable auto emptying of Trash

Create Archive of Plex Data

I’ll first need to find my Plex data directory. Since the documentation gives the location for Ubuntu as /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/ I’ll do a quick search to confirm.

sudo find / -name 'Plex Media Server' -type d

The result:

/var/lib/plexmediaserver/Library/Application Support/Plex Media Server

Now that the location is confirmed, I’ll make a tarball of the data to make a backup.

cd "/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server"
tar -cf plexdata.tar 

tar is the command, c is to create an archive and f is the file in which to create. So the command breaks down to

tar create file nameofarchive.tar dir/to/archive

Optional. Note that compression is CPU intensive and may take a while. The newly create tar file is a bit big (23G), so I’m going to compress it with bzip2:

bzip2 plexdata.tar

Copy the backup to another drive, or to a directory on the zpool.

cp plexdata.tar /netstor/backups/

Export the ZFS Pool

While this is not 100% necessary, as you can use --force when importing the ZFS pool on the newly installed OS, it does make it easier and reduces the risk of complications.

not necessary to export the zpool. Once the new OS is installed, zpool import does not require --force if you shutdown the prior OS gracefully

Install Fedora

I’ll use the anaconda installer to install Fedora, taking care not to install the OS onto a ZFS drive.

Install ZFS

ZFS install instructions specific to Fedora are found here

  1. Add repo: dnf install -y https://zfsonlinux.org/fedora/zfs-release$(rpm -E %dist).noarch.rpm
  2. Install kernel headers: dnf install -y kernel-devel
  3. Load kernel module: modprobe zfs

Import ZFS Pool

Once ZFS is installed, I can list the available ZFS pools to import1: zpool import

 pool: tank
    id: 11809215114195894163
  state: ONLINE
 action: The pool can be imported using its name or numeric identifier.
 config:

        tank        ONLINE
          mirror-0  ONLINE
            c1t0d0  ONLINE
            c1t1d0  ONLINE

Note the “action” bit. The pool can be imported using its name or numeric identifier.

zpool import netstor

Install Plex Media Server

Add plex repo

Install plexmediaserver package

dnf install -y plexmediaserver

Import Plex Data From Backup

Untar the backup into the appropriate directory


cd "/var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/"

cp /netstor/backup/plexdata.tar ./

tar -xf plexdata.tar 

Before I created (c) a file (f):

tar -cf plexdata.tar

Now I’m extracting (x) a file (f)

tar -xf plexdata.tar

Enable Service and Create Firewall Rule

Enable the Plex service to autostart upon bootup and start the service immediately:

systemctl enable --now plexmediaserver

Don’t forget to create a firewall rule:

firewall-cmd --permanent --add-service=plex
firewall-cmd --reload

That should be it. I now can enjoy my new Plex server.

  1. https://docs.oracle.com/cd/E19253-01/819-5461/gazru/index.html