Debootstrap install
Contents |
intro
debootstrap is a program that is used internnally by the debian/ubuntu installers to create a base system. it is a handy tool to do stripped down system installs or installs from a running system, for example if you have a running linux box and you want another you just hook up your other hard drive to it via usb and load the os and there you go. this is how you can bend it to your will.
get debootstrap
it should be in the main repository so you shouldn't have to edit your sources.list at all. justhost$ apt-get install debootstrap
note: most if not all commands need to be run with root priviledges, so either sudo all of them or just switch to root now (host$ sudo su -).
mountpoint
you need to select a mountpoint that you are going to use. i use /target for convenience. if you see $target in this howto, just replace with the path to whatever mountpoint you will be using. you need to make sure it exists.
host$ mkdir $target
partition/mkfs
IMPORTANT: you need to be absolutely sure you know what the devnode for your target disk is or risk losing everything. much safer to practice from a livecd on a system you dont care about.
host$ cfdisk -z /dev/[target disk]
create one partition for your root filesystem and one for your swap partition. i usually use a swap partition of 1 gig. you can look around the internet for different opinions and guidelines about it.
you need to mkfs the root filesystem.
host$ mkfs.ext4 /dev/[target disk]1
and mkswap your swap partition and turn it on
host$ mkswap /dev/[target disk]2 host$ swapon /dev/[target disk]2
note: if, after you partition your disk you get any problem mkswap and swapon, reboot. your partition table probably needs to be re-read. then redo the mkfs and mkswap. if you use a improperly setup fs, your work will be lost next boot. if you're on a livecd, repeat steps 1 and 2.
if those steps were good, go ahead and mount your target root filesystem on $target
host$ mount /dev/[target disk]1 $target
debootstrap
this is the minimum you should start with.
host$ debootstrap --include ubuntu-minimal,grub,linux-generic karmic $target
you need these to set up wireless generally speaking
wireless-tools wpa-supplicant
you may also want these so your system is more friendly/useful. you can wait to install these in the chroot step or after booting the new system if you want.
vim screen sudo language-pack-en gpm(i dont usually use a mouse in text mode, but i wont stop you) mc man
configure system
network interface configuration
you will want generally to have lo set for loopback and eth0 set for dhcp. i wont go into making wireless automagic from startup here, there are other resources on the net.
your $target/etc/network/interfaces file should contain these lines
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp
hostname by default is either ubuntu or whatever your host's hostname is
change the hostname on the 127.0.0.1 line in $target/etc/hosts
change $target/etc/hostname
chroot
you need to execute some things inside the target system. for this you will use chroot to enter. use host$chroot $target /bin/bash. from now on anything prefixed with chroot$ needs to be done in this chroot. it is very helpful if you are using multiple xterm to change the prompt in your chroot to make it clear where you are entering commands. try
chroot$ export PS1=chroot-$PS1
install grub
set up dev, proc and fake mtab
host$ mount -o bind /dev $target/dev host$ mount -t proc proc $target/procyou need a $target/etc/mtab to placate grub-install. it needs to contain the line /dev/[target disk] /boot [target filesystem] rw 0 0. ex:
chroot$ echo /dev/[target disk]1 /boot ext4 rw 0 0 > /etc/mtab
install-grub
you need to run install-grub in the target chroot and give an argument of where to install. you can use a devnode, but i prefer to use grub notation. (hdx,y) where x is the number, counting from zero, of the disk you want and y is the partition on that disk you want to install to. if you just specify a disk, ex (hd0), it will install to the mbr instead of a particular superblock.
chroot$ install-grub "(hd1)" chroot$ update-grub
make sure $target/boot/grub/menu.lst is accurate. you should look for references to hda1 and change them to sda1 probably.
user setup
set root password - this is important. if you dont have a password set, you will not have a blank password, you will have no password and consequently will not be able to login
chroot$ passwd
you may want to setup a non-root user as is good security practice
chroot$ adduser newuser(or whatever username)
then you should add it to sudo and audio
chroot$ gpasswd -a newuser audio chroot$ gpasswd -a newuser sudo
setup sudo
chroot$ visudothen add a line that says
%sudo ALL=(ALL) ALL
boot new system
reboot your system without the livecd if you're using a livecd or boot your target disk on your new system if you are doing it that way.
now you can add more software like ubuntu-desktop or xorg and fluxbox and firefox or whatever your heart desires. i just use fluxbox firefox and xorg and nodm on lightweight systems. nodm can be a security risk since it automatically logs on. maybe use wdm if you need a real logon.
new-system$ apt-get update new-system$ apt-get install xchatto get xchat so you can goto #shellium