Welcome! Log In Create A New Profile

Advanced

Q. Mounting a root file system with the /sbin/init file of a ramdisk?

Posted by linus 
Q. Mounting a root file system with the /sbin/init file of a ramdisk?
January 26, 2010 06:12AM
#!/bin/sh
echo INITRD: Trying to mount /dev/mmcblk0p1 as msdos

mount -n -t msdos /dev/mmcblk0p1 /mnt

echo INITRD: Mounted OK

losetup /dev/loop0 /mnt/linux/linuxdsk.img

That is the text of my /sbin/init. the screen displays "INITRD: Mounted OK" and then "kernel panic-not syncing:.." and a lot of numeric trace information.

Any ideas? I want the loop to be mounted as the new root file system. Do I need to call "pivot_root"?
Re: Q. Mounting a root file system with the /sbin/init file of a ramdisk?
January 27, 2010 12:55AM
Try chroot.
Re: Q. Mounting a root file system with the /sbin/init file of a ramdisk?
January 27, 2010 01:13AM
In my understanding "chroot" changes the root directory "/" location. What I want to do is mount a new root file system, but it may still work. The problem is I cant test it, because I get kernel panic at the losetup line of my init file.
Re: Q. Mounting a root file system with the /sbin/init file of a ramdisk?
January 29, 2010 02:25PM
I was thinking that what you could try is mounting /dev/loop0 and then chrooting to wherever you had mounted it.

Granted, I don't know much about Linux, and that's not the best solution, but it may work.
Re: Q. Mounting a root file system with the /sbin/init file of a ramdisk?
January 30, 2010 02:30AM
#!/bin/sh
mount -n -t msdos /dev/mmcblk0p1 /mnt
losetup /dev/loop0 /mnt/linux/linuxdsk.img
mount -t ext2 /dev/loop0 /mnt2
cd /mnt2
pivot_root . initrd/
exec /sbin/init

This is what I have now. It works to mount the loop and boot into it, but I still need to free the ramdisk
Re: Q. Mounting a root file system with the /sbin/init file of a ramdisk?
February 07, 2010 06:03AM
exec /usr/sbin/chroot . sh -c 'umount -l /initrd; blockdev --flushbufs /dev/ram0; exec /sbin/init' \
dev/console 2>&1

This is my new revised final line. I changed from ext2 to ext3 as well. I am now booting a single 800mb loopback file of xwhiite from the sole FAT partition of my SD card.
Sorry, only registered users may post in this forum.

Click here to login