create a minimal ubuntu/debian system via debootstrap
this is a procedure I find useful for creating bootable ubuntu systems on usb drive. The howto assumes that debootstrap and chroot are already installed and that the usb drive is ready for being used (partitioned and formatted, a single ext3 partition flagged as “boot” made with gparted will do the job)
create the minimal system
sudo mkdir /tmp/blah sudo debootstrap maverick /tmp/blah/
copy it to the (usb) folder where you want to create your new system (suppose it is mounted in /mnt), preserving file attributes
sudo cp -ap /tmp/blah /mnt
chroot into it
cd /mnt sudo mount -t proc none proc/ sudo mount --bind /dev dev/ sudo mount --bind /dev/pts/ dev/pts sudo LC_ALL=C chroot . /bin/bash
edit fstab, make sure that XXX corresponds to the uuid of the partition ”/” on the usb drive (can be found in gparted)
# file system mount point type options dump pass proc /proc proc defaults 0 0 UUID=XXX / ext3 defaults 0 1
hostname (substitute “Hostname” with the actual name you want)
echo Hostname > /etc/hostname echo -e "127.0.0.1\tlocalhost.localdomain\tHostname" > /etc/hosts
kernel, grub
install linux-image and while configuring grub, skip the installing part. We will do it manually later
apt-get install linux-image
exit chroot (type “exit”) and install grub
grub-install --root-directory=/mnt /dev/sdX
where sdX is the device that corresponds to the usb stick (something like sdc)
While you are there, you might also find useful to add an admin (this can be also done later one when the usb stick is booted)
users, admin, sudo
chroot again, add one user to be made administrator
adduser matteo addgroup admin addgroup matteo admin visudo
Add the following at the very end:
%admin ALL=(ALL) ALL
If you get a “sudo: must be setuid root” when using sudo, use
chmod 4111 /usr/bin/sudo
booting
Now you can reboot, make sure you select to boot from usb from your boot menu, grub will start but it is not configured, therefore you need to tell him what he has to do
root (hd0,1) linux /vmlinuz root=/dev/sdb1 ro single initrd /initrd.img boot
by issuing the root command, you will be able to use the tab function to get autocompletion, therefore you can type “linux /<TAB>” to list what is it available. This is a nice trick to make sure you selected the right drive. Instead of using the device of the usb stick, you can use the same UUID that you inserted in fstab with root=UUID=XXX.
after the system is booted, run again “update-grub” it will create grub configuration file with everything in place
installing
Now you have a bare minimum system, you may want to issue a “dhclient eth0” in order to connect to your router, “apt-get update” and start apt-get something.
dpkg-reconfigure console-setup #if you need to setup a different keyboard
In order to get a full ubuntu system
apt-get install ubuntu-dekstop
eventually add ”–no-install-recommends”