- Fixed a problem with chrooting into read only squashfs system
- Fixed a problem with resolving DNS names
I've rented recently a dedicated hosts. It's preinstalled OS was Fedora. I decided to install gentoo, as that's my preferred choice since few years now.
Because strange Orange policy – they are blocking Samba (Windows) shares to the outside world – I couldn't mount a Gentoo mini CD installation disk on the dedicated server.
I made several approaches to mount a USB floppy disk which nadn't have such requirements (it's enough to just upload an image to the remote control management software), but I failed for many reasons. Hal91 couldn't mount ext3 partitions, some other couldn't work from USB, no distro could recognize installed network card… fail after fail.
Meanwhile one idea came to my mind: „maybe it would be possible to extract CD ISO and mount it as a drive?“. Unfortunately I couldn't login as root into such prepared system, but it opened the door to another, cleaner solution. Instead of booting from the extracted CD I decided to chroot into it. The rest was eas – follow the Gentoo Handbook.
Here is how I did it step by step:
I needed some space. As there were all partitions used I decided to move all Fedora into one. I've copied all /var and /home (which were placed on other than ‚/‘ partition) to /xvar and /xhome, removed their entries in /etc/fstab, restarted server and switched it to single mode (easy with grub – just hit ‚e‘ to edit entries and change add word ‚single‘ on the end of the line calling the kernel). Then I removed empty /var and /home, renamed /xvar to /var, /xhome to /home and rebooted again. All Fedora was on one partition. The rest is free for my gentoo system.
To copy the /var and /home it's better to use --preserve parameter
cp -pr /var /xvar cp -pr /home /xhome
after reboot to single mode:
rm -r /var /home mv /xvar /var mv /xhome /home
reboot again – should work fine.
I have gentoo minimal ISO image in the root's home directory.
mkdir mini mount -t iso9660 -o loop install-x86-minimal-2006.1.iso mini
Inside the mini dir exists a file called image.squashfs. That's the real system installed on the CD. We have to copy it's content to the filesystem and umount loop filesystems.
mkdir squash_fs mount -t squashfs -o loop mini/image.squashfs squash_fs mkdir squash cp -rp squash_fs/* squash/ umount squash_fs umount mini rm -r squash_fs rm -r mini
Copy resolv.conf from Fedora to gentoo:
cp /etc/resolv.conf squash/etc/
Now there is a need to chroot into the copied system:
mount -t proc none squash/proc mount -o bind /dev squash/dev chroot squash env-update.sh source /etc/profile
Here we have a system almost the same as if we would boot from the CDROM burned from mini CD ISO image.
Go into your Gentoo Handbook written for you distribution (in my case x86 ) and follow the steps until Booting the Grub installation and/or configuration process begins.
Instead of following the steps from the handbook do the following:
Go out from the chrooted environment (Ctrl-D,Ctrl-D) and umount the disks:
umount squash/mnt/gentoo/proc/ umount squash/mnt/gentoo/dev/ umount squash/mnt/gentoo umount squash/proc umount squash/dev
Now edit Grub menu file:
and add new entry for Gentoo:
title Gentoo root (hd0,1) kernel /boot/vmlinuz ro root=/dev/hda2
Reboot and be happy. Digg the story