initrd help -- umounts root after pivot_root

From: John R Moser (jmoser5_at_student.ccbc.cc.md.us)
Date: 10/31/03

  • Next message: sankar: "Question on mips-linux xross compilation"
    Date:	Thu, 30 Oct 2003 19:18:39 -0500 (EST)
    To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
    
    

    Been trying with 2.4.20, 2.4.22, 2.6.0-test9, how the heck do I get this
    to work?

    I set everthing up on /dev/shm type tmpfs, then
    cd /dev/shm
    mkdir initrd
    pivot_root . initrd

    So yay, it's set up so that the cd is pointed to by a lotta links in
    tmpfs, and the stuff that needs to be rw (like /etc) is on the tmpfs.

    That's good.

    Of course, the kernel unmounts / and then swears that it can't find init
    when the linuxrc exits.

    The documentation says that linuxrc should pivot_root to the real root in
    Documentation/initrd.txt so I thought that's what the script sholud do.
    Apparently the doc is bad/old.

    Any ideas?

    script follows.

    ====/linuxrc
    #!/bin/sh
                                                                                                                                    
    # linuxrc for Genoppix initrd
    # Basicly mounts the cdrom, sets up rw stuff, spins the root image
    # around to the root, and exits.
    echo "Genoppix Initrd Loaded, linuxrc executing in 5 seconds..."
    sleep 5
    mount none -t proc /proc
    echo "Mounting cdrom..."
    CDROM="/dev/cdrom"
    if [ ! -e $CDROM ]; then
      CDROM="/dev/cdroms/cdrom0"
    fi
    mount $CDROM /mnt/root || (echo "FATAL: Cannot mount cdrom!" && sh)
    echo "mounting tmpfs..."
    mount none -t tmpfs /dev/shm || (echo "FATAL: Cannot mount tmpfs!" && sh)
    echo "Building symlinks to cd root..."
    cd /dev/shm
    ln -s /mnt/root/* .
    sleep 2.5
    echo "Setting mnt and home to rw root..."
    rm -f root home mnt
    mkdir root home mnt
    #echo "linking cdroot's new location to what will be cdroot's old
    location..."
    #ln -s /mnt/initrd/mnt/root /dev/shm/mnt/root
    echo "mounting cdrom at new root..."
    mount $CDROM /dev/shm/mnt/root
    echo "Pivoting root to shared memory filesystem..."
    cd /dev/shm
    mkdir initrd
    pivot_root . initrd || (echo "Cannot pivot root!" && sh)
    mount -t proc none /proc
    echo "copying /etc to a rw /etc..."
    rm -f etc
    mount -t devfs none /dev
    cp -R /mnt/root/etc .
    echo "Root pivoted, making users..."
    sleep 1
    echo "creating homes for default users..."
    cd /home
    mkdir jak
    mkdir tails
    mkdir fox
    mkdir krystal
    chgrp users *
    chown jak jak
    chown tails tails
    chown fox fox
    chown tails tails
    chown krystal krystal
    echo "exiting linuxrc and starting init ;)

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: sankar: "Question on mips-linux xross compilation"

    Relevant Pages

    • nfsroot over PCMCIA: pivot_root lockup
      ... to sort-of single-step the linuxrc contained in the initrd. ... However, now I cd to /mnt/nfsroot, mkdir initrd, and pivot_root. ... echo 'Starting PCMCIA'>/dev/console ... insmod $PC/pcmcia_core.o $CORE_OPTS ...
      (comp.os.linux.portable)
    • Re: FORTH levels
      ... cat, mkdir, rm, mv, echo they have. ... Albert van der Horst, UTRECHT,THE NETHERLANDS ...
      (comp.lang.forth)
    • Re: FORTH levels
      ... cat, mkdir, rm, mv, echo they have. ... swapoff swapon sync sysctl tail tar tee telnet telnetd test todos ...
      (comp.lang.forth)
    • Re: Identical servers + kernel configs -> different initrds?
      ... After uncompressing the two initrd's, and doing a diff -r on them, I ... vis/ dir has the small initrd uncompressed. ... < echo "Loading libata.ko module" ... < insmod /lib/libata.ko ...
      (comp.os.linux.setup)
    • mkinitrd problems
      ... This failure MAY indicate that your kernel will not boot! ... echo pcspkr ... mkdir initrd ... xldd /sbin/modprobe ...
      (Debian-User)