Visit our website:
www.linutop.com


Tutorials/Debootstrap

From LinutopWiki

Contents

Build a custom debian/ubuntu based system for your Linutop

The OS provided with your Linutop is a LiveCD-like system, which means that you can't modify it easily. But you can easily create your own Linux system. All you need is a working installed debian/ubuntu system, and a minimal knowledge about how to use it (mainly how to install packages).

For this tutorial, we will create a minimal Ubuntu Hardy system, using the system as host.

Preparing

The first thing to do is to create partitions on the USB stick/Hard drive on which you want to install your system. There's no pre-defined rule for this, you'll have to partition your disk so that it fits your needs.

To partition your disk, use your favourite partition software (parted, qtparted, gparted, partition magic...). In our example we will use a single partition for the entire system, plus a swap partition.

Once your partitions are set up, mount the future root partition on your running debian/ubuntu system:

$ CHROOT=/media/usb
$ sudo mkdir $CHROOT
$ sudo mount /dev/sda1 $CHROOT # change /dev/sda1 to the device you'll use

We can now create the minimal system using debootstrap:

$ sudo apt-get install debootstrap
$ sudo debootstrap hardy $CHROOT

Debootstrap will now download and install a minimal but usable system on your disk. Let's prepare some tea now...

Making the new system bootable

You can now use the system by chrooting in it:

$ sudo chroot $CHROOT
$ cat /etc/lsb-release # we are in the new system
$ exit

But you can't boot this system because:

  • There's no kernel to boot (chroot uses your host system kernel)
  • There's no boot loader (such as grub or lilo)

Setting up apt

Let's update the chroot sources.list:

$ sudo vim $CHROOT/etc/apt/sources.list # use your favorite text editor instead of vim

Modify the file to have:

deb http://archive.ubuntu.com/ubuntu hardy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu hardy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu hardy-security main restricted universe multiverse

Now in the chroot:

# apt-get update # we are root in the chroot, no need to use sudo
# apt-get dist-upgrade # to get the updates installed

If the system asks you question and you don't know what to do, just use the default answers.

Installing a kernel and a boot loader

We still are in the chroot:

# apt-get install linux-headers-generic linux-restricted-modules-generic linux-restricted-modules-generic 
# apt-get install linux-image-generic

Now we install grub:

# apt-get install grub
# mkdir /boot/grub
# update-grub
# vim /boot/grub/menu.lst

Edit the two entries at the bottom of /boot/grub/menu.lst; you only need to replace /dev/hda1 with /dev/sda1. The entries will look something look like this:

timeout 10
title           Ubuntu, kernel 2.6.17-11-generic
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.17-11-generic root=/dev/sda1 ro quiet
initrd          /boot/initrd.img-2.6.17-11-generic
quiet
savedefault

We'll install the boot record outside of the chroot:

# exit

Now install grub on the MBR:

$ sudo grub-install --root-directory=$CHROOT --no-floppy --recheck /dev/sdb # modify /dev/sdb to use your device

Now umount your disk:

# sudo umount $CHROOT

Linutop2 and Ubuntu Hardy

The Linutop2 has internally 1GB of flash. It may be that your USB-key is used to boot, but during the "initramfs" phase the Linutop2 flash is mounted and you get an error about /sbin/init not existing.

Tricky because we see that /dev contains entries for sda but not for sdb and the directory /root/ looks nothing like what's on your USB key (it's actually the image on the 1GB Linutop2 Flash).

The most reliable way (tested on Hardy 8.04.1 as the USB key image) is to label the USB key (with e2label) and modify grub's menu.lst file to boot from a labelled partition.

  1. Label the USB key. Assume it's mounted on your build environment as /dev/sdb1
  2. # e2label /dev/sdb1 mylinukey
    
  3. Modify the grub /boot/grub/menu.lst file so the boot section looks something like this
  4. title           Ubuntu 8.04.1, kernel 2.6.24-19-generic
    root            (hd0,0)
    kernel          /boot/vmlinuz-2.6.24-19-generic root=LABEL=mylinukey ro
    initrd          /boot/initrd.img-2.6.24-19-generic
    

Only use the letters [a-zA-Z] in your label. Other characters may prevent your USB key from starting correctly.

Configuration

Root password

Inside the chroot:

# passwd

Type your password twice.

Setting up network

Add default network entries inside the chroot:

# vim /etc/network/interfaces

The content could look like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Time and date

Set the timezone (match the zoneinfo to match your location):

# mv /etc/localtime /etc/localtime.dist
# ln -s /usr/share/zoneinfo/Europe/Oslo /etc/localtime

Add users

# adduser myusername

Sudo

If you're used to Ubuntu systems, you might want to set up sudo. Inside the chroot:

# apt-get install sudo
# addgroup admin
# adduser myusername admin # use your user login instead of 'myusername'
# echo "%admin ALL=(ALL) ALL" >> /etc/sudoers

You'll be able to use sudo when logged in with your main user.


This is it!

You're done! Connect the usb drive to your Linutop and boot it. The default password for root is blank.

The installed system is *really* minimalist and you'll have to set up several things (configure, install packages...)

Quick guide to make our system more pleasant

After booting your new system probably you would like to watch some movie in graphic environment than live in console. Linutop is not the fastest machine available on the market so I advise you to install some lightweight solutions.

Audio drivers: # apt-get install linux-ubuntu-modules-$(uname -r)

Video drivers: # apt-get install xorg

Display manager: # apt-get install xdm

Desktop environment: # apt-get install fluxbox

3rd party software: # apt-get install mplayer firefox openoffice.org leafpad nano gnome-terminal aumix xchat gftp