Difference between revisions of "Minnowboard:Debian Bare Minimum Bootstrapping"

From eLinux.org
Jump to: navigation, search
m
Line 1: Line 1:
'''This document is a work in progress and the instructions are not guaranteed to work. Feedback is needed to improve this document'''
+
'''This document is a work in progress. Feedback is needed to improve this document'''
  
  
Line 14: Line 14:
 
You will need a place to install Debian onto, for safety sake we are installing onto a drive other then the micro SD card. This way if you mess up you can simply format the drive and start over and still have a good install of Angstrom to use.
 
You will need a place to install Debian onto, for safety sake we are installing onto a drive other then the micro SD card. This way if you mess up you can simply format the drive and start over and still have a good install of Angstrom to use.
 
   
 
   
:'''TIP:''' Set your CPU frequency scaling to Ondemand for both cores to keep your system cool during this procedure. Bootstrapping is fairly cpu intensive and things can heat up fast.
+
Your Minnowboard came with Angstrom preinstalled on a micro SD card that had two partitions. The first partition is the UEFI boot partition, which we will keep to boot our Debian system. The second partition is the Angstrom root partition which should be left intact as well.
  
First plugin your thumb drive and use Disk Utility to properly partition it out. I suggest you name your root partition Debian to avoid any confusion later on. If your Feeling adventurous make a swap partition and leave some room for a boot loader.
+
:'''TIP:''' Save the kernel modules in /lib/modules/ directory to preserve the Angstrom kernel modules which a guaranteed to work. You can use these modules and the Angstrom kernel with your Debian root filesystem also.
  
 +
If you are using a new micro sd card or SATA disk you'll want to create a small (approximately 20MB) fat16 or fat32 partition and enable the boot flag on it. This partition will be your new UEFI boot partition. You can use GPT partitioning or MSDOS partitioning if you wish. The Minnowboard's UEFI system can boot off of either of the two.
 +
 +
:'''TIP:''' You can merely copy the files from the Angstrom Boot partition to your new media and you'll have a working Grub UEFI bootloader.
 +
 +
First plugin your thumb drive and use your favorite Disk Utility to properly partition it out. Create the following partitions:
 +
 +
Partition 1: 20-50MB marked as Active or Bootable
 +
Partition 2: 2GB-10GB depending on if you plan on install X11
 +
 +
==== Create filesystems on partitions ====
 +
 +
:'''NOTE:''' Check, Double Check and Triple Check that you are using the CORRECT devices. This could potentially erase your filesystem if you choose the wrong device.
 +
 +
Create a fat32 filesystem on the UEFI boot partition
 +
mkfs.vfat /dev/sdb1
 +
 +
Create an ext4 filesystem on the root partition
 +
 +
mkfs.ext4 /dev/sdb2
 +
 +
Mount the UEFI boot partition and copy all of the files from the device
 +
 +
Mount the Angstrom micro sd card
 +
mkdir /mnt/angstromboot
 +
mount /dev/mmcblk0p1 /mnt/angstromboot
 +
 +
Mount your new UEFI boot partition
 +
mkdir /mnt/debianboot
 +
mount /dev/sdb1  /mnt/debianboot
 +
 +
==== Copy the Angstrom Bootloader files ====
 +
Now we will copy all of the files from the Angstrom micro sd UEFI boot partition
 +
 +
