Linux netbooting: Difference between revisions

From WirelessAfrica
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
Instructions follow on how to netboot using Ubuntu Linux.
Instructions follow on how to netboot using Ubuntu Linux.
=Server Setup=
==Setup DHCP==
[[/usr/local/etc/dhcp.conf]]
==Setup PXE==
==Setup Filesystem==
Useful information: [http://evanjones.ca/software/pxeimager-scratch.html Building PXE Imager from scratch]
1) Use debian debootstrap tool to create basic filesystem.
sudo debootstrap breezy /home/yusuf/ubuntu ftp://ftp.is.co.za/ubuntu/
2) chroot into new filesystem
sudo chroot /home/yusuf/ubuntu/
3) create apt source list
sudo vi /etc/apt/sources.list
4) Add packages
sudo apt-get update
sudo apt-get install ssh olsrd
5) Tar the filesystem
  sudo tar -cvjf ubuntu.tar.gz ./ubuntu/
6) Copy the filesystem to the server and un-tar
  scp ubuntu.tar.gz user@server:


=Client Setup=
=Client Setup=
==Create Linux Kernel==
==Create Linux Kernel==


There are two types of Kernel images you can build. The first is an image which contains all the necessary file system drivers, or even network drivers in the case of NFS, to allow the file systems to mount and let the operating system boot normally. The second type of kernel image puts all the drivers in a file which is mounted in RAM as a RAM disk. This is known as an initrd file. initrd stands for "initial ramdisk"  
To get a kernel up and running it needs firstly to boot itself and then run some file system drivers, or even network drivers in the case of NFS, to allow the file systems to mount and let the operating system boot normally. To do this the kernel needs to mount a RAM disk which contains all the drivers necessary for boot up. This RAM disk is called an initrd file or "initial ramdisk file" Below are the steps to firstly create the kernel with the necessary options then create a ramdisk file with the required drivers and finally configure the server to network boot this kernel


'''I Create kernel image with module drivers built in'''
'''I Build the kernel image'''


1) Start the kernel configuration program
1) Start the kernel configuration program in /usr/src/<linux kernel version>


  sudo make menuconfig
  sudo make menuconfig
Line 51: Line 18:
  Device Drivers  --->
  Device Drivers  --->
   Networking support  --->  
   Networking support  --->  
  Ethernet (10 or 100Mbit)  --->
    [*] Via Rhine support
   Networking options  --->
   Networking options  --->
     [*] Packet socket
     [*] Packet socket
Line 61: Line 30:
   <*> NFS file system support  
   <*> NFS file system support  
     [*] Root file system on NFS
     [*] Root file system on NFS
Loadable module support  --->
  [] Enable loadable module support


3) Make the kernel
3) Make the kernel
Line 78: Line 45:
  scp bzImage djohnson@meshy.dhcp:~/vmlinuz.david
  scp bzImage djohnson@meshy.dhcp:~/vmlinuz.david


'''II Build the initial ramdisk file (initrd)'''
1) Make the kernel module drivers
sudo make modules
2) Backup your current kernel modules (<current kernel version> is your current kernel e.g. 2.6.10-12
sudo cp -r /usr/modules/<current kernel version> /usr/modules/<current kernel version>.bak
3) Install the module drivers (note this will install all the drivers in the directory /lib/modules/<kernel version> If your current kernel version is the same as the kernel source you are building it will overwrite all your current kernel modules but step 2 would have created a backup - after this process however you will need to restore your original kernel modules using the backup
sudo make modules_install
4) Create the initrd ramdisk image
sudo mkinitrd -o initrd.img-2.6.12 2.6.12
The mkinitrd script does a few default things here. First it looks at /etc/mkinitrd/mkinitrd.conf to see which modules it must include. In the example above it will look in /lib/modules/2.6.12 to find all the modules to build into the initrd.img-2.6.12 file
5) Copy the initrd file to the server
scp initrd.img-2.6.12 djohnson@meshy.dhcp:~
'''III Setup the server to run the kernel with the initrd file'''
1) Login to the server containing these files
ssh name@server
2) Copy the kernel and the initrd file to the tftpboot directory
cp vmlinuz.david initrd.img-2.6.12 /export/tftpboot
3) Edit the pxelinux.cfg/defualt file to boot your new kernel
DEFAULT vmlinuz.david
APPEND ip=dhcp root=/dev/nfs nfsroot=172.20.1.1:/export/linux/ubuntu ramdisk_size=16432 initrd=initrd.img-2.6.12
=Server Setup=
==Setup DHCP==
[[/usr/local/etc/dhcp.conf]]
==Setup PXE==
==Setup Filesystem==
Useful information: [http://evanjones.ca/software/pxeimager-scratch.html Building PXE Imager from scratch]
'''I Setup root file system'''
1) Use debian debootstrap tool to create basic filesystem.
sudo debootstrap breezy /home/yusuf/ubuntu ftp://ftp.is.co.za/ubuntu/
2) Copy the driver modules that were created in the client setup to the filesystem
cp -r /usr/modules/<current kernel version> /home/yusuf/ubuntu/lib/modules
3) chroot into new filesystem
sudo chroot /home/yusuf/ubuntu/
4) Setup a root passwd
passwd
password: <enter root password>
5) create apt source list
sudo vi /etc/apt/sources.list
6) Add packages
sudo apt-get update
sudo apt-get install ssh olsrd
7) Tar the filesystem
  sudo tar -cvjf ubuntu.tar.gz ./ubuntu/
