UPS for Raspberry PI 4B?
-
Hardware:
PI 4B
5.1V | 3A
Arcade joysticks and Button
32 GB SanDisk
64 GB USB DriveI've been getting a lot of power interruptions recently and I'm worried that one of them might result in data corruption or damage some of the hardware. I'm running a Raspberry PI 4B and I'm considering installing a UPS to reduce the risk. But how large is the risk of power interruptions damaging data and hardware?
Do you think it's necessary UPS for the system?
Which UPS would you recommend me to use?I'm also planning to build another arcade for a friend who will probably leave it on all of the time and let his kids play, so I think I'll probably put a UPS for that.
This is the UPS I'm planning to get right now: https://shopee.ph/PiJuice-HAT-Raspberry-Pi-Portable-Power-Platform-i.20469516.1550503335
-
Designed for the Raspberry Pi A+, B+, 2B, 3B and 3B+ but also compatible with Raspberry Pi Zero v1.3 and Raspberry Pi Zero Wireless.
Will this work OK with the Pi 4B? Is the form factor correct to line up with the GPIO pins?
-
I built a handheld recently and used the PiJuice for power, with a 12000mah battery hooked up. It's powering a Pi4, 5" screen and an Arduino Micro, and I would estimate that I'd get about 4-5 hours on a full charge. The software they have is excellent too, there's a regular desktop GUI, or a command-line interface. The amount of settings you have and custom script options is excellent. Can't fault it at all.
-
Nice. From what I read it uses only the physical pins 1 to 6 of the GPIO.
This means if you plan to attach more than one GPIO based controller (4 directional buttons, 6 A/B/X/Y/TL/TR buttons and 3 for Select, Start and Hotkey) you will need a MCP23017 in between (which also utilizes i2c ports as the powerbank).
The SD-card (slot) is most sensitive part in underpowering ( (the yellow lightning bolt), so if you only put
/boot
on the SD-card and put all the rest on the USB drive (or USB attached SSD) it will give you extra safety preventing corruption. -
@Mark_McQ I was also thinking about cases and enclosures if they were going that route. I'm not familiar with the hardware so I didn't know if things were still in the right places.
-
@iandaemon I think a couple other people mentioned it, from what I read PIJuice seems compatible, though not the best form factor. I'm not really too worried about putting a case or anything like that, though.
I'm just mostly worried if it can feed enough power (so the system won't be forced to run slower) and that the software on a pijuice might be incompatible with retropie.
@Mark_McQ btw, was your hand-held one also running retropie? Just curious if the software is compatible and for any issues
@Lolonois thanks, I didn't even consider that. Luckily, the controls I use are connected using the USB ports on the PI 4, so that shouldn't be an issue. I store the roms and save files on the USB drive, but I put the Retropie OS on the SD Card. Is that what you mean by /boot?
Overall, I think I'll probably get the PIJuice and see if it works, worst case scenario, I can save it for another PI project
-
@hellothere The
/boot
folder contains a few low level firmware files to initialize the Rpi hardware. It is usually not very large (around 150 MiB). [1]What I was refrering to is that you can leave the first partition (which is later, when the pi up and running mounted at
/boot
) on the sdcard and everything else on the USB drive. The setup may be a little more sophisticated than your current. If you are interested I can provide a sketch on how to set it up, just let me know how familiar you are with Linux and editing/boot/cmdline.txt
and/etc/fstab
[1] https://www.raspberrypi.org/documentation/configuration/boot_folder.md
-
@lolonois I'm not really familiar with using Linux or editing those files, but I can learn it and if you can give a rough outline on how to set it up that would be great
Leaving /boot on the sd card seems more straight forward, but why would you do this over just moving everything to a usb flash drive/ssd and booting up from the usb device?
-
@hellothere don't want to leave this unanswered.
Prereq:
Have a USB drive or SSD with same or larger capacity than your SD card.
When using an SSD SATA to USB adapter make sure it is fully UASP to get max. transfer/access speed. Here are some hints [1] - also this site has more details as I do provide below.It goes like this:
- Make a full backup of your SD-card (eg. with Win32DiskImager (<- easiest), Clonezilla, ...) to your desktop PC.
- Put that backup at your USB drive / SSD (again using Win32Diskimager or the tool of your choice) on your desktop PC.
- Resize the USB partition (only if the USB drive is larger than SD card).
- Advise the pi to use a different partition after initial booting from
/boot
, handing over to the USB drive.
When you are done with the backup (Step 1 and 2 from above) attach both (SD card and USB drive) to the Rpi.
Remove any additional USB storage attached to the pi to avoid confusion.
Boot/Power up.
Nothing has changed up to this point.Note: Following steps are the crucial part - but no worries you have a backup. If something derails, you can back out by using the backup.
Step 3: Optional: Resize the USB partition (if USB drive is larger than SD card).
SSH to your pi as user pi. Type
sudo su
Issue
blkid /dev/sda*
blkid /dev/sda* /dev/sda: PTUUID="e006ca92-3704-44b9-a15f-bc56e2171825" PTTYPE="gpt" /dev/sda1: UUID="4832bb70-bb77-4a4a-9d68-5541559df133" TYPE="ext4" PARTUUID="9ec38a7c-ff79-413f-bddc-fc66de260c13"
Note the partition number /dev/sdN on the left which has the TYPE="ext4".
Run with that number
resize2fs /dev/sdN
(replace N with your number identified, most likely it will be 2).
Wait for process to finish.Step 4: Advise the kernel to mount a different partition as "root-filesystem".
I underlined the items to REMOVE in RED and those to ADD in GREEN.
The red and green values are different on your machine. Use those. Not those from the example!
SSH to your pi as user pi. Type
sudo su
gets you root.
Issue
blkid /dev/sda*
Will give you a similar output as above.
Note down the value of PARTUUID of partition with TYPE="ext4" (in the example 9ec38a7c-ff79-413f-bddc-fc66de260c13). There should be only one with this type.Edit fstab (with editor nano (<-- easiest) (or editor of your choice)):
mount /dev/sda1 /mnt # <-- this should be the same sdN as used in resize2fs, will mount the partition from the USB drive. nano /mnt/etc/fstab
You will find something like this:
These current PARTUUID point to partitions on your SD card.( You can verify it with
blkid /dev/mmcblk0*
)The second entry has to be altered to contain the PARTUUID you noted down before. For example:
Again: Use your identified PARTUUID value.
You don't have to keep the lines starting with#
(=comment)
Save the file.Almost done: Then edit cmdline.txt, last step before rebooting:
nano /boot/cmdline.txt
You will find something like:
This instructs the kernel to look for the root filesystem at the partition PARTUUID, currently the SD card.
Make it read, change only the PARTUUID, leave everything else as is:
Save the file. Reboot... Drum roll, please!
After reboot, ssh to your pi, then check with
mount
command:mount | grep sda
Should output something like:
/dev/sda1 on / type ext4 (rw,noatime)
That's it. Revel in your success.
[1] https://jamesachambers.com/raspberry-pi-4-usb-boot-config-guide-for-ssd-flash-drives/
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.