Moving a Perforce P4 P4ROOT to a different drive
On one of my servers here, I run a local Perforce P4 server for my son. He’s a game developer and as they use P4 at work, he wanted to learn it in a sandbox and to have somewhere familiar to put his own work.
Installation onto Ubuntu was easy enough and I provided access outside of our local network via Tailscale and all was well.
Recently, I was doing some admin-stuff on the server and realised that the drive that P4 was using was the local 256GB drive rather than one of the big 8TB drives in the box, so I needed to move it. The directory that the instance was using was /opt/perforce/servers/p4d-holland1. This needed moving to /media/ssd1/data/perforce/servers/p4d-holland1.
Note I run a single instance, very default, not-very-important P4 server. Don’t just copy these steps blindly if your setup is more complicated or mission critical! Make sure that you read the docs.
These are the steps I followed:
- Stop the instance: p4dctl stop p4d-holland1
- Move the data by copying it and renaming the old directory (just in case):
mkdir -p /media/ssd1/data/perforce/servers/p4d-holland1 cp -r /opt/perforce/servers/p4d-holland1/* /media/ssd1/data/perforce/servers/p4d-holland1/ mv /opt/perforce/servers/p4d-holland1 /opt/perforce/servers/p4d-holland1-old
- Edit /etc/perforce/p4dctl.conf.d/p4d-holland1.conf and update the P4ROOT to the new directory
- Start the instance again: p4dctl start p4d-holland1
I didn’t see any errors, so I got my son to check it. After he said it was all good, I removed the old /opt/perforce/servers/p4d-holland1-old directory.
My son now has more than enough space to continue his side-projects.