You will need a Raspberry Pi 3 B(+) with a microSD card running RetroPie (or Raspbian).
-
Update Raspbian.
$ sudo apt-get update && sudo apt-get upgrade -y
-
Make sure you are running on the latest Raspberry Pi firmware.
$ sudo BRANCH=next rpi-update
-
Enable booting from USB. (This feature is experimental and cannot be reversed.)
$ echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt $ sudo reboot
-
(Optional) Verify that USB booting was enabled successfully.
$ vcgencmd otp_dump | grep 17: 17:3020000a
-
Set up the USB drive. This should be blank and unintialized. (No existing partitions.) The drive should be mounted as /dev/sda, but you should verify this before continuing.
# start the partition manager $ sudo parted /dev/sda # add a FAT partition table (parted) mktable msdos # create a FAT32 boot partition (parted) mkpart primary fat32 0% 100M # create an EXT4 partition for RetroPie (parted) mkpart primary ext4 100M 100% # double check that you are creating two partitions (parted) print (parted) quit
-
Format the partitions you just created on the USB drive.
$ sudo mkfs.vfat -n BOOT -F 32 /dev/sda1 $ sudo mkfs.ext4 -n /dev/sda2
-
Install
rsync
.$ sudo apt-get update && sudo apt-get install rsync -y
-
Copy the files from the SD card to the USB drive. (This step may take some time.)
# mount the target Linux partition $ sudo mkdir /mnt/target $ sudo mount /dev/sda2 /mnt/target # mount the target boot partition $ sudo mkdir /mnt/target/boot $ sudo mount /dev/sda1 /mnt/target/boot # synchronize the files between the SD card and USB drive $ sudo rsync -ax --progress / /boot/ /mnt/target
-
Mount the virtual filesystem on the USB drive.
$ sudo mount --bind /dev dev $ sudo mount --bind /sys sys $ sudo mount --bind /proc proc
-
Reset the SSH keys on the new installation. (They match the old host.)
$ sudo chroot /mnt/target # rm /etc/ssh/ssh_host* # dpkg-reconfigure openssh-server # exit
-
Unmount the virtual filesystem.
$ sudo umount dev $ sudo umount sys $ sudo umount proc
-
Reconfigure the boot files on the USB drive to search for the operating system on the new drive.
$ sudo sed -i "s,root=/dev/mmcblk0p2,root=/dev/sda2," /mnt/target/boot/cmdline.txt $ sudo sed -i "s,/dev/mmcblk0p,/dev/sda," /mnt/target/etc/fstab
-
Unmount the USB drive and power down.
$ cd ~ $ sudo umount /mnt/target/boot $ sudo umount /mnt/target $ sudo poweroff
-
Remove the microSD card and boot from the USB drive.