Does a USB drive need a boot sector to boot properly?
-
This is related to a question I asked in March but have not had time to follow up on - until now. Coming back to the topic, I realize there's a possible issue I want to check on first.
If I make the change on a Pi 3B to make it boot the USB drive (instead of the SD card), other than copying the entire RetroPie system to my USB drive, do I have to do anything like create a boot sector on the USB drive? Or will just having the /boot directory be enough for the Pi to find what it needs to boot it?
Note I'm not asking about what I do to the Pi itself, I'm asking if I have to do anything special on the USB drive to change to that as a boot device. The previous thread was quite helpful in handling things with the Pi - I just never thought to ask about any alterations to the USB media.
-
@tango boot sector? no. But:
The USB drive needs a boot partition. Usually a FAT32 partitiion at least 128MiB, more than 256MiB is wasted space. No need to set the bootable flag on that partition, a Rpi boots also fine without that flag. Here is a detailed guide on preparing that partition [1]. Just copy everything from the sdcard
/boot
to it.The Rpi does check for the file
start.elf
on any connected USB-drive. See here (last section) [2]I would flash a fresh Retropie Image to an USB drive, and then copy the regular files to it from your backup, backup option 2 [3]
Some more thoughts: As you communicated your Arcade is located in a barn and the boot failure only happens after someone left the Arcade powered on.
Idea: Why not utilize the sleep and wake functions? [4] Note however that these are only effective when an emulator is exited (i.e. you are back in the Emulationstation).
The sleep script would contain something likesleep 1h && sudo sync && sudo halt -p
The wake script would contain something like
kill -9 $(pidof sleep)
[1] https://www.stephenwagner.com/2020/03/21/create-boot-partition-layout-raspberry-pi/
[2] https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md
[3] https://retropie.org.uk/docs/Updating-RetroPie/#making-a-backup
[4] https://retropie.org.uk/docs/EmulationStation/#scripting -
@lolonois Thanks for some good info. Please understand that right now I'm exhausted - it happens a lot lately! So if I miss something, feel free to point out what I missed - but I'll try to keep it all straight.
The USB drive is 256MiB and has a lot of ROMs on it (many, honestly, need to come of - my source had many, many copies of some ROMs because of the way the drive was organized). I put it on a Linux system that reported it was 1 partition and was VFAT. Can I boot from that? (Checking because I'm hoping for any kind of short cut - like just copying my current Linux files over from SD to USB.)
I will be going through all the links you included - Really appreciate those! I'm just hoping for any short cut I can use so I don't have to go through /etc and figure out which config files have my changes and which don't. (I know - use ls and check dates, but it's still a pain, since also means looking over and modifying things like fstab so it works with the new setup.)
Longer stuff that isn't a direct connection to booting:
That's a good solution to handling the sleep and hibernation for the arcade system, but it's going to be a moot issue soon. We're out in the boonies and when we had the house built, I bought a good generator that would power things out here and would be able to handle the barn, too, with load sharing. The issue was that the electrician that wired the house - well, let's just say there are reason I will never hire him again and why I got someone else to wire the barn when we finished renovations.
The good electrician has been working with me, gradually, to fix the shortcomings from the first electrician. Within a month, we will have the barn on the generator, too - and the load sharing will be implemented as it should have been. (Long story about why the first guy didn't use it, but it can be summed up with the words "ignorant in his own field.") I'm getting UPS's for the equipment in the barn - the arcade machine, the entertainment center, my wife's computer (she has an art studio on the 2nd floor) and for my computer and CNC system in the workshop (also on the 2nd floor). The generator never takes more than 45 seconds to kick in, so, for almost everything, we can use small capacity UPSes, since nothing has to be powered for as long as a minute!
So the unplanned shutoffs will be a thing of the past - unless we lose power for something like a week and are on vacation and can't call for a propane refill!
-
I've been dealing with other issues, so it's taken me awhile to get back to this, but I like to leave notes on how something worked for future readers of a thread.
First, this issue raises a question: Other than changing UUIDs in the boot config and in /etc/fstab, is there anything else I need to change when I move a RetroPie install to a different partition or drive?
I took a 2nd USB drive and partitioned it, giving it 512MB for a FAT32 boot partition and I created another ext4 partition with the rest of the space. (I considered using FAT32 for both, so I could easily read the system partition on my iMac and on a Windows system.) I used rsync to copy everything from my SD card to my USB drive and put the new USB drive into my Pi and turned it on.
The red LED stayed on long enough I was thinking it wasn't going to boot, but then the multi-color screen showed up and the green LED started flashing. The three raspberries showed up at the top of the screen, but it never got farther than that. The green LED would flash, on and off, and then stop, then start again.
I'm wondering if I need to change the UUIDs for the drives - both in the boot configuration and in /etc/fstab to get it to boot.
At this point I have two choices, one much easier than the other. I'm hoping all I need to change is device UUIDs to point at the proper new sys partition.
If that doesn't work, it means I have to basically do a fresh RetroPie install, which I can do, but I do NOT want to have to recostumize by tracking down all the config and setting files I've edited and copy them to the new partition/device. I know I made a lot of modifications and really don't want to have to track them down. While most are in /etc, there's also things like .bashrc, my ssh keys, and a lot of stuff I likely don't remember right now.
-
@tango in general you did the right steps. From the distance just a guess: Did you use the UUID or PARTUUID from the
blkid
output? The pi uses/needs the PARTUUID in/boot/config.txt
and/etc/fstab
.
I found a comprehensive guide which has all the details: https://www.pragmaticlinux.com/2020/08/move-the-raspberry-pi-root-file-system-to-a-usb-drive/Good to see you made progress as I was too busy to answer in a timely manner.
I never did run a linux from a FAT32/vfat partition. After you checked my first guess, this may be another showstopper. The guide above shows how to transfer the files to an ext4 partition (in the section "Copy the SD card root file system to the USB drive").
Chances are that it won't remediate the solution as several files/folders are connected via Linux softlinks in a juvenile retropie installation. They may break / or are broken already as Linux softlinks and Windows (FAT32) symbolic links are not compatible. This would mean you would have to go the long way (fresh installation and manual rom and config copy and recheck). :/On a side note: Microsoft recently communicated they are able to read/write ext4 with the "Windows Subsystem for Linux 2". But i never tried that. MacOs should also be able to handle ext4 as it is based on a Unixoid core.
-
@lolonois You are right twice in that last post!
First, I used the UUID and not the PARTUUID. I changed that and got past the 4 (I thought it was 3 - had just glanced at it) raspberries at the top of the screen and it went through most of the boot process, including putting up the RetroPie splash screen, but then that went and I got a message about being in emergency (or is it restore?) mode. I wondered if the issue could be the - well, I don't know what to call them, but the files that are used as pointers to hardware and so on, like in /dev. I've had cases where I have problems like that on a reboot, so I reboot again and they've been repaired in the process. So I rebooted and it didn't work and went back to look over your link.
I used
rsync -av <source> <dest>
and it really needsrsync -axv <source> <dest>
, just one difference - include the 'x' switch (which specifies to keep extended attributes). So I re-copied the files from the SD card /retropie partition to the /RetroPie partition on the USB drive using the suggested version of the command.It booted and got to EmulationStation. I think I saw a warning before ES came up (I suspect it's about the root account being locked - that's the one I got when it wouldn't completely boot) and I don't have the ROMs in place yet on that drive. I was testing it in my study, where I didn't have extra controllers to hook up, so I couldn't control ES or quit it to check on the warning. Tomorrow or later in the week I'll be able to take it back down to the barn where the arcade cabinet is and test it on that, where I have controllers and a keyboard and check it out.
Thank you!
-
I got it all working and wrote up notes on what I had to do in this post.
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.