-
Senior Member
registered user
[HOWTO] How to boot a chroot directory ...
This is actuaqlly a copy of a mail I sent to debian-knoppix earlier this day ...
I hope this is interesting for some of you:
---
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
...
Similar Threads
-
By astranberg in forum Hardware & Booting
Replies: 1
Last Post: 05-10-2005, 04:15 AM
-
By A. Jorge Garcia in forum General Support
Replies: 4
Last Post: 05-08-2004, 01:35 PM
-
By kevinonknoppix in forum Customising & Remastering
Replies: 0
Last Post: 02-24-2004, 08:45 AM
-
By bongski55 in forum Customising & Remastering
Replies: 3
Last Post: 06-21-2003, 11:16 AM
-
By babo in forum Customising & Remastering
Replies: 0
Last Post: 03-06-2003, 03:40 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

USB 3.0 Flash Drive 32GB 64GB 128GB Memory Stick Thumb Stick Lot Pack
$164.99

SanDisk Ultra Luxe USB 3.1 Flash Drive – 5 Pack | Premium Metal USB Flash Drives
$59.99

Microsoft Windows 11 Pro 64bit - New Sealed – Flash USB 1 PC
$49.99

Windows 11 Pro Install/Recovery/Repair USB Flash Drive
$35.00

Sandisk 16GB 32GB 64GB 128GB Cruzer Blade Flash Drive Memory Stick USB Lot Pack
$175.90

Sandisk Flash Drive 16GB 32GB 64GB 128GB 256GB 512GB Blade Glide Ultra Flair lot
$623.38

Kingston 32GB 64GB 128GB 256GB USB 3.0 Flash Drive Thumb Memory Stick Pen lot
$135.90

Sandisk 32GB 64GB 128GB 256GB Cruzer Glide Flash Drive USB 2.0 Memory Lot
$404.42

Wholesale 5/10/100PCS 1GB 2GB 4GB 8GB 16GB 32GB USB 2.0 Flash Drive Memory Stick
$378.00

Tesla 128gb usb flash drive 3.1
$15.99