Have a Raspberry Pi and a nice, high capacity SD card? Sure you do, but that 32GB SD card has Raspbian installed on it and contains some Python scripts you spent hours writing. You have a 2GB SD card from an old smart phone lying around, but the minimal RetroPie image is 2.2GB. What do you do?
Now, this assumes you’re not an avid Retro Gamer, but you think it’d be fun to play Super Mario once in a while. You hear about RetroPie, a no-mess Linux distro that turns your Pi into a retro gaming console. You don’t want to delete your Raspbian install, and while you could install it on Raspbian, you fear that it could cause some library conflicts and/or system bloating you don’t want on your main OS. Luckily, there is a slightly ‘hacky’ way to install Retropie on that 2GB SD card, as long you have at least a 1GB USB drive lying around and access to a Linux OS (not on the Pi).
- x86/AMD64 Linux
- >= 1GB USB
- 2GB SD
- GNOME DE
Start by downloading the correct image of RetroPie from here.
Once downloaded, mount the image on your system (usually a double-click on GNOME 3) and insert the USB stick and SD Card.
Mounting the Retropie ‘.img’ file will show two partitions: ‘boot’ and ‘retropie’. Check the properties of each one and take note of the boot partitions size (it should be around ~35MB).
Formatting the Disks
I format the USB drive in the manner below because I assume that you normally use a Mac or Windows and having FAT32 first allows you to continue to access that partition from any machine. If you only use Linux, then the order does not matter.
- ~35MB (Check ‘boot’ from .img) FAT32
- Rest of space (~1.9GB) Ext4
- ~200MB (or Total - 800MB) FAT32
- 800MB Ext4
Installing The Root Partition
[Note] Now I am going to explain how to do the installation manually, but if you are familiar with Bash scripting, you can make this much shorter.
Open the virtual drive, ‘retropie’, in a file manager; it should show folders such as “bin” and “usr”.
In a terminal, find the location of the ‘retropie’ partition and the SD card, then ‘cd’ to the directory of your ext4 SD partition. (If you don’t know the directory you can use the mount command to find it.)
=> <something> on /run/media/coolguy/retropie
=> /dev/mmblock<xxxx> on /run/media/coolguy/c339423df98a0 ...
$ cd /run/media/coolguy/c339423df98a0
Now for each folder, except for “opt”, you will run the following command:
$ sudo cp -R -v --preserve=all /run/media/coolguy/retropie/<directory> ./
This will copy the files along with all of their attributes (which is important to keep executables able to execute).
“But what about the ‘opt’ folder, Sean? You didn’t copy that over.”
True, and this is because the “opt” folder contains the main Retropie information that would not fit onto the SD card. We could have done this with “usr”, the other large folder, but it also contains many important system functions that are needed to boot up, while even without “opt” one could still boot into the console.
Before changing directories, run the command
$ mkdir opt so we have an empty folder.
Installing and Linking the RetroPie Partition
‘cd’ to into the ext4 partition of your USB drive and then run the following command:
$ sudo cp -R -v --preserve=all <retropie_directory>/opt/* ./
$ sudo chmod -R 777 ./*
Now, on your second partition of your USB drive, you see ‘retropie’ and ‘vc’ folders.
The commands above copied the files from ‘retropie’s “opt” folder onto your USB drive and changed the permissions so that anyone can edit them (this will prevent issues upon booting).
Next, we need to tell the SD card where the opt partition is. Luckily, Linux has a file to edit to allow this quite easily.
$ cd <ext4_SD_partition>
$ sudo <text_editor> etc/fstab
You will see some text which you do NOT delete. Start a new line and type the following, trying to line it up like the lines above.
Note: This method assumes you’ll only have one USB drive plugged in when you.
/dev/sda2 /opt ext4 defaults 0 1
This addition tells the file system to mount the second partition of a USB drive to the “opt” folder on the SD card with read and write permissions.
Installing the Boot Partition
The partition will be copied in its entirety, so you will run our previous copy-paste command only using the “*” to copy everything from the virtual ‘boot’ partition to the first partition of the SD card.
$ sudo cp -R --preserve=all <boot_directory>/* ./
Optional and Not Personally Tested
The SD card will have a little over 100MB space left on it for games which is plenty for NES and SNES but very little for newer systems like the N64 or GBA.
In theory, we could link Retropie’s “ROM” folder to the first partition of the USB drive and use its 200MB+ space to store games in. I have not done so yet, due to having too much other data on my USB’s first partition to make it a better option.
Change the current directory to the root of the first USB partition (FAT) and copy the files of the old ROM’s folder:
$ sudo cp -R --preserve=all <sd_ext4_part>/home/pi/RetroPie/roms/* ./
Then rename the old ROM’s folder (or delete it if you don’t feel the need to keep a backup) and create a new empty folder with the same name.
Finally, go back to the “fstab” file we edited earlier and add the following line to it:
/dev/sda1 /home/pi/RetroPie/roms vfat defaults 0 1
Congrats! If you have followed all of the steps then you now have the ability to run RetroPie on a 2GB SD card (well, sort of).
Plug in the SD card and USB drive and let it boot up, on the first run it should end up in a blue screen and then reboot. After this, as long as you have both components plugged in, then you will be greeted with the traditional RetroPie interface. If for whatever reason, you forget the USB or it is damaged, the system will boot to a basic terminal to do maintenance.
If you want to read more about using RetroPie itself, check out this article from Lifehacker.