How to mount final root filesystem after loading initrd?

The Netgear NAS forum
Post Reply
JPT
Posts: 2
Joined: Fri Mar 08, 2013 5:21 pm

How to mount final root filesystem after loading initrd?

Post by JPT » Mon Mar 11, 2013 5:11 pm

Hi,

I am trying to install a debian on my ReadyNAS Duo V2 since a week now.
It's far from easy....
Well, my current problem is, that I would like to mount my root filesystem instead of the stock one.

I simply add INIT=/bin/sh to the BOOTARGS, so the boot stops before mounting the root fs from harddisk.
I provided my root filesystem on USB drive.

Now, this is what I did after booting into initrd:

Code: Select all

~ # mkdir new-root
~ # mount /dev/sda1 new-root
~ # cd new-root
/new-root # mkdir old-root
/new-root # pivot_root . old-root
pivot_root: Invalid argument
this more or less cut&pasted from the pivot_root man page.

Tried to move the other mounts, as I found a suggestion in the web.

Code: Select all

$ mount --move /sys /new-root/sys
$ mkdir /new-root/dev/pts
$ mount --move /dev/pts /new-root/dev/pts
$ mount --move /dev /new-root/dev
$ mount --move /proc /new-root/proc
Tried rotating root using switch_root.
And added EXEC in front...

Code: Select all

$ exec switch_root -c /dev/ttyS0 /new-root /init
[... outputs usage info but no meaningful error message ...]
Bringing up RAID arrays...mdev: /sys/class: No such file or directory
done
Bringing up network...done
ERROR: Could not mount data partition [/dev/mtdblock4] (No such file or directory)
mdev: /sys/class: No such file or directory
/bin/ash: can't access tty; job control turned off

Code: Select all

$ exec pivot_root . old-root
pivot_root: Invalid argument
Bringing up RAID arrays...mdev: /sys/class: No such file or directory
done
Bringing up network...done
ERROR: Could not mount data partition [/dev/mtdblock4] (No such file or directory)
mdev: /sys/class: No such file or directory
/bin/ash: can't access tty; job control turned off
But it does not behave like expected. My observations are:
- when I add a exec in front of pivot_root or switch_root, I get the same error message, but some init seems to be executed afterwards.
- the init called seems to be the init from initrd, it did not rotate root.

Does anyone have a hint?


thanks,

JPT

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: How to mount final root filesystem after loading initrd?

Post by Mijzelf » Mon Mar 11, 2013 7:13 pm

/new-root # pivot_root . old-root
pivot_root: Invalid argument
Are you sure old-root and newroot aren't the same filesystem?

JPT
Posts: 2
Joined: Fri Mar 08, 2013 5:21 pm

Re: How to mount final root filesystem after loading initrd?

Post by JPT » Tue Mar 12, 2013 7:23 am

Are you sure old-root and newroot aren't the same filesystem?
As far as I understood, old-root is where / gets mounted after new-root is /
That's why old-root has to be a directory on the new filesystem.

Mijzelf
Posts: 6206
Joined: Mon Jun 16, 2008 10:45 am

Re: How to mount final root filesystem after loading initrd?

Post by Mijzelf » Tue Mar 12, 2013 10:25 am

Yes, that is true, but the kernel isn't happy with the parameters you pass. The error message you see is from the kernel, rejecting the current parameters.

From the man pages:
The following restrictions apply to new_root and put_old:

- They must be directories.

- new_root and put_old must not be on the same file system as the current
root.

- put_old must be underneath new_root, that is, adding a nonzero number of
/.. to the string pointed to by put_old must yield the same directory as
new_root.

- No other file system may be mounted on put_old.
So in your snippet of code the only reason I can think of why it fails, is because sda1 already is mounted on / before the pivot_root is called.

Post Reply