1

It's been two years since I modified my raspberry pi 3(model B).

In linux 4.1 I usually change the value of /sys/module/bcm2709/parameters/reboot_part to switch OS I want. But now I can't find it on linux 4.14.

Guys on IRC tell me it's no longer exist:

[17:24] Guest21160: it no longer exists. You can run 'reboot $part_no' instead

After command "reboot -f 5", it still boot from partition 1.

I think reboot command may need re-built, but does anyone know where I can get the source?

3
  • what bootloader do you use?
    – MaNyYaCk
    Jul 23, 2018 at 10:04
  • Now I use raspberry Pi 3 Model B+
    – Wally
    Jul 23, 2018 at 10:46
  • I got an answer - some one had the same issue : github.com/raspberrypi/linux/issues/2095 guys on IRC tell me that busybox's reboot implementation is unlikely to do it. So I use the sample code above the link and solve this.
    – Wally
    Jul 23, 2018 at 10:49

1 Answer 1

2

OK, First thing is the reboot_part is no longer exist since RPI linux branch 4.8.y.

All the posts are outdated if they told you to change this attributes:

Rebooting into a new OS

Enlaces entre varios sistemas operativos

The answer for current RPI linux is simply use system call function below:

syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, reboot_part);

Most modern linux init system (upstart, systemd) will implement their reboot command included the SYS_reboot system call.

So you simply can use command "reboot 5" to reboot from partition 5.

If you use busybox or something else that might not include this system call, you can just write your own, or just get a sample code from someone's post:

how to reboot into partition with new firmware but no systemd?

Here is the sample code I copied from the post above, thanks to matthuisman:

#include <linux/reboot.h>
#include <sys/syscall.h>
#include <signal.h>
#include <stdlib.h>

int main(int argc, char *argv[])  {
    char *param = NULL;
    int cmd;

    if(argc == 2) {
        param = argv[1];
        cmd = LINUX_REBOOT_CMD_RESTART2;
    }
    else {
        cmd = LINUX_REBOOT_CMD_RESTART;
    }

    sync();
    system("/etc/init.d/rcK || /etc/init.d/rc 0");

    sync();
    syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, param);

    return 0;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.