Mount an .IMG file to get ROMs


Mount an .IMG file to get ROMs

There are several images (.img) outhere, specially for Raspberry Pis and other SBCs, which contain full set of ROMs, with some of the best games or just all. The best thing about these images is that they contain in game pictures, videos with gaming preview and also you are sure, that they play on a specific emulator, like MAME. This way, you know that the ROM set included, works with the included emulator.

So, i wanted to build my ROM collection, by not just getting every ROM, out there, but with a few selections of the best games, for each platform. I was specially cared about arcade game ROMs, which are my favorite. Instead of finding web sites, full of ads, that you have to click several times for just downloading one game, i tried the method below and got a complete set of ROMs, with only a few clicks.

First, you have to get one of these retro collection images, for Raspberry. I wont give a link, but there are some ARCADE PUNKS out there, who offer such images ;) Get one and open a terminal...

Go inside the folder you have the image files and give this command: fdisk -l <filename>.img you will get some information about the file, like this:

Disk CoinJunkiePiZero16gb2-s.img: 13,91 GiB, 14940353024 bytes, 29180377 sectors
Units: sectors of 1 * 512 = **512** bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x14a75fe9

Device                       Boot  Start      End  Sectors  Size Id Type
CoinJunkiePiZero16gb2-s.img1 *      8192   124927   116736   57M  e W95 FAT16 (L
CoinJunkiePiZero16gb2-s.img2      124928 29180376 29055449 13,9G 83 Linux

There are two partitions in this disk/image file, as it should be. We don't care about the first one. The second one has the goodies. To mount this partition we first create a folder in our system, where we will mount the image. For example: sudo mkdir /media/user/rpi_image. Also make you as the owner of the folder with: sudo chown user:user /media/user/rpi_image

The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount. To do this we multiply the Sector Size, in this case is 512, with the partition Start position, which is 124928. So, the offset will be: 512 x 124928 = 63963136.

To mount the specific partion we give this, in the terminal: sudo mount -o loop,offset=63963136 file.img /media/user/rpi_image

Check your file manager ;) Navigate into the RetroPie directory and you will find all roms, bios, images and videos gathered and organized, waiting for you...

Add a comment

Previous Next