8) Copy the filesystem to the server and un-tar
  scp ubuntu.tar.gz user@server:~


'''II Create kernel image without module drivers built in'''


1) Start the kernel configuration program
'''II Create root file system on the server'''


sudo make menuconfig
1) Login to the server containing these files


2) Set the following options on the kernel configuration menus
ssh name@server


Processor type and features  ---> 
2) Untar the root file system to the export directory
  Processor family: Pentium-Classic
Device Drivers  --->
  Networking support  --->
  Networking options  --->
    [*]IP: kernel level autoconfiguration                           
      [*]    IP: DHCP support
      [*]    IP: BOOTP support
      [*]    IP: RARP support             
File systems  --->
  Network File Systems  --->
  <*> NFS file system support
    [*] Root file system on NFS
Loadable module support  --->
  [*] Enable loadable module support


3) Make the kernel
tar zxvf ubuntu.tar.gz /export/linux/


sudo make
3) Restart one of the client machines and check that it boots successfully


4) Make the kernel image


sudo make bzImage
''How to build a gutsy file system''


This will give you your linix kernel image (bzImage) in /usr/src/linux-source-2.6.12/arch/i386/boot/
After chroot into file system


5) Copy the kernel image to the server directory where the booting directory is located
1) Remove udev
   
   
  scp bzImage djohnson@meshy.dhcp:/export/tftpboot/vmlinuz.david
  apt-get remove udev


6) Make the kernel module drivers
2) Get slackware devices


  sudo make modules
[http://www.slackware.at/data/slackware-9.0/slackware/a/devs-2.3.1-i386-13.tgz Slackware devices]
 
Copy these to root of chroot environemnt
 
Untar in root
 
tar zxvf devs-2.3.1-i386-13.tgz /
 
3) Change the policy of the init
 
 
Add /usr/sbin/policy.init.d
 
#!/bin/sh
exit 101
 
4) Add locale settings
 
/var/lib/locales/supported.d/
 
en
local
 
sudo dpkg-reconfigure locales
 
5) In you kernel configuraion
 
Under devices->character devices
[*] Unix98 PTY support


7) Install the module drivers


sudo make modules_install
=Building a linux system from scratch=


8) Create the initrd ramdisk image
==Adding dropbear support==


sudo mkinitrd -o initrd.img-2.6.12 2.6.12
If you are logging in from bash


9)
change the /etc/passwd file to:
root:x:0:0:root:/root:/bin/bash

Latest revision as of 17:08, 7 February 2008

Instructions follow on how to netboot using Ubuntu Linux.

Client Setup

Create Linux Kernel

To get a kernel up and running it needs firstly to boot itself and then run some file system drivers, or even network drivers in the case of NFS, to allow the file systems to mount and let the operating system boot normally. To do this the kernel needs to mount a RAM disk which contains all the drivers necessary for boot up. This RAM disk is called an initrd file or "initial ramdisk file" Below are the steps to firstly create the kernel with the necessary options then create a ramdisk file with the required drivers and finally configure the server to network boot this kernel

I Build the kernel image

1) Start the kernel configuration program in /usr/src/<linux kernel version>

sudo make menuconfig

2) Set the following options on the kernel configuration menus

