I have a doubt about boot process, is possible set boot partition from boot if /dev/root fails? like a grub select. I prefer no use berryboot and my install is noobs based. My idea is set a boot partition failover for data corruption on SD card. Any ideas?
2 Answers
You need to edit /boot/cmdline.txt
and define root=PARTUUID=
, for example root=PARTUUID=1e4c4b75-02
You can have multiple partitions, up to 3 (except boot one), with different OS.
To find your destinated PARTUUID you can use this command:
ls -l /dev/disk/by-partuuid/
Each of rootfs partitions have to have own /etc/fstab
with its PARTUUID
You can prepare two folders /boot/os1
and /boot/os2
with separated kernels
/cmdline.txt
. Than just move content of needed os to /boot and it works just like full separated dual boot.

- 121
- 4
No. You could (I believe this is what something like berryboot probably does; I haven't used it) load a minimal root fs, possibly from an initramfs, present the user with options, and then switch the root filesystem (which is what initramfs kernels always do), but obviously there is a bit of work involved.
Alternately, you could write your own bootloader code, but this is even more work, and may require some proprietary knowledge (I'm not sure).

- 58,859
- 17
- 112
- 227
-
I think you can load busybox (grub, or that new bootloader) onto the boot partition, from which you can then use some logic to start a kernel on any other parition. Just something I read somewhere. But you need to compile the
boot.img
with all this.. that didnt look to easy for me. – Piotr Kula Dec 02 '15 at 19:40 -
@ppumkin No, you would need a kernel before busybox, which can be used as a drop-in for init without needing a rootfs. It can't act as it's own kernel. So similar to the initramfs idea. Note you can built an initramfs into the kernel, presumably one including busybox -- although don't think there would be much advantage to that, because you might as well just load an initramfs from the first partition. – goldilocks Dec 02 '15 at 19:44
-
Ahh.. right. So I wonder if he could put a busybox kernel on the default parition where Raspbain would be (EXT2) not on the (FAT), and from the busybox chain load the actual kernel he needs, like from NFS or whatever. He could use a 8MB SD Card (if that is even supported) - Yea? – Piotr Kula Dec 02 '15 at 19:46
-
https://www.raspberrypi.org/blog/boot-from-a-16mb-sd-card/ - This links to a tutorial where they use a custom bootloader and change something in a text editor to direct from where to chain load the actual kernel. Pretty cool, but the filesytem needs to be mounted/accessible though, ie USB drive. – Piotr Kula Dec 02 '15 at 19:49
-
"from the busybox chain load" -> That's sort of what I'm saying about the initramfs -- which normally is basically a lot like busybox, an init plus some utilities (and kernel modules, but the relevant stuff is just built in on the pi). You can do whatever you want in it, it's a tiny OS. That includes various ways to switch the seat of the root filesystem. Except I don't see the point in chainloading a different kernel unless you want something non-linux -- dunno what the options there would be. – goldilocks Dec 02 '15 at 19:51
-
-
@ppumkin Actually that link is just about changing
cmdline.txt
so you can use a root filesystem on a different device (USB stick). That still won't allow you to select a root fs; if the stick is not there you will be stick out of luck ;) – goldilocks Dec 02 '15 at 19:55 -
More info about select partition to start, bassically we can edit file: cmdline.txt with root=/dev/mmcblk0p2 or whatever you want under /boot partion and select a previous stored partition. It's good to keep different versions and play manually between theirs. Next step could be add logic after fcsk on boot to choice a healthy partition and continue boot. Suggestions? – Angeloide Dec 03 '15 at 10:00
-
Is possible launch commands or scripts after to force a fsck on server reboot? (power fails and probably raspi has a corrupted/irrecoverable data partition) is this point some logic can be insert other cloned partition to cmdline.txt – Angeloide Dec 03 '15 at 10:17
-
You can unequivocally force a fsck, i.e., so that it lalways happens no matter what. It may add 10-15 seconds to your boot time depending on the size of the card. – goldilocks Dec 04 '15 at 04:12
-
Yes, but the question is: after check partition results corrupt then raspi boot hangs, Can I execute some code at his point to change partition on cmdline? Then raspi reboot and finish boot from other install. – Angeloide Dec 04 '15 at 09:21
-
I've already answered that. There are probably thousands of pages around explaining initramfs. They are not normally used on the pi because they are not necessary, but they could be for this purpose. – goldilocks Dec 04 '15 at 10:44
cmdline.txt
containsroot=/dev/mmcblk0p2
(at least for Rasbpian different if NOOBS). You can change this to a different partition (provided \etc\fstab is correctly set in the partition). I don't normally bother with multi-boot on a Pi. A 8GB SD costs $7 - I just swap SD). – Milliways Dec 02 '15 at 12:20