cp -r /mnt/angstromboot/* /mnt/debianboot/
 +
 +
=== Debootstrapping ===
 
Mount the Debian root partition  
 
Mount the Debian root partition  
 
   mkdir /media/debian
 
   mkdir /media/debian
Line 26: Line 62:
 
   cd /debinst
 
   cd /debinst
  
Then choose what version of Debian you want to use.
+
Then choose what version of Debian you want to use. It should be either Debian Jessie or Sid to ensure that you have a serial console.
 +
 
 +
:'''NOTE:''' If you are currently running a Debian based system you can run this command 'sudo aptitude install debootstrap fakeroot' and your system will install the chroot and debootstrap packages for you. If this is the case then the following step is unecessary.
 +
 
 
http://ftp.debian.org/debian/pool/main/d/debootstrap/
 
http://ftp.debian.org/debian/pool/main/d/debootstrap/
 
   mkdir work
 
   mkdir work
Line 41: Line 80:
  
 
Next Comes the part that will take some time. Running the bootsrtap script
 
Next Comes the part that will take some time. Running the bootsrtap script
   /usr/sbin/debootstrap --verbose --extrractor=ar --arch i386 wheezy \/media/debian http://ftp.us.debian.org/debian
+
   /usr/sbin/debootstrap --verbose --extrractor=ar --arch i386 sid \/media/debian http://ftp.us.debian.org/debian
 +
 
 +
:'''NOTE:''' You can replace sid in the command above with jessie, but wheezy should not be used. The kernels in wheezy are too old for the needed changes to support a serial console and perhaps ethernet for the Minnowboard.
  
If all goes well you now have Debian :)
+
=== Configuring ===
Lets configure a few things by chroot into the system.
+
Lets configure a few things by chrooting into the system.
 
   LANG=C.UTF-8 chroot /media/debian /bin/bash
 
   LANG=C.UTF-8 chroot /media/debian /bin/bash
 
Set the terminal to be compatible with the Debian System  
 
Set the terminal to be compatible with the Debian System  
Line 54: Line 95:
 
   MAKEDEV generic
 
   MAKEDEV generic
  
Mount points in fstab
+
You will need to add Mount points in your fstab. Below is a very good starting point for both sd cards and SATA disks.
   editor /etc/fstab
+
 
 +
editor /etc/fstab
 +
 
 +
:'''TIP:''' If you are using an sd card or any flash based storage you will benefit considerably by removing the # in front of the tmpfs entries below. These entries mount various filesystem to tmpfs which help reduce writes on your flash devices; thus prolonging their life. Also note that the log files will not be retain after subsequent boots, so if you need them copy them elsewhere before rebooting.
 +
 
 +
rootfs          /                      ext4      defaults              1  1
 +
proc            /proc                  proc      defaults              0  0
 +
devpts          /dev/pts                devpts    mode=0620,gid=5      0  0
 +
#tmpfs          /var/run                tmpfs  defaults                0  0
 +
#tmpfs          /var/lock              tmpfs  defaults                0  0
 +
#tmpfs          /var/log                tmpfs   defaults                0  0
 +
#tmpfs          /tmp                    tmpfs  defaults                0  0
 +
 
 +
==== CPU Throttling ====
 +
The cpu is set to 600Mhz by default, we'd like to have it at 1GHZ
 +
apt-get install cpufrequtils
 +
 
 +
You have to create the file below but that is no problem, we give you the appropriate contents to fill it with
 +
editor /etc/default/cpufrequtils
 +
 
 +
Add the correct governor to boost performance
 +
# you can run 'cpufreq-info -g' to get a list of available governors
 +
GOVERNOR="performance"
  
(more information needed here on proper fstab settings)
 
  
 
==== Timezone settings ====
 
==== Timezone settings ====
 
The following command allows you to choose your timezone.  
 
The following command allows you to choose your timezone.  
  dpkg-reconfigure tzdata
+
dpkg-reconfigure tzdata
  
 
==== Configure Networking ====
 
==== Configure Networking ====
 +
Networking on the Minnowboard is still a work in progress with the Debian patched kernels. It is suggested that you use a usb wifi or usb ethernet nic until the issues are sorted out appropriately with the pch_gbe module. Currenlty the module loads sporadically and the interface comes up but it fails to respond as it should.
 
   editor /etc/network/interfaces
 
   editor /etc/network/interfaces
  
add the following lines to enable dhcp
+
Add the following lines to provision your interface. If you are using a wireless adapter use the appropriate steps to configure it
 +
 
 
   auto eth0
 
   auto eth0
 
   iface eth0 inet dhcp
 
   iface eth0 inet dhcp
 +
:'''NOTE:''' replace 'auto eth0' with 'noauto eth0' if you'd rather not wait for the interface to attempt to obtain an ipaddress. Currently all attempts will fail with the pch_gbe module, slowing down the boot process. 
 +
 
Enter your nameserver(s) and search directives in /etc/resolv.conf:  
 
Enter your nameserver(s) and search directives in /etc/resolv.conf:  
 
   editor /etc/resolv.conf
 
   editor /etc/resolv.conf
Line 77: Line 143:
  
 
Debootstrap will have created a very basic /etc/apt/sources.list you can add more repositories
 
Debootstrap will have created a very basic /etc/apt/sources.list you can add more repositories
   deb-src http://ftp.us.debian.org/debian wheezy main
+
   deb-src http://ftp.us.debian.org/debian sid main
   deb http://security.debian.org/ wheezy/updates main
+
   deb http://security.debian.org/ sid/updates main
   deb-src http://security.debian.org/ wheezy/updates main
+
   deb-src http://security.debian.org/ sid/updates main
 +
:'''NOTE:''' You should put the correct release in here whether it be sid or jessie but stay away from wheezy unless you plan on using an alternate kernel such as the kernel included with Angstrom
  
 
==== Install a Kernel ====
 
==== Install a Kernel ====
If you intend to boot this system, you probably want a Linux kernel and a boot loader. Identify available pre-packaged kernels with:
+
Identify available pre-packaged kernels with:
 
   apt-cache search linux-image
 
   apt-cache search linux-image
 
Once you find one you like to use do:
 
Once you find one you like to use do:
   aptitude install linux-image-ArchOfYourChoice-etc
+
   aptitude install linux-image-686-pae
 +
 +
or try the realtime kernel
 +
 
 +
aptitude install linux-image-686-rt-pae
 +
 
 +
==== Rebuild your  initramfs ====
 +
Certain modules need to be preloaded for your system to fully boot. These modules should be added to the ramdisk so that your root file system can be mounted
 +
 
 +
editor /etc/initramfs-tools/modules
 +
 
 +
If you are using the micro sd slot you must have the mmc module in the ramdisk for the root filesystem to mount
 +
 
 +
add the following line
 +
mmc
 +
 
 +
Rebuild the initramfs
 +
 
 +
update-initramfs -u
 +
 +
==== Configure a Serial Console ====
 +
Debian needs the following lines added to it's configuration files for your serial console to display a login prompt after booting
 +
  editor /etc/modules
 +
 
 +
add the following line to automatically load the uart console module
 +
pch_uart
 +
 
 +
editor /etc/inittab
 +
 
 +
add the following the bottom of the inittab to tell getty to spawn consoles on the 3 uart devices
 +
T0:23:respawn:/sbin/getty -L ttyPCH0 115200 vt100
 +
T1:23:respawn:/sbin/getty -L ttyPCH1 115200 vt100
 +
T2:23:respawn:/sbin/getty -L ttyPCH2 115200 vt100
 +
 
 +
editor /etc/securetty
 +
 
 +
add the follwing entries to the securetty file so that the root user can login via the console
 +
 
 +
ttyPCH0
 +
ttyPCH1
 +
ttyPCH2
  
 
==== Boot Loader ====
 
==== Boot Loader ====
(Not working yet.)
+
In order to simplify things we will just reuse the boot partition that was provided with the Angstrom Minnowboard image. More information will be added here later but until then, this is the quickest way to achieve a working system.
   aptitude install grub-pc
+
 
  grub-install /dev/hdb1
+
There is a grub.cfg included in the /EFI/BOOT directory of the uefi boot partition of the Angstrom Minnowboard image. Edit it as follows
  update-grub
+
 
 +
Use this for a MBR partitioned disk
 +
 
 +
menuentry "Debian 7.0 3.10-3-rt-686-pae (32-bit, EFI)" {
 +
insmod part_msdos
 +
insmod ext2
 +
set root='(hd0,msdos2)'
 +
linux /boot/vmlinuz-3.10-3-rt-686-pae root=/dev/sda2 ro rootwait console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0
 +
initrd /boot/initrd.img-3.10-3-rt-686-pae
 +
}
 +
 
 +
Use this entry for a GPT partitioned disk
 +
 
 +
 
 +
menuentry "Debian 7.0 3.10-3-rt-686-pae (32-bit, EFI)" {
 +
insmod part_gpt
 +
insmod ext2
 +
set root='(hd0,gpt2)'
 +
linux /boot/vmlinuz-3.10-3-rt-686-pae root=/dev/sda2 ro rootwait console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0
 +
initrd /boot/initrd.img-3.10-3-rt-686-pae
 +
}
 +
 
 +
If you are using a micro sd card make sure that you change the 'root=/dev/sda2' line to 'root=/dev/mmcblkp2'
 +
 
 +
Install grub-efi
 +
 
 +
   aptitude install grub-efi-ia32
 +
 
 +
mount your uefi boot partition
 +
mount /dev/sda1 /mnt
 +
or
 +
mount /dev/mmcblkp1 /mnt
 +
 
 +
Copy all of the modules from the grub-efi directory to the boot partition
 +
cp -r /usr/lib/grub/i386-efi /mnt/EFI/BOOT/
 +
 
 +
More information will come soon on the installation of grub via Debian Sid's Grub 2.X but many errors were produced during installation.
  
 
==== SSH and Remote Access ====
 
==== SSH and Remote Access ====
(Needs fixing)
+
   aptitude install openssh-server
   aptitude install ssh
 
 
   passwd
 
   passwd
  
==== Expanding Further ====
+
==== Finishing Up ====
 +
 
 +
Exit the chroot environment
 +
exit
 +
 
 +
You system is now ready to boot from the installed media
 +
=== Expanding Further ===
 
As mentioned earlier, the installed system will be very basic. You can expand your system more with the following command
 
As mentioned earlier, the installed system will be very basic. You can expand your system more with the following command
 
  tasksel install standard
 
  tasksel install standard

Revision as of 18:57, 11 October 2013

This document is a work in progress. Feedback is needed to improve this document


Bootstrapping Debian onto your MinnowBoard is a fairly simple process. At the end of this guide you will have a complete minimum Debian system you can use on your MinnowBoard.

Requirements:

  1. MinnowBoard that has a working micro SD card preloaded with the MinnowBoard Angstrom Linux Distribution
  2. USB Thumb drive >2GB or SATA drive
  3. Internet connection
  4. Some spare time

Lets Get Started

You will need a place to install Debian onto, for safety sake we are installing onto a drive other then the micro SD card. This way if you mess up you can simply format the drive and start over and still have a good install of Angstrom to use.

Your Minnowboard came with Angstrom preinstalled on a micro SD card that had two partitions. The first partition is the UEFI boot partition, which we will keep to boot our Debian system. The second partition is the Angstrom root partition which should be left intact as well.

TIP: Save the kernel modules in /lib/modules/ directory to preserve the Angstrom kernel modules which a guaranteed to work. You can use these modules and the Angstrom kernel with your Debian root filesystem also.

If you are using a new micro sd card or SATA disk you'll want to create a small (approximately 20MB) fat16 or fat32 partition and enable the boot flag on it. This partition will be your new UEFI boot partition. You can use GPT partitioning or MSDOS partitioning if you wish. The Minnowboard's UEFI system can boot off of either of the two.

TIP: You can merely copy the files from the Angstrom Boot partition to your new media and you'll have a working Grub UEFI bootloader.

First plugin your thumb drive and use your favorite Disk Utility to properly partition it out. Create the following partitions:

Partition 1: 20-50MB marked as Active or Bootable
Partition 2: 2GB-10GB depending on if you plan on install X11

Create filesystems on partitions

NOTE: Check, Double Check and Triple Check that you are using the CORRECT devices. This could potentially erase your filesystem if you choose the wrong device.

Create a fat32 filesystem on the UEFI boot partition

mkfs.vfat /dev/sdb1

Create an ext4 filesystem on the root partition

mkfs.ext4 /dev/sdb2

Mount the UEFI boot partition and copy all of the files from the device

Mount the Angstrom micro sd card

mkdir /mnt/angstromboot
mount /dev/mmcblk0p1 /mnt/angstromboot

Mount your new UEFI boot partition

mkdir /mnt/debianboot
mount /dev/sdb1  /mnt/debianboot

Copy the Angstrom Bootloader files

Now we will copy all of the files from the Angstrom micro sd UEFI boot partition

cp -r /mnt/angstromboot/* /mnt/debianboot/

Debootstrapping

Mount the Debian root partition

 mkdir /media/debian
 mount /dev/sdb1 /media/debian

Next make a root directory on your Angstrom micro SD card to hold all the bootstrap files call it debinst.

 mkdir /debinst
 cd /debinst

Then choose what version of Debian you want to use. It should be either Debian Jessie or Sid to ensure that you have a serial console.

NOTE: If you are currently running a Debian based system you can run this command 'sudo aptitude install debootstrap fakeroot' and your system will install the chroot and debootstrap packages for you. If this is the case then the following step is unecessary.

http://ftp.debian.org/debian/pool/main/d/debootstrap/

 mkdir work
 cd work
 wget http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.48+deb7u1_all.deb

copy the package to the work folder, and extract the files from it.

 ar -x debootstrap_1.0.48+deb7u1_all.deb
 cd /
 zcat /debinst/data.tar.gz | tar xv

There is a small issue with the installer that needs to be fixed before we start the script. Edit /debinst/usr/sbin/debootstrap line 16 to

 DEBOOTSTRAP_DIR=/debinst/usr/share/debootstrap

Next Comes the part that will take some time. Running the bootsrtap script

 /usr/sbin/debootstrap --verbose --extrractor=ar --arch i386 sid \/media/debian http://ftp.us.debian.org/debian
NOTE: You can replace sid in the command above with jessie, but wheezy should not be used. The kernels in wheezy are too old for the needed changes to support a serial console and perhaps ethernet for the Minnowboard.

Configuring

Lets configure a few things by chrooting into the system.

 LANG=C.UTF-8 chroot /media/debian /bin/bash

Set the terminal to be compatible with the Debian System

 export TERM=xterm-color

Now we can create the device files (there may be a better way to do this)

 apt-get install makedev
 cd /dev
 MAKEDEV generic

You will need to add Mount points in your fstab. Below is a very good starting point for both sd cards and SATA disks.

editor /etc/fstab
TIP: If you are using an sd card or any flash based storage you will benefit considerably by removing the # in front of the tmpfs entries below. These entries mount various filesystem to tmpfs which help reduce writes on your flash devices; thus prolonging their life. Also note that the log files will not be retain after subsequent boots, so if you need them copy them elsewhere before rebooting.
rootfs          /                       ext4       defaults              1  1
proc            /proc                   proc       defaults              0  0
devpts          /dev/pts                devpts     mode=0620,gid=5       0  0
#tmpfs           /var/run                tmpfs   defaults                0  0
#tmpfs           /var/lock               tmpfs   defaults                0  0
#tmpfs           /var/log                tmpfs   defaults                0  0
#tmpfs           /tmp                    tmpfs   defaults                0  0

CPU Throttling

The cpu is set to 600Mhz by default, we'd like to have it at 1GHZ

apt-get install cpufrequtils

You have to create the file below but that is no problem, we give you the appropriate contents to fill it with

editor /etc/default/cpufrequtils

Add the correct governor to boost performance

# you can run 'cpufreq-info -g' to get a list of available governors
GOVERNOR="performance"


Timezone settings

The following command allows you to choose your timezone.

dpkg-reconfigure tzdata

Configure Networking

Networking on the Minnowboard is still a work in progress with the Debian patched kernels. It is suggested that you use a usb wifi or usb ethernet nic until the issues are sorted out appropriately with the pch_gbe module. Currenlty the module loads sporadically and the interface comes up but it fails to respond as it should.

 editor /etc/network/interfaces

Add the following lines to provision your interface. If you are using a wireless adapter use the appropriate steps to configure it

 auto eth0
 iface eth0 inet dhcp
NOTE: replace 'auto eth0' with 'noauto eth0' if you'd rather not wait for the interface to attempt to obtain an ipaddress. Currently all attempts will fail with the pch_gbe module, slowing down the boot process.

Enter your nameserver(s) and search directives in /etc/resolv.conf:

 editor /etc/resolv.conf

Enter your system's host name (2 to 63 characters)

 echo DebianMinnow > /etc/hostname

Configure Apt

Debootstrap will have created a very basic /etc/apt/sources.list you can add more repositories

 deb-src http://ftp.us.debian.org/debian sid main
 deb http://security.debian.org/ sid/updates main
 deb-src http://security.debian.org/ sid/updates main
NOTE: You should put the correct release in here whether it be sid or jessie but stay away from wheezy unless you plan on using an alternate kernel such as the kernel included with Angstrom

Install a Kernel

Identify available pre-packaged kernels with:

 apt-cache search linux-image

Once you find one you like to use do:

 aptitude install linux-image-686-pae

or try the realtime kernel

aptitude install linux-image-686-rt-pae

Rebuild your initramfs

Certain modules need to be preloaded for your system to fully boot. These modules should be added to the ramdisk so that your root file system can be mounted

editor /etc/initramfs-tools/modules

If you are using the micro sd slot you must have the mmc module in the ramdisk for the root filesystem to mount

add the following line

mmc

Rebuild the initramfs

update-initramfs -u

Configure a Serial Console

Debian needs the following lines added to it's configuration files for your serial console to display a login prompt after booting

 editor /etc/modules

add the following line to automatically load the uart console module

pch_uart
editor /etc/inittab

add the following the bottom of the inittab to tell getty to spawn consoles on the 3 uart devices

T0:23:respawn:/sbin/getty -L ttyPCH0 115200 vt100
T1:23:respawn:/sbin/getty -L ttyPCH1 115200 vt100
T2:23:respawn:/sbin/getty -L ttyPCH2 115200 vt100
editor /etc/securetty

add the follwing entries to the securetty file so that the root user can login via the console

ttyPCH0
ttyPCH1
ttyPCH2

Boot Loader

In order to simplify things we will just reuse the boot partition that was provided with the Angstrom Minnowboard image. More information will be added here later but until then, this is the quickest way to achieve a working system.

There is a grub.cfg included in the /EFI/BOOT directory of the uefi boot partition of the Angstrom Minnowboard image. Edit it as follows

Use this for a MBR partitioned disk

menuentry "Debian 7.0 3.10-3-rt-686-pae (32-bit, EFI)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos2)'
linux /boot/vmlinuz-3.10-3-rt-686-pae root=/dev/sda2 ro rootwait console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0
initrd /boot/initrd.img-3.10-3-rt-686-pae
}

Use this entry for a GPT partitioned disk


menuentry "Debian 7.0 3.10-3-rt-686-pae (32-bit, EFI)" {
insmod part_gpt
insmod ext2
set root='(hd0,gpt2)'
linux /boot/vmlinuz-3.10-3-rt-686-pae root=/dev/sda2 ro rootwait console=ttyPCH0,115200 console=tty0 vmalloc=256MB snd-hda-intel.enable_msi=0
initrd /boot/initrd.img-3.10-3-rt-686-pae
}

If you are using a micro sd card make sure that you change the 'root=/dev/sda2' line to 'root=/dev/mmcblkp2'

Install grub-efi

 aptitude install grub-efi-ia32

mount your uefi boot partition

mount /dev/sda1 /mnt

or

mount /dev/mmcblkp1 /mnt

Copy all of the modules from the grub-efi directory to the boot partition

cp -r /usr/lib/grub/i386-efi /mnt/EFI/BOOT/

More information will come soon on the installation of grub via Debian Sid's Grub 2.X but many errors were produced during installation.

SSH and Remote Access

 aptitude install openssh-server
 passwd

Finishing Up

Exit the chroot environment

exit

You system is now ready to boot from the installed media

Expanding Further

As mentioned earlier, the installed system will be very basic. You can expand your system more with the following command

tasksel install standard

From the bootstrapping process there will be a ton of left over packages in /var/cache/apt/archives/. You may want to remove them.

 aptitude clean