# # # linuxrc.Commands.Help.txt # # # # 02-Nov-04 amo Create a minimal initrd.gz to load the rootfs.gz as / # 13-Nov-04 amo Split off ramdisk options into linuxrc.Commands.Help.txt # # # ============= # # # # NOTE # # # ============= # - you cannot manually invoke /sbin/init from a command line # # - if you do, you will get the following error message: # "error opening/writing control channel /dev/initctl" # # # # For Normal ramdisk/rootfs setup # -------------------------------- # lilo: linux-2.4.27 - will call /sbin/init when linuxrc is done # # # "man initrd" says to unmount everything before existing linuxrc # but we're still using/needing /mnt/hda/rootfs # # # Upon exiting /linuxrc, normal /sbin/init will be invoked # and /dev/ram0 will have been previously moved to /initrd # # # For Manual ramdisk/rootfs setup # ------------------------------- # # # # # this root=/dev/ram0 will execute linuxrc ( sorta useless to just specify root= ) # # # lilo: linux-2.4.27 root=/dev/ram0 # # # # # # these root= and init= will NOT execute linuxrc # # modify linuxrc to call linuxrc.loop or /bin/bash as desired first # # # lilo: linux-2.4.27 root=/dev/ram0 init=/bin/bash # ( check and run linuxrc.bash.txt if you don't want to type ) # # # # mount /proc # # # mount -t proc none /proc # # # # # make it rw if we want to edit /linuxrc or anything else # # # mount -n -o rw,remount /dev/ram0 / # # # # # run /linuxrc as if it was executed normally # # # sh /linuxrc # # # # # change into the rootFS # # # chroot /mnt/loop /bin/bash # # # We're in the rootFS # -------------------- # # # # run the /linuxrc.loop commands in lieu of /sbin/init # # # sh /linuxrc.loop # # # colorize the screen # sh /root/.alias # # # # # create some ramdisks # # # sh /root/ramdisks.sh # # # # # invoke normal single user # # # cd /etc/rc.d ; ./rc.S # # # # # invoke normal multi-user # # # cd /etc/rc.d ; ./rc.M # # # ping the work as normal # route -nv # ping yahooc.om # # # # # install a firewall # # # cd /etc/rc.d ; ./rc.iptables # # # Other Commands useful in ramdisks # --------------------------------- # # # # to Mount a Loop Device # # # mount -o loop filename /dev/loop0 # # # # # to change / for testing linuxrc.loop or rootfs # # # chroot /mnt/loop0 / # # # # ------------------------------------- # "chroot /mnt/loop0 exec /sbin/init 1" # "chroot /mnt/loop0 /sbin/init 3" # ------------------------------------- # # init also expects a run level # # a shell ( including /linuxrc ) CANNOT call init --> causes error message: # # ======================================================= # # # # "error opening/writing control channel /dev/initctl" # # # ======================================================= # # # pivot_root # ------------- # ======================================================= # # # # "device or resource busy" # # # ======================================================= # # # To View the RootFS # ------------------- # mount /dev/hda1 /mnt/hda # losetup /dev/loop0 /mnt/hda/boot/rootfs # mount -o loop,rw /dev/loop0 /mnt/loop0 # # # Which Shells # ------------ # http://www.busybox.net # http://www.ibiblio.org/pub/Linux/system/shells/ # # # # Release the memory after we're done # ------------------------------------ # freeram # blockdev --flushbufs /dev/ram0 # # ================================================================ # # Which is the roofs it will boot # ------------------------------- # rdev /boot/vmlinuz-2.4.27 # # Set the rootfs on the kernel to user /dev/loop0 # ------------------------------------------------ # rdev /boot/vmlinuz-2.4.27 /dev/loop0 # # more whacky options # -------------------- # rdev -R /dev/fd0 0 # ?? - or - ?? # rdev -r /dev/fd0 0 # # rdev /dev/fd0 /dev/fd0 # rdev -R /dev/fd0 49552 # rdev -r /dev/fd0 49552 # # ================================================================ # # Loop Devices # -------------- # # 0100 /dev/ram0 # 0700 /dev/loop0 # 0301 /dev/ram1 # # echo "0x700" > /proc/sys/kernel/real_root_dev # # # http://webpages.charter.net/decibelshelp/LinuxHelp4_PartImage.html # rdev vmlinuz /dev/fd0 # rdev -r vmlinuz 49152 # rdev -R vmlinuz 0 # # http://www.linuxfromscratch.org/blfs/view/cvs/postlfs/config.html # # # # Join rescueimage and initrd onto a diskette # # # dd if=rescueimage of=/dev/floppy/0 bs=1k # rdev /dev/floppy/0 0,0 # rdev -R /dev/floppy/0 0 # # rdev -r /dev/floppy/0 16865 # 16865 = 481 + 16,384 ( ie 2**14) # # dd if=/tmp/rootfs.gz of=/dev/fd0 bs=1k seek=481 # 481 is dd's output +1 # # ================================================================ # # # From man initrd # --------------- # "man initrd" says to unmount everything before existing linuxrc # but we're still using/needing /mnt/hda/rootfs # # # # unmount the compact flash # umount /mnt/CF # # # # leave /proc, since echo fails # umount /proc # # # Upon exiting /linuxrc, normal /sbin/init will be invoked # and /dev/ram0 will have been previously moved to /initrd # # # except in our /dev/loop case, / cannot be mounted since # /dev/loop0 does not yet exist in the real rootFS, so we # will use linuxrc.loop instead # # # ================================================================ # # What causes: # ------------ # pivot_root: device or resource busy # # ---------------------- # # pivot_root /mnt/loop0 /initrd # chroot /mnt/loop0 /sbin/init 3 # # cd /mnt/loop0 && pivot_root . /initrd # # # dumps you into /mnt/loop0 and does not execute /sbin/init # docmd "exec chroot . " # # # # - # - pivot_root is needed for chroot + init to work # - # # http://www.sdc.org/~leila/usb-dongle/usb-filesystem/linuxrc # # cd /mnt/loop0 # /sbin/pivot_root . /initrd # exec /usr/bin/chroot . /sbin/init 3 # exec chroot . /sbin/init < dev/console 2>&1 # # # # To manually see what's going on rootFS # -------------------------------------- # # chroot /mnt/loop0 /bin/bash # chroot /mnt/loop0 /linuxrc.loop # # # a shell ( including /linuxrc ) CANNOT call init --> causes error message: # "error opening/writing control channel /dev/initctl" # # # chroot /mnt/loop0 /sbin/init 1 # # # # # End of file