Loopback mounting the root filesystem using nash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
   I've been working on trying to build a really tiny SELinux enabled
version of fedora and I am getting stuck with something things in nash.
I created a file called rootfs.img using the following commands:

dd if=/dev/zero of=rootfs.img count=1 bs=64MB
mke2fs -j -F -i 1024 rootfs.img

I then mounted it as a loopback fs and proceeded to copy the appropriate
filesystem structure and what I need to get the system running with
busybox into it.

I ran into a problem when I tried to use this from an initrd.

I first tried to losetup the file onto /dev/loop0 but kept getting loop:
can't get info on device /dev/loop0: No such device or address. I
thought it was because I was missing the loop device so I created it
with mknod /dev/loop0 b 7 0 (as it is on my actual fedora box) but this
didn't help.

The next thing I tried was to not bother with this and just use the -o
loop option to mount but this fails with the error "mount: error
mounting /rootfs.img on /sysroot as ext3: Block device required"

I started by unpacking the initrd that is for the kernel that I am
currently running so at some point it worked. I have pasted the modified
init script that I am using in hopes that someone can help me figure out
what I am doing wrong.

Dave

#!/bin/nash

mount -t proc /proc /proc
setquiet
echo Mounting proc filesystem
echo Mounting sysfs filesystem
mount -t sysfs /sys /sys
echo Creating /dev
mount -o mode=0755 -t tmpfs /dev /dev
mkdir /dev/pts
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
mkdir /dev/shm
mkdir /dev/mapper
echo Creating initial device nodes
mknod /dev/null c 1 3
mknod /dev/zero c 1 5
mknod /dev/systty c 4 0
mknod /dev/tty c 5 0
mknod /dev/console c 5 1
mknod /dev/ptmx c 5 2
mknod /dev/tty0 c 4 0
mknod /dev/tty1 c 4 1
mknod /dev/tty2 c 4 2
mknod /dev/tty3 c 4 3
mknod /dev/tty4 c 4 4
mknod /dev/tty5 c 4 5
mknod /dev/tty6 c 4 6
mknod /dev/tty7 c 4 7
mknod /dev/tty8 c 4 8
mknod /dev/tty9 c 4 9
mknod /dev/tty10 c 4 10
mknod /dev/tty11 c 4 11
mknod /dev/tty12 c 4 12
mknod /dev/ttyS0 c 4 64
mknod /dev/ttyS1 c 4 65
mknod /dev/ttyS2 c 4 66
mknod /dev/ttyS3 c 4 67
mknod /dev/loop0 b 7 0
echo Setting up hotplug.
hotplug
echo Creating block device nodes.
mkblkdevs
echo "Loading ehci-hcd module"
modprobe -q ehci-hcd
echo "Loading ohci-hcd module"
modprobe -q ohci-hcd
echo "Loading uhci-hcd module"
modprobe -q uhci-hcd
mount -t usbfs /proc/bus/usb /proc/bus/usb
echo "Loading loop module"
modprobe -q loop
echo "Loading ext3 module"
modprobe -q ext3
echo "Loading scsi_mod module"
modprobe -q scsi_mod
echo "Loading sd_mod module"
modprobe -q sd_mod
echo "Loading scsi_transport_spi module"
modprobe -q scsi_transport_spi
echo "Loading mptbase module"
modprobe -q mptbase
echo "Loading mptscsih module"
modprobe -q mptscsih
echo "Loading mptspi module"
modprobe -q mptspi
modprobe scsi_wait_scan
rmmod scsi_wait_scan
mkblkdevs
resume /dev/sda2
echo "Creating root device"
mkrootdev -t ext3 -o loop,ro /rootfs.img 
echo "Mounting root filesystem"
mount -t ext3 /sysroot
echo Setting up other filesystems.
setuproot
echo Switching to new root and running init.
switchroot
echo Booting has failed.
sleep -1

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux