Notes on Transferring RetroPie from an SD card to a USB drive
-
I had a few questions about the process and asked them here and here. Now that I've finished it, I just wanted to post notes here, in case it helps others. Most of this has been written up before (there are some links in those other threads), but this is all together, in one place. Between this, the two other threads, and the links in them, this should help anyone wanting to do this.
Background: I have a Raspberry Pi 3B+ and had an SD card with /boot and /retropie on it - an install straight from the image using Etcher. I was running into issues because I'm not the only person who uses my arcade system and there were times power was left on and we had an outage. Every time that happened, my Pi wouldn't reboot. The first several times popping the SD card into a Linux system and just reading the card to see the filenames was enough to fix it. The last time that didn't help and I was getting tired of going through that and didn't want to have to transfer files to keep settings and deal with partitioning, only to face it all again at the next outage.
I had already transferred my ROMs from the SD card because the SD card wasn't big enough for the collection. By this time, I had not done a lot of work on my system for a while and was just enjoying playing games, so I had forgotten a lot of the settings.
I had hoped I could just move the entire file system to the existing partition on the USB drive with all the ROMs, but that won't work. I took another USB drive and, on my Linux system, partitioned it. I made a small FAT32 /boot (it forced it to /BOOT in the partition editor I was using) partition that was 512MB and the rest, close to 256GB, I made into an ext4 partition labelled /RetroPie. (I used the caps like that so, when it was inserted, I could distinguish it from the /retropie partition on the SD card.)
Once partitioned, I copied the files in /boot on the SD card to /BOOT on the USB stick with
rsync -axv
. The first few times I tried this, I did not use the 'x' option and it's necessary. (You can skip the 'v' option - that's for 'verbal' and tells rsync to say what it's doing as it copies each file.) Then do the same with the files on the SD card's /retropie to the USB stick's /RetroPie.At that point, the files are copied. If your ROMs were all on the SD card's /retropie partition, there's no need to do any more copying. But if they were on a USB drive, instead, then copy them, in the same folder layout the were in, to the new RetroPie partition - in my case, to /RetroPie/home/pi/RetroPie/roms/.
Now all your files are in place, but there's still work to do. From here, you need to edit two files, one is /boot/cmdline.txt and the other in the RetroPie partition. Mine was at /RetroPie/etc/fstab, but you may not have named your RetroPie partition the same as I did.
There's one thing to change in both files, the PARTUUID for your devices. Note that is NOT the UUID, but PARTUUID.
Use the
blkid
command. On some systems you need to use sudo to do that. You'll get output like this:/dev/sda1: UUID="b8b04816-a038-4833-91d6-1fe369ef6dad" TYPE="ext4" PARTUUID="92ac090c-01" /dev/sdb1: UUID="C961-5A41" TYPE="vfat" PARTUUID="32843ae4-ddaa-4f98-a6be-bcbccd49e418" /dev/sdb2: UUID="62379aba-7fb2-4f78-b225-fedd01406c3b" TYPE="ext4" PARTUUID="f684a3b1-7859-4658-9502-de5d571af014" /dev/sdb3: UUID="ab50c102-6bdf-4d96-91e5-c9fd5e1b1b3b" TYPE="swap" PARTUUID="0ddc5b5e-604e-48ee-8e25-fb1f56549105" /dev/sdd1: SEC_TYPE="msdos" LABEL_FATBOOT="boot" LABEL="boot" UUID="1D8D-D42B" TYPE="vfat" PARTUUID="6397c987-01" /dev/sdd2: LABEL="retropie" UUID="b5bfbb14-56d1-4eab-a831-0d17cd711a6a" TYPE="ext4" PARTUUID="6397c987-02" /dev/sdh1: UUID="19A1-8C38" TYPE="vfat"
Scan through this for the partition you need. For instance, in this, the device at /dev/sdd1 has the label "boot" and the one in /dev/sdd2 has the label "retropie". The PARTUUID for /boot is "6397c987-01". The PARTUUID for /retropie is "6397c987-02".
Now, in the /boot or /BOOT partition is the file cmdline.txt. Load it into your favorite text editor and the contents are something like this:
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=6397c987-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait loglevel=3 consoleblank=0 plymouth.enable=0
This file basically tells the system where to get the Linux kernel to load. Note the kernel is NOT on /retropie, but on the BOOT PARTITION. So replace the value of the PARTUUID with the UUID for the boot partition on your USB drive.
Now edit /etc/fstab in your RetroPie partition. It'll look something like this:
proc /proc proc defaults 0 0 PARTUUID=6397c987-01 /boot vfat defaults 0 2 PARTUUID=6397c987-02 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that
What you want is the line where the 2nd entry is '/'. Not /RetroPie. That's the partition we're using, but when it's mounted, it'll be just / and it's your base for the filesystem. In this case, it's on the 3rd line. Note the PARTUUID value there. You want to change that to the PARTUUID value from blkid for the /RetroPie partition. That way Linux knows where the file system for the whole thing is.
Once that is done, you're ready to umount both partitions so you can remove the USB drive from the system and plug it into your Raspberry Pi and boot it up.
Be sure your SD card is out of the Pi. I haven't tested it, but I'm told the SD card is earlier in the boot order than the USB drive. Also, since I have a Pi 3B+, I don't have to do anything to make sure it boots to the USB drive first. I did notice that when I used to boot from the SD card, I'd plug my Pi in and the red LED would come on and, almost immediately, the green one near it would start flickering. With no SD card and the USB in and being used for booting, it took 5-7 seconds before the red LED turns on.
From there, it should go normally - finish booting, bring up EmulationStation, and you're good to go.
-
@tango Thanks for sharing your insights! 👍
-
People here have given me a lot of help, so I hope I can help others!
-
@tango Thanks for this comprehensive writeup. That's the spirit of a community. :)
For all coming accross this post: This guide works only for Rpi 3B+ (Note the +).
For other models suppporting USB mass storage boot see prerequites here: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md
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.