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

Re: [debian-knoppix] [HOWTO] How to boot a chroot directory ...



Great news I really like this idea thank you very much:)

Zau Mikko 

On Friday 04 July 2003 22:04, Fabian Franz wrote:
> Hi,
>
> in my last mail I said, that there are problems with chroot, that you are
> not able to unmount or remount ...
>
> I also had an idea, and this idea did work ...
>
> What you need:
>
> - Linux partition
> - Lilo (Grub could also be possible)
>
> Create an ext2-image with 2560000 bytes. (Should be enough).
>
> Mount it to /mnt.
>
> -rwxr-xr-x    1 root     root       150580 2002-07-26 14:09 /mnt/static/ash
> lrwxrwxrwx    1 root     root            3 2003-04-01 23:46
> /mnt/static/init -> ash
> lrwxrwxrwx    1 root     root            3 2003-04-01 23:46 /mnt/static/sh
> -> ash
>
> Copy ash to /mnt/static and create symlinks ...
>
> Copy needed modules (for ext3 that are jbd.o and ext3.o) to /mnt/modules
>
> -rw-r--r--    1 root     root        87626 2003-04-01 23:46
> /mnt/modules/ext3.o
> -rw-r--r--    1 root     root        74090 2003-04-01 23:46
> /mnt/modules/jbd.o
>
> Copy device that needs to be mounted to /mnt/dev (or copy whole /dev)
>
> cp libraries for non-static binaries ("real" mount/pivot_root are needed)
>
> -rwxr-xr-x    1 root     root        82456 2003-05-07 09:27
> /mnt/lib/ld-linux.so.2
> -rwxr-xr-x    1 root     root      1104072 2003-05-07 09:27
> /mnt/lib/libc.so.6
>
> mkdir -p /mnt/mnt /mnt/mnt2 /mnt/proc
>
> copy mount and pivot_root to /bin:
>
>
> -rwsr-xr-x    1 root     root        81080 2003-05-07 09:27 /mnt/bin/mount
> -rwsr-xr-x    1 root     root          4832 2003-05-07 09:27
> /mnt/bin/pivot_root
>
> Last but not least create the /mnt/linuxrc the heart of our operation :-))
>
> #!/static/sh
>
> # load needed modules
> insmod /modules/jbd.o
> insmod /modules/ext3.o
>
> # mount proc, say that root is pivot_rooted and unmount it
> mount -t proc proc /proc
> echo 256 > /proc/sys/kernel/real-root-dev
> umount /proc
>
> # mount the root-filesystem
> mount -t ext3 /dev/hda5 /mnt
>
> # tricky: We now bind our chroot environment to /mnt2
> /bin/mount --bind /mnt/home/knoppix/newroot /mnt2
>
> # now we unmount the root-filesystem; believe me, its possible and /mnt2 is
> still there
> umount /mnt
>
> # Now we change the root permanently to the chroot-dir and we can do every
> operation that is needed (remount, unmount, ...)
>
> /bin/pivot_root /mnt2 /mnt2/initrd
>
> Of course you can sue the comments and just have the script so compact :
>
> #!/static/sh
> insmod /modules/jbd.o
> insmod /modules/ext3.o
> mount -t proc proc /proc
> echo 256 > /proc/sys/kernel/real-root-dev
> umount /proc
> mount -t ext3 /dev/hda5 /mnt
> /bin/mount --bind /mnt/home/knoppix/newroot /mnt2
> umount /mnt
> /bin/pivot_root /mnt2 /mnt2/initrd
>
> I tried this and it did work ... I was really suprised, but I think its an
> kind of easy way to test several copied knoppix systems or bootstrapped and
> then knoppised debian's :-)).
>
> If anyone knows an easier way, I'm interested to learn it :-) (Or if anyone
> knows this way from another source on the web ...)
>
> btw. lilo.conf:
>
> image=/boot/vmlinuz-2.4.20-xfs
>         label=Chroot
>         append="hda=scsi hdb=scsi hdc=scsi hdd=scsi hde=scsi hdf=scsi
> hdg=scsi hdh=scsi apm=power-off nomce ramdisk_size=100000 lang=de
> init=/etc/init" initrd=/boot/chroot_initrd
>         read-only
>
> I think it would be possible to also have all this pointing to
> /home/knoppix/newroot/vmlinuz|boot/chroot_initrd ...
>
> But as I had the same kernel, I'm lazy ... :-))
>
> cu
>
> Fabian
>
> PS: I hope this is useful to someone ...
> PPS: So you can finally start your changed system and such USE sortlists
> and so optimise the system more and more without the need of an
> extra-partition ...
> _______________________________________________
> debian-knoppix mailing list
> debian-knoppix@linuxtag.org
> http://mailman.linuxtag.org/mailman/listinfo/debian-knoppix

-- 




_______________________________________________
debian-knoppix mailing list
debian-knoppix@linuxtag.org
http://mailman.linuxtag.org/mailman/listinfo/debian-knoppix


Reply to: