content/blog/2022-03-08-plex-migration.org

0b2895a90c7751ce06e4b26d4db41005ea2f40a9
cleberg.net/content/blog/2022-03-08-plex-migration.org rendered · source · history · blame · raw

253 lines · 8961 bytes

  1#+date:        <2022-03-08 Tue 00:00:00>
  2#+title:       Procedure for Migrating Plex Media Server with Nvidia GPU Transcoding Configuration
  3#+description: Stepwise instructions for transferring Plex Media Server to new hardware and enabling Nvidia GPU transcoding to optimize media processing performance.
  4#+slug:        plex-migration
  5#+filetags:    :plex:migration:nvidia:
  6
  7* Migration Phases
  8:PROPERTIES:
  9:CUSTOM_ID: migration-phases
 10:END:
 11I recently decided to migrate my server from an old OptiPlex desktop
 12machine to a custom-built tower with better hardware in every category.
 13In order to do this, I would need to properly migrate a full Plex
 14installation.
 15
 16The second part of this migration is that the new server uses an Nvidia
 17GPU and does not have any integrated graphics, which requires extra work
 18for installation, but provides much better hardware transcoding options
 19for Plex.
 20
 21Therefore, I have broken this migration down into three phases:
 22
 231. Configure the New Server
 242. Migrate Plex Data & Devices
 253. Configure GPU Transcoding
 26
 27* Phase 1: Configure the New Server
 28:PROPERTIES:
 29:CUSTOM_ID: phase-1-configure-the-new-server
 30:END:
 31** Choosing an OS
 32:PROPERTIES:
 33:CUSTOM_ID: choosing-an-os
 34:END:
 35In order to migrate Plex to my new server, I first needed to choose an
 36appropriate operating system (OS) and install it on the machine. Given
 37that I have encountered numerous issues installing other Linux
 38distributions properly with Nvidia graphics, I chose
 39[[https://ubuntu.com/download/server][Ubuntu Server]].
 40
 41The first step is to create a bootable USB with Ubuntu Server. This is
 42easy with [[https://www.balena.io/etcher/][Etcher]], an app that runs on
 43many different platforms. Just download the Ubuntu Server =.iso= image,
 44launch Etcher, and install the =.iso= on the USB.
 45
 46Once the USB is created, insert it into my server, reboot, and click
 47=Esc= (or any of the =F1-12= keys) until the BIOS menu appears. Finally,
 48launch the USB boot drive.
 49
 50** Booting with Nvidia
 51:PROPERTIES:
 52:CUSTOM_ID: booting-with-nvidia
 53:END:
 54In order to install Ubuntu Server with an Nvidia Graphics card (and no
 55integrated graphics on this device for some reason), you'll have to
 56configure the boot menu to allow different graphics drivers to be
 57loaded.
 58
 59When booting from the USB, the machine will launch the initial
 60installation menu. From this menu, type =e= to view the default command
 61options that come with the device - it's a good idea to take a photo of
 62this screen, so you can enter these commands on the next screen (along
 63with adding support for Nvidia).
 64
 65Finally, type =Ctrl + C= to enter the command line. From this command
 66line, enter the commands found on the =e= screen. /Remember to add
 67=nomodeset= to the =linux ...= line so that your Nvidia device will
 68display the installation screens properly!/
 69
 70Here's an example of the commands I pulled from the =e= screen and
 71entered on the command line.
 72
 73#+begin_src sh
 74setparams 'Install Ubuntu Server'
 75setgfxpayload=keep
 76linux /casper/vmlinuz quiet nomodeset ---
 77initrd /casper/initrd
 78boot
 79#+end_src
 80
 81Once the machine is rebooted, enter the =e= screen again and add
 82=nomodeset= to the =linux ...= line again and press =Ctrl + X= to save
 83the boot options.
 84
 85The machine is now fully installed and can properly display on an
 86external display using the Nvidia GPU.
 87
 88Always remember to update and upgrade on a new installation:
 89
 90#+begin_src sh
 91sudo apt update; sudo apt upgrade -y; sudo apt autoremove -y
 92#+end_src
 93
 94* Phase 2: Migrate Plex Data & Devices
 95:PROPERTIES:
 96:CUSTOM_ID: phase-2-migrate-plex-data-devices
 97:END:
 98This phase uses the great Plex article on migrations
 99([[https://support.plex.tv/articles/201370363-move-an-install-to-another-system/][Move
100an Installation to Another System]]) and adds a bit more information to
101help with commands and context.
102
103** Terminology
104:PROPERTIES:
105:CUSTOM_ID: terminology
106:END:
107*Source:* The original server that is being replaced.\\
108*Destination:* The new server.\\
109*Client:* Any application that can be used to modify settings for both
110source/destination.
111
112** Step 01: [Client] Update Settings
113:PROPERTIES:
114:CUSTOM_ID: step-01-client-update-settings
115:END:
116Open up a Plex app and /disable/ the =Account= > =Library= >
117=Empty trash automatically after every scan= preference for the source
118server.
119
120** Step 02: [Destination] Install Plex
121:PROPERTIES:
122:CUSTOM_ID: step-02-destination-install-plex
123:END:
124Open up the [[https://www.plex.tv/media-server-downloads/][Plex Media
125Server download page]] and copy the link for the appropriate platform.
126
127Execute the following commands on the destination server to install
128Plex:
129
130#+begin_src sh
131wget <url>
132sudo dpkg -i <filename>
133sudo systemctl stop plexmediaserver.service
134#+end_src
135
136** Step 03: [Source] Stop Plex & Migrate Data
137:PROPERTIES:
138:CUSTOM_ID: step-03-source-stop-plex-migrate-data
139:END:
140First, stop the Plex service so that no data is created or modified
141during the migration.
142
143#+begin_src sh
144sudo systemctl stop plexmediaserver.service
145#+end_src
146
147Next, copy the data to the new server. To find where the Plex data
148directory is located, Plex has another excellent article available:
149[[https://support.plex.tv/articles/202915258-where-is-the-plex-media-server-data-directory-located/][Where
150is the Plex Media Server data directory located?]].
151
152There are many ways to copy the data to the new server and will largely
153depend on the size of the folder being copied. Personally, my data
154folder was ~23GB and I opted to simply use the =scp= command to copy the
155files over SSH.
156
157This process was throttled by the old server's slow HDD and ports and
158took approximately 90 minutes to complete. In comparison, moving the
159data from the new server's =home/user/= directory to the
160=/var/.../Plex Media Server= directory took 2-3 minutes.
161
162#+begin_src sh
163scp -r "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server" your_user@xxx.xxx.xxx.xxx:"'/path/to/destination/'"
164#+end_src
165
166** Step 04: [Destination] Update File Permissions
167:PROPERTIES:
168:CUSTOM_ID: step-04-destination-update-file-permissions
169:END:
170In case you move the data directory to a common area on the new server,
171it will have to be moved to the proper location before Plex can function
172properly:
173
174#+begin_src sh
175mv "Plex Media Server" /var/lib/plexmediaserver/Library/Application Support/
176#+end_src
177
178To ensure permissions were retained properly, the server will need to
179show that all files and folders in the data directory are owned by
180=plex:plex= (or whichever user is running the Plex application).
181
182#+begin_src sh
183sudo chown -R plex:plex "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server"
184#+end_src
185
186Finally, start the service and check the status.
187
188#+begin_src sh
189sudo systemctl start plexmediaserver.service
190sudo systemctl status plexmediaserver.service
191#+end_src
192
193** Step 05: [Client] Update Libraries & Metadata
194:PROPERTIES:
195:CUSTOM_ID: step-05-client-update-libraries-metadata
196:END:
197The first step - now that the new server is up and running - is to sign
198out of the client and sign back in. Once this is done, update any
199library locations, if necessary. This was unnecessary in my case since I
200simply moved my storage drives from the source server to the destination
201server.
202
203Next, perform the following actions in the client:
204
2051. On the left sidebar, click =More= > Three-Dot Menu >
206   =Scan Library Files=
2072. /Enable/ the =Account= > =Library= >
208   =Empty trash automatically after every scan= preference for the
209   source server.
2103. On the left sidebar, click =More= > Three-Dot Menu > =Manage Server=
211   > =Empty    Trash=
2124. On the left sidebar, click =More= > Three-Dot Menu > =Manage Server=
213   > =Clean    Bundles=
2145. On the left sidebar, click =More= > Three-Dot Menu > =Manage Server=
215   > =Optimize Database=
216
217Finally, double-check the Remote Access settings to make sure no changes
218have caused issues with accessing the server from outside the network.
219
220In my case, I use a single port forwarding rule in my router and needed
221to update the Local LAN IP Address to the new server IP address.
222
223* Phase 3: Configure GPU Transcoding
224:PROPERTIES:
225:CUSTOM_ID: phase-3-configure-gpu-transcoding
226:END:
227The final piece to the migration is enabling hardware transcoding so
228that Plex can fully utilize the new Nvidia GPU available in the server.
229The first step is to install Nvidia graphics drivers. This process may
230take a few minutes, but the commands are pretty simple:
231
232#+begin_src sh
233sudo add-apt-repository ppa:graphics-drivers/ppa
234sudo apt update
235sudo apt-get install ubuntu-drivers-common
236sudo ubuntu-drivers autoinstall
237#+end_src
238
239Finally, reboot so that the changes are loaded:
240
241#+begin_src sh
242sudo reboot now
243#+end_src
244
245To ensure that the Nvidia graphics drivers are working properly, run the
246following command to view the available GPUs, statistics, and processes:
247
248#+begin_src sh
249sudo nvidia-smi
250#+end_src
251
252Finally, enable hardware transcoding settings in the Plex application to
253finish the process.