Processor type and features  --->  
 Processor family: Pentium-Classic
Device Drivers  --->
 Networking support  ---> 
  Ethernet (10 or 100Mbit)  --->
   [*] Via Rhine support
  Networking options  --->
    [*] Packet socket
    [*]IP: kernel level autoconfiguration                             
     [*]     IP: DHCP support
     [*]     IP: BOOTP support
     [*]     IP: RARP support               
File systems  ---> 
 Network File Systems  ---> 
  <*> NFS file system support 
   [*] Root file system on NFS

3) Make the kernel

sudo make

4) Make the kernel image

sudo make bzImage

This will give you your linix kernel image (bzImage) in /usr/src/linux-source-2.6.12/arch/i386/boot/

5) Copy the kernel image to the server

scp bzImage djohnson@meshy.dhcp:~/vmlinuz.david

II Build the initial ramdisk file (initrd)

1) Make the kernel module drivers

sudo make modules

2) Backup your current kernel modules (<current kernel version> is your current kernel e.g. 2.6.10-12

sudo cp -r /usr/modules/<current kernel version> /usr/modules/<current kernel version>.bak

3) Install the module drivers (note this will install all the drivers in the directory /lib/modules/<kernel version> If your current kernel version is the same as the kernel source you are building it will overwrite all your current kernel modules but step 2 would have created a backup - after this process however you will need to restore your original kernel modules using the backup

sudo make modules_install

4) Create the initrd ramdisk image

sudo mkinitrd -o initrd.img-2.6.12 2.6.12

The mkinitrd script does a few default things here. First it looks at /etc/mkinitrd/mkinitrd.conf to see which modules it must include. In the example above it will look in /lib/modules/2.6.12 to find all the modules to build into the initrd.img-2.6.12 file

5) Copy the initrd file to the server

scp initrd.img-2.6.12 djohnson@meshy.dhcp:~

III Setup the server to run the kernel with the initrd file

1) Login to the server containing these files

ssh name@server

2) Copy the kernel and the initrd file to the tftpboot directory

cp vmlinuz.david initrd.img-2.6.12 /export/tftpboot

3) Edit the pxelinux.cfg/defualt file to boot your new kernel

DEFAULT vmlinuz.david APPEND ip=dhcp root=/dev/nfs nfsroot=172.20.1.1:/export/linux/ubuntu ramdisk_size=16432 initrd=initrd.img-2.6.12


Server Setup

Setup DHCP

/usr/local/etc/dhcp.conf

Setup PXE

Setup Filesystem

Useful information: Building PXE Imager from scratch

I Setup root file system

1) Use debian debootstrap tool to create basic filesystem.

sudo debootstrap breezy /home/yusuf/ubuntu ftp://ftp.is.co.za/ubuntu/

2) Copy the driver modules that were created in the client setup to the filesystem

cp -r /usr/modules/<current kernel version> /home/yusuf/ubuntu/lib/modules

3) chroot into new filesystem

sudo chroot /home/yusuf/ubuntu/

4) Setup a root passwd

passwd
password: <enter root password>

5) create apt source list

sudo vi /etc/apt/sources.list

6) Add packages

sudo apt-get update
sudo apt-get install ssh olsrd

7) Tar the filesystem

 sudo tar -cvjf ubuntu.tar.gz ./ubuntu/

8) Copy the filesystem to the server and un-tar

 scp ubuntu.tar.gz user@server:~


II Create root file system on the server

1) Login to the server containing these files

ssh name@server

2) Untar the root file system to the export directory

tar zxvf ubuntu.tar.gz /export/linux/

3) Restart one of the client machines and check that it boots successfully


How to build a gutsy file system

After chroot into file system

1) Remove udev

apt-get remove udev

2) Get slackware devices

Slackware devices

Copy these to root of chroot environemnt

Untar in root

tar zxvf devs-2.3.1-i386-13.tgz /

3) Change the policy of the init


Add /usr/sbin/policy.init.d

  1. !/bin/sh

exit 101

4) Add locale settings

/var/lib/locales/supported.d/

en local

sudo dpkg-reconfigure locales

5) In you kernel configuraion

Under devices->character devices [*] Unix98 PTY support


Building a linux system from scratch

Adding dropbear support

If you are logging in from bash

change the /etc/passwd file to:

root:x:0:0:root:/root:/bin/bash