Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
custom initramfs: switch_root woes [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Ramblurr
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2006
Posts: 103

PostPosted: Mon Apr 09, 2007 4:10 pm    Post subject: custom initramfs: switch_root woes [Solved] Reply with quote

I'm implementing the dm-crypt w/ Luks disk encryption solution as outlined in this wiki entry. The problem might be unrelated to dm-crypt or Luks, so I figured it might help to open the issue up to a wider audience.

The unlocking and mounting is working fine, however when I get to the bit where I need to switch_root and execute the init that exists on my disk my system just sorta.. does nothing.

I enabled debugging (-x) for /bin/ash (i'm using busybox 1.2.2.1). And this is the output at the time it needs to switch:
Code:
+ exec switch_root /new-root /sbin/init


And that's it. I've tried a million things now. I thought it might be my /etc/conf.d/cryptfs or fstab, but those are both correct.
It simply freezes after switch_root'ing... the cursor still blinks, I can make new lines, and a few keys work. But Ctrl+z or c does nothing. ctrl+alt+del doesn't reset it. Alt+F#s doesn't change anything. My only option is to perform a hard reboot.

I've verified that the root system is actually mounted in /new-root and /sbin/init exists (/new-root/sbin/init) with correct permissions. Anyone think they might know what the issue is?


Last edited by Ramblurr on Tue Apr 10, 2007 7:14 pm; edited 1 time in total
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1738
Location: Emerald Isles, overlooking Dublin's docklands

PostPosted: Mon Apr 09, 2007 4:24 pm    Post subject: Reply with quote

didn't touch LUKS yet, but don't you usually use "pivot_root" to get change the root filesystem?
_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( Twitter | Blog | GitHub )
Back to top
View user's profile Send private message
Ramblurr
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2006
Posts: 103

PostPosted: Mon Apr 09, 2007 4:41 pm    Post subject: Reply with quote

I thought so too, but...

Quote:
You can't use pivot_root from rootfs because rootfs can't be moved or unmounted; switch_root is for initramfs, and pivot_root is for initrd.


and

Quote:
One point that was perhaps not made strongly enough is that pivoting is an initrd thing *only*. initrd and initramfs are separate things and work quite differently.



Others have sucessfully used switch_root. I am wondering if something is wrong with /sbin/init. I do have the latest version of sysvinit (in portage).


edit:

do I need to specify a '-c /dev/console' flag for switch_root? I thought it would use the current console. If the console was bad though I should get 'switch_root: bad console'
Back to top
View user's profile Send private message
wynn
Advocate
Advocate


Joined: 01 Apr 2005
Posts: 2416
Location: UK

PostPosted: Mon Apr 09, 2007 4:46 pm    Post subject: Reply with quote

Ramblurr wrote:
do I need to specify a '-c /dev/console' flag for switch_root? I thought it would use the current console. If the console was bad though I should get 'switch_root: bad console'
Code:
/usr/share/genkernel/generic $ grep switch_ *
linuxrc:        exec switch_root -c "/dev/console" "${CHROOT}" ${REAL_INIT:-/sbin/init} ${INIT_OPTS}
It looks as though you do.
_________________
The avatar is jorma, a "duck" from "Elephants Dream": the film and all the production materials have been made available under a Creative Commons Attribution 2.5 License, see orange.blender.org for details.
Back to top
View user's profile Send private message
Ramblurr
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2006
Posts: 103

PostPosted: Mon Apr 09, 2007 8:38 pm    Post subject: Reply with quote

Well I got the Bad Console error.


Code:
exec switch_root -c /dev/console /new-root /sbin/init
switch_root: Bad console '/dev/console'
Kernel Panic - not syncing: Attempted to kill init!



I did create /dev/console in my initramfs with:

Code:
mknod --mode=0600 /path/to/build_initramfs/dev/console c 5 1


Is there another way to do this?

EDIT: Aha something! I downgraded busybox to version 1.1.2. I removed the -c /dev/console bit too.

Now after the exec switch_root line I get:
Code:
udevd-event[2311]: udev_node_mknod: mknod(/dev/bus/usb/001/001, 020664, 189, 0) failed: No such file or directory

Is this some sort of mknod incompatibility because of the downgrade, or is it having trouble finding the usb device?

Oh, and yes, I'm booting from a usb stick if I didn't mention that already.
Back to top
View user's profile Send private message
wynn
Advocate
Advocate


Joined: 01 Apr 2005
Posts: 2416
Location: UK

PostPosted: Tue Apr 10, 2007 8:46 am    Post subject: Reply with quote

I'm not sure I follow all that but I think the bad console error is because there is no /newroot/dev/console.

I think, if you look at genkernel's linuxrc, you will find that it creates several things under /dev before it runs switch_root.
_________________
The avatar is jorma, a "duck" from "Elephants Dream": the film and all the production materials have been made available under a Creative Commons Attribution 2.5 License, see orange.blender.org for details.
Back to top
View user's profile Send private message
Ramblurr
Tux's lil' helper
Tux's lil' helper


Joined: 18 Dec 2006
Posts: 103

PostPosted: Tue Apr 10, 2007 7:14 pm    Post subject: Reply with quote

Thanks :) That worked it out.

I passed ichkpt=6 as a parameter then when I got the shell executed:
Code:
mknod /new-root/dev/console c 5 1


then 'exec switch_root -c /dev/console /new-root /sbin/init' worked fine.

Solved finally!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum