Debian Debootstrap HowTo, Review

by Mike Levin SEO & Datamaster, 08/24/2010

Okay, it’s been a long time since I did updates at ShankServer.org, and the pressure is really on me now, since my 2 SheevaPlugs arrived from Globalscale last week–the main event at this site–real hardware–real… shank… servers! Forget these little virtual Linux keychain novelties. Who needs them, when you can have a Linux server running out of your living room behind your WiFi box, taking only 5 watts of power and serving as an efficient footprint model for massive scaling in the cloud.

But first, I really have to finish out the bare minimum basics to make these virtual Linux keychain drives a useful lesson and basis for other projects, and that means finishing the sudo step, creating a new promotable user, and deactivating the root account. Unfortunately, I lost all my momentum, and in the time in between, I have come to doubt the preciseness of some of my steps (copying the Linux kernel). So in order to rebuild my momentum and confidence in my steps, I’m re-bootstrapping a new system to test my instructions. I will use this page as a sort of summary / recap of the prior steps that spanned many pages.

I’m doing this in-position with my Windows/Mac multi-boot ShankServer directory. It turns out that absolutely the only thing that goes bad is the harddisk.raw file, and since I’m redoing it, I’m giving myself 100 extra MB on the main partition, enough to get MySQL onto it when I have to. I can see already that I’m going to want to put a full WordPress install into these things–if only to test installing WordPress, and I really don’t want to run out of room by 100MB! It will still fit fine on a CD-ROM or a 1GB USB drive with plenty of space left over for utilities. I already went over the limit for 500MB USB drives, but you can hardly find those these days anyway.

Okay, so I basically delete harddisk.raw from:

ShankServerDebian.appContentsResourcesGuestDebian.qvm

…and then I put the knoppix.iso file into that directory, and start following my own instructions, but with a new path ../Guest/Debian.qvm/ inserted before every drive image location. So, I open a CMD window and make a new hard drive file:

qemu-img create -f raw ../Guest/Debian.qvm/harddrive.raw 600MB

…and then I boot the system:

qemu -hda ../Guest/Debian/qvm/harddrive.raw -cdrom ../Guest/Debian/qvm/knoppix.iso

…and then I pick 10 to get the Shell, and use fdisk to partition the drives. The instructions are perfect: http://shankserver.org/2010/07/how-to-partition-format-hard-drive/

…and then I format the drives:

mkfs.ext3 -L HOME /dev/sda1 mkswap -L SWAP /dev/sda2

…and then I mount sda1:

mount /dev/sda1 /mnt/sda1

…and then I debootstrap it:

debootstrap –arch i386 squeeze /mnt/sda1 http://ftp.us.debian.org/debian

…now, I chroot over to the new location and apt-get update and install lilo:

chroot /mnt/sda1 apt-get update apt-get install lilo Y

Okay, so far, so good. And now we copy the Linux kernel and it’s modules:

cp /boot/vmlinuz* /mnt/sda1/boot/ cp /boot/System.map* /mnt/sda1/boot/ cp -R /lib/modules/* /mnt/sda1/lib/modules/

And now we bind the proc and dev locations to the new hard drive, and chroot back in:

mount -o bind /proc /mnt/sda1/proc mount -o bind /dev /mnt/sda1/dev chroot /mnt/sda1

And then configure the lilo.conf file:

nano /etc/lilo.conf boot=/dev/sda root=/dev/sda1 image=/boot/vmlinuz-2.6.32.6 label=Linux Ctrl+o [Enter] Ctrl+x

…and now run lilo:

lilo -v -v

…and now edit the fstab file:

vi /etc/fstab o proc /proc proc defaults 0 0 /dev/sda1 /boot ext3 defaults 0 0 /dev/sda2 none swap sw 0 0 [Esc] :wq

Now, give root a password, so you can get in after a reboot:

passwd

Okay, let’s set up networking:

vi /etc/network/interfaces

[Down arrow] o auto eth0 iface eth0 inet dhcp [Esc] :wq

…now type exit to un-chroot, and delete a pesky directory:

exit rm -rf /mnt/sda1/dev/.udev/

And now, change the hostname. This change won’t take effect until after the next reboot:

echo ‘ShankServer’ > /etc/hostname

And now we’re fully debootstrapped! The system should be fully bootable, but we don’t want to do a restart because we don’t want Knoppix rebooting, so we do a hard shutdown:

shutdown -h now

…and now you can test with this command whether you’ve done it all correctly:

qemu -hda ../Guest/Debian.qvm/harddrive.raw

If you are still seeing messages about the .udev directory, then reboot with Knoppix, mount /dev/sda1 and do the rm -rf /mnt/sda1/dev/.udev/ command again.

If you’ve got it right, a whole bunch of grey text will scroll by. device or filesystem errors will be reported. If you reach that point, immediately shut down and copy off your harddrive.raw file. It’s a great asset.

Pshew! Okay, now back to security.