Difference between revisions of "Debian deboostrap"
(→How could this guide be improved)
(→Partition the disk)
|Line 17:||Line 17:|
===Partition the disk===
===Partition the disk===
We will create 3 partitions : one with about 3GB for the
We will create 3 partitions : one with about 3GB for the system, another one with 256MB for swap, and another one that takes the rest of the disk.
# fdisk /dev/sda
# fdisk /dev/sda
Revision as of 18:09, 27 February 2011
- 1 Plan of action
- 2 (Re)Partitioning the drive
- 3 Install a temporary Debian system on /dev/hda3
- 4 Configuring your Ubuntu system
- 5 Boot your Ubuntu OS
- 6 How could this guide be improved
Plan of action
Installing Debian from scratch is a complex and lengthy process. This is our plan of action :
- Partition the drive
- Boot to a temporary debian system on /dev/hda3, so we can
- debootstrap debian, chroot to it, configure it and
- compile a vanilla mainstream kernel
- reboot and see if everything is all right
For this guide, you need to have the newer Uboot version, with the netconsole working, available in Kurobox support in stock 2.6 kernels. The guide also assumes you are using foonas-em.
(Re)Partitioning the drive
Get on EM mode
Get on EM mode. On foonas-em this is done by pressing the Power button one time after the device powered on, and while the power light is still slowly blinking. If you can't get on EM mode by this way, you can enter 'run fooflboot' on the netconsole.
Partition the disk
We will create 3 partitions : one with about 3GB for the Debian system, another one with 256MB for swap, and another one that takes the rest of the disk.
# fdisk /dev/sda -> o ( enter ) (clean the partition table on the disk) -> n, p, 1, (enter), +3000M; (New Primary partition in position 1, from start to 2048M after it) -> a, 1; (Set partition 1 as bootable) -> n, p, 2, (enter), +256M; (New Primary partition in position 2, from the first free spot to 256M after it) -> t, 2, 82; (set Type of partition 2 as 82 (Linux Swap) -> n, p, 3, (enter), (enter); (New Primary partition 3, taking the rest of the disk) -> w (write the changes to the disk - THIS WILL REFORMAT YOUR HD! BACKUP YOUR DATA! - ) # mkfs.ext3 -j /dev/sda1 (Create a new journaled ext3 filesystem on /dev/sda1) # mkfs.ext3 -j /dev/sda3 (Create a new journaled ext3 filesystem on /dev/sda1) # mkswap /dev/sda2 (Create a swap filesystem on /dev/sda2)
Install a temporary Debian system on /dev/hda3
If you already have a working installation of Gentoo, you can debootstrap Ubuntu from there without having to first install Debian. See Debootstrap Ubuntu from Gentoo
If you have the newer foonas-em mode installed, it should be possible to debootstrap and chroot from the EM mode, since it does have a 2.6 kernel.
Now we will prepare to boot a pre-made image on /dev/hda3, so we can use the debootstrap tool later on to create our final system on /dev/hda1. One could chroot to the image, using the EM Mode, and try to deboostrap from there, but to be able to chroot to the Ubuntu partition, you need to be running a newer kernel, so it's mandatory to boot on a newer kernel. (It said "FATAL : Kernel too old" for me when I tried it)
Get the Debian image and a kernel image from Debian_sylver. Be sure to grab a kernel image that supports U-boot.
Also, before proceeding, have your netconsole running, we'll need to enter special boot parameters. (Run "nc -u -p 6666 -v -v 192.168.0.100 6666", replacing 192.168.0.100 for your Kurobox Ip. Make sure your kurobox/desktop are ready to use the netconsole)
Have the Debian image ready for boot
$ mount /dev/hda3 /mnt -> Use your favorite tool to FTP the debian image to /mnt/ -> Use your favorite tool to FTP the kernel image to /mnt/ $ cd /mnt $ tar xvfz debian_image.tar.gz $ tar xzf linux-kenel_image.tar.gz $ cp boot/uImage boot/vmlinux.UBoot (U-Boot is configured to boot from vmlinux.UBoot) $ vi etc/fstab (make sure everything is ok - /dev/hda3 should mount on /, hda1 should mount on /mnt)
Before rebooting, you should check the network settings for this temporary Debian installation. In particular, the contents of:
(The necessary contents of these files are described below in 'Configuring your Ubuntu system')
$ write_ok (the box won't boot normally if you don't issue that command) $ reboot
At this point, have your netconsole running on your pc, be ready to stop the boot procedure hitting 's'.
Running debootstrap on the Debian Image
These steps are done on the netconsole :
-> Hit 's' before the timeout comes => ext2load ide 0:3 800000 boot/vmlinux.UBoot (load the kernel on the memory) => setenv bootargs root=/dev/hda3 (set that the root file system is on hda3) => bootm 800000 (finally, boot from that memory address)
Hopefully the Debian image will boot. Back on the normal shell, telnet to it :
$ telnet 192.168.0.100 (username and password : tmp-kun ) $ su (root password : root ) $ apt-get update
Note that we need to use a special version from debootstrap, one that has the ubuntu scripts :
$ apt-get install debootstrap $ wget http://br.archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_0.3.3.2ubuntu3_all.deb $ dpkg -i debootstrap_0.3.3.2ubuntu3_all.deb $ debootstrap --arch powerpc feisty /mnt http://archive.ubuntu.com/ubuntu/ (place to pickup mirrors)
This will setup a base system on /mnt, and it will take a while. Nice time for a coffee :)
Configuring your Ubuntu system
At this point, we will get your Ubuntu system ready to be booted on.
$ cp /etc/fstab /mnt/etc/fstab (just a template that will help us configuring fstab later) $ chroot /mnt /bin/bash $ mount -t proc proc /proc
Note that we will use the mainstream kernel on this system. This means that we have to use the PATA drivers, instead of IDE. So edit your fstab file, make sure sda1 goes to /, and sda3 goes to /mnt. Ensure we have no "hda1", "hda2" or "hda3", replace for "sda1", "sda2", "sda3".
$ vim /etc/fstab
We have to ensure the box will connect to the network. So edit the /etc/network/interfaces file.
$ vim /etc/network/interfaces (configure to use with dhcp or static config)
If you use DHPC :
auto eth0 lo iface eth0 inet dhcp iface lo inet loopback
If you use a static setting (replace the ips to fit you) :
auto eth0 lo iface eth0 inet static address 192.168.0.100 network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 iface lo inet loopback
Ok, let's move on :
$ vim /etc/resolv.conf (make sure that is has your nameserver/router) $ echo NameOfYourBox > /etc/hostname (this is the coolest part - name your host! ) $ vim /etc/hosts (Update your hosts file with your new IP & hostname (if using static IP) 127.0.0.1 localhost 192.168.0.100 NameOfYourBox $ vim /etc/apt/sources.list ( you can generate one for you on http://www.ubuntu-nl.org/source-o-matic/ ) $ apt-get update $ apt-get install console-data (reconfigure keyboard, if needed) $ dpkg-reconfigure console-data $ vim etc/hosts.allow (you should add your network there) ALL : 192.168.0.0/255.255.0.0 ALL : 127.0.0.1
$ dpkg-reconfigure tzdata (adjust your timezone) $ adduser YourUserName $ passwd (change the root password) $ visudo (add the following to the file, and save, so your user can use sudo) YourUserName ALL=(ALL) NOPASSWD: ALL $ apt-get install ubuntu-standard (This set of packages provides a comfortable text-only Unix-like environment) $ apt-get install ssh (you'll need this to login to your Kurobox later)
Building the kernel
# apt-get install git git-core make patch unzip bison flex libncurses5-dev gcc (install the additional packages for compiling kernel) # update-alternatives --config git (choose #2: git-scm - we need git to get the sources for dtc) # chown -R YourUserName:users /usr/src (you need permission to write on that folder) # su YourUserName (this part is meant to be run as a normal use) $ cd /usr/src $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.tar.bz2 (get the most recent from http://www.kernel.org/pub/linux/kernel) $ tar xjf linux-2.6.21.tar.bz2 $ ln -sf linux-2.6.21 linux $ git clone git://www.jdl.com/software/dtc.git dtc (the dtc tool is used to compile a required special hardware database file) $ cd /usr/src/dtc $ make $ sudo ln -sf /usr/src/dtc/dtc /usr/local/bin/ $ sudo apt-get install uboot-mkimage (that is needed to produce kernel images that the u-boot can boot into) $ cd /usr/src/linux $ cp arch/powerpc/configs/linkstation_defconfig .config $ make menuconfig $ make uImage modules $ exit # cd /usr/src/linux # make modules_install # cp arch/powerpc/boot/uImage /boot/vmlinux.UBoot # cp arch/powerpc/boot/dts/kuroboxHG.dts /boot/ # cd /boot # dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts # reboot
(User:Mflint suspects that 'jigit' package is not needed -- indeed, maybe it's really not, removed from the guide)
Boot your Ubuntu OS
$ sudo apt-get install avr-evtd $ sudo vim /etc/default/avr_evtd (tweak the configuration to suit your needs)
Make Hwclock work
Hwclock only reads from /dev/rtc, but the system makes /dev/rtc0. Add this command to have udev to link rtc->rtc0 every time the system boots, so you can use the hwclock command. Just add the line to the file:
$ sudo vim /etc/udev/rules.d/50-udev.rules KERNEL=="rtc0", SYMLINK+="rtc"
If you see the following error when running perl:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_GB.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C").
# locale-gen en_GB.UTF-8 en_US.UTF-8
(be sure to choose an appropriate locale)
Inform the repository that you are using the packages related to the Kurobox, so they don't get forgotten, run :
# sudo apt-get install popularity-contest
How could this guide be improved
- A better foonas-em busybox, comming with ar, that would allow debootstrapping directly without the need to boot the temporary debian image.