Guide to move your home directory to a USB stick.
-
I have a Pi1B and have built an arcade...I see myself upgrading to a pi3 in the near future. Because of that, I'd like to keep as much configuration on the 128GB USB drive I'm using (and off the 4GB SD card).
I hope to move /home or /home/pi to the usb key, but I haven't seen any guides on how to do that with retropie. I see many guides for moving roms to a USB key, but not the whole home directory.
I'm a unix sysadmin, shouldn't be an issue right? My plan was to move the contents of /home/pi to /media/usb0 (the location of my drive), then create a fstab entry to mount the usb key at /home/pi.
Moving the files isn't going so great; there's a bunch that straight up won't move. So, don't use 'mv', here's what I did to make it work:
rsync -av --remove-source-files /home/pi/ /media/usb0/
You'll get some errors in the output pointing to some broken symlinks, this is your trigger to fix it later:
sending incremental file list rsync: symlink "/media/usb0/.emulationstation" -> "/opt/retropie/configs/all/emulationstation" failed: Operation not permitted (1) rsync: symlink "/media/usb0/RetroPie/roms/genesis" -> "megadrive" failed: Operation not permitted (1) .... rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
So, to fix that:
ln -s /opt/retropie/configs/all/emulationstation/ /media/usb0/.emulationstation ln -s /media/usb0/RetroPie/roms/megadrive /media/usb0/RetroPie/roms/genesis
If you're like me, those will fail, saying "Operation Not Permitted" even if you're root. This is because my usb stick is vfat, and symlinks aren't supported. More on this later.
The rsync will leave some stuff, so at the end you may need to run:
rm -Rf /home/pi/*
But that's a pretty dangerous command, so do so at your own discretion.
So, now we prepare to mount the USB key over /home/pi. Run:
sudo blkid
To get the UUID of your drive, the actual device address (/dev/sda1 for me) and the TYPE. My Type is vfat. If it's ntfs or exfat, consider this:
sudo apt-get update; sudo apt-get install exfat-utils ntfs-3g -y
First, test your mount by unmounting the usb driver and then re-mounting it with this:
sudo umount /media/usb0 sudo mount -o uid=pi,gid=pi /dev/sda1 /home/pi
If this works, you're good to go creating the fstab rule.
vi /etc/fstab
And add this line (with your own UUID):
UUID=2965-5D60 /home/pi vfat nofail,uid=pi,gid=pi 0 0
Reboot to test it. If you run the following and see the mount, then run the 2nd one and see your files, you should be good:
mount | grep "/home/pi" ls -as1l /home/pi
Ok. All is well for me. There's still the issue of the 2 symlinks. When it comes back up, /home/pi/.emulationstation will be automatically created. Now...if you've already set up emulation station, rather than symlink, you can just copy the content:
cp -R /opt/retropie/configs/all/emulationstation/* /home/pi/.emulationstation/
If you HAVEN'T set it up already, just set it up now. It'll go where it needs to go. For the other symlink, if you're not on vfat or exfat:
cd /home/pi/RetroPie/roms/ ln -s megadrive genesis
If you are using a filesystem type that won't work, just remember that you have to use megadrive over genesis, or do this:
mv /home/pi/RetroPie/roms/megadrive /home/pi/RetroPie/roms/genesis
And that should do it!
-
I should mention...I did that for about 10 seconds before realizing vfat sucks and committing the drive to ext4. Same principle though.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.