created : 2010-02-01 updated : 2010-02-01
In the last section, we have created a lfs.vdi which is bootable. But it is not a standalone system yet, because we still have to rely on the grub utility installed in the Virtual Ubuntu.
This section describe how to make lfs.vdi a standalone bootable virtual disk. After that a new virtual machine can be created using this virtual disk image.
First make a new disk image for our blfs partition (this will be the standalone bootable disk)
cp lfs.vdi blfs.vdi It was a mistake that I didn't use VBoxManage clonevdi, now lfs and blfs have the same uuid, so I must assign a new uuid to blfs.
VBoxManage internalcommands setvdiuuid blfs.vdi Then attach blfs.vdi to the Ubuntu Virtual machine. After booting, /dev/sda will be the Ubuntu partition, /dev/sdb will be the blfs partition.
Now enter the chroot environment, so that /dev/sdb1 will become /
export LFS=/mnt/lfs mount /dev/sdb1 $LFS mount -v --bind /dev $LFS/dev mount -vt devpts devpts $LFS/dev/pts mount -vt tmpfs shm $LFS/dev/shm mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys chroot "$LFS" /tools/bin/env -i \ HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ /tools/bin/bash --login +h Now configure GRUB, note that the configuration here is not the same as those in section 8, "Boot LFS".
Enter the grub shell
grub GRUB uses its own naming structure for drives and partitions in the form of (hdn,m), where n is the hard drive number and m is the partition number, both starting from zero. For example, partition hda1 is (hd0,0) to GRUB and hdb3 is (hd1,2). Tell GRUB where to search for its stage{1,2} files. The Tab key can be used everywhere to make GRUB show the alternatives: root (hd1,0) Tell GRUB to install itself into the MBR of the BLFS disk (noted, do that on hd1 only, don't do that on hd0, which is the Ubuntu disk) setup (hd1) If all went well, GRUB will have reported finding its files in /boot/grub. That's all there is to it. Quit the grub shell: quit Create a “menu list” file defining GRUB's boot menu: cat > /boot/grub/menu.lst << "EOF" # Begin /boot/grub/menu.lst # By default boot the first menu entry. default 0 # Allow 30 seconds before booting the default. timeout 30 # Use prettier colors. color green/black light-green/black # The first entry is for LFS. title LFS 6.5 root (hd0 ,0) kernel /boot/lfskernel-2.6.30.2 root=/dev/sda 1 EOF Noted that we used hd0 here, because once you create a new virtual maching using blfs.vdi. That machine would have only one virtual disk image.
/etc/fstab
cat > /etc/fstab << "EOF" # Begin /etc/fstab # file system mount-point type options dump fsck # order /dev/s da 1 / ext3 defaults 1 1 #/dev/sda5 swap swap pri=1 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 devpts /dev/pts devpts gid=4,mode=620 0 0 tmpfs /dev/shm tmpfs defaults 0 0 # End /etc/fstab EOF Because a new virtual machine would have a new MAC address. The kernel would create a eth1 interface instead of using the old eth, so add configuration file for eth1
cd /etc/sysconfig/network-devices mkdir -v ifconfig.eth1 cat > ifconfig.eth1/ipv4 << "EOF" ONBOOT=yes SERVICE=ipv4-static IP=192.168.1.101 GATEWAY=192.168.1.1 PREFIX=24 BROADCAST=192.168.1.255 EOF How did I know it was using eth1 ? Boot BLFS, then issue the following command :
ls /sys/class/net End |
1. LFS >