Netboot install

From LSDevLinux
Revision as of 10:36, 24 November 2010 by Mayhewn (talk | contribs) (Reverted edits by Okopacare (Talk); changed back to last version by Mayhewn)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

It's possible to install Debian/Ubuntu entirely over a network without downloading a full ISO CD image.

This has a number of advantages. One is that you are doing the download and the install in one step, which means that you can set it going without waiting for a large CD image to download, and when you come back the installation will be finished and the machine ready to use. Another advantage is that you may use a mirror that doesn't carry CD images (many don't) and at busy times just after new releases these mirrors are fairly lightly loaded since the CDs contain all the latest packages and few additional mirror downloads are needed.

A live CD is always useful as a recovery disk, but it's not necessary to have the latest and greatest. A live CD from a previous release, or a different distro, will often do just as well.

Method of booting

First you will need to decide which of several boot methods you will use, as described below. Each involves downloading a few small files from a mirror and booting from them. All of the necessary files can be downloaded from the netboot directory of any mirror site:


The gtk subdirectory contains versions that use the graphical installer. Otherwise the installer is console-based. Surprisingly, the graphical installer is only very slightly larger.

Mini ISO

The Mini ISO [1] is a bootable CD image that is only 10-16MB in size. It is the file mini.iso at the top level of the netboot or netboot/gtk mirror directory mentioned above.

Download and burn this to a CD, ideally a rewritable one, since you probably won't ever need it again. This is also typically a good way set up a new virtual machine, by attaching the downloaded ISO to the virtual CD drive (ie no need to burn a CD in this case).

Set the machine to boot from the CD drive, eg by changing the boot order to "Floppy. CD, HD".

GRUB flash

It's possible to install GRUB on a USB flash drive and copy the netboot kernel and initrd to it. These files are in the debian-installer/i386 of the netboot mirror directory mentioned above. This can be done with any flash drive, and doesn't require any repartitioning or imaging of the drive.

The outline of the procedure is as follows:

  1. Create a boot directory at the top level of the drive, and a grub directory within that.
  2. Copy the files linux and initrd.gz to the boot directory, or a subdirectory of it.
  3. Create a menu.lst in boot/grub.
  4. Install GRUB to the MBR.

It's possible to have multiple sets of linux+initrd for different distros and purposes all on the one drive. They don't take up much space. It's easier to keep things organized if you use separate subdirectories for each distro and release. You can also have memtest86 available, which is handy for checking suspect machines, even Windows ones.

Having GRUB in the MBR is invisible until you boot from the drive, and doesn't affect its operation in any way. You can keep GRUB and the boot directory on there permanently, which leaves you with a handy way to test or install linux on any machine as needed.

Copy boot files to the drive

The layout of my flash drive looks like this:





I also have DSL and DSL-n available as boot options, although this requires additional files to be installed in a KNOPPIX directory at the root of the drive.

Set up menu.lst

My menu.lst looks like this:

foreground = ff3366
background = 000066


title  New Debian Install (i386)
kernel /boot/debian-i386/linux root=/dev/ram0 ramdisk_size=12000 video=vesa:ywrap,mtrr vga=788
initrd /boot/debian-i386/initrd.gz

title  New Ubuntu Install (i386)
kernel /boot/ubuntu-i386/linux root=/dev/ram0 ramdisk_size=12000 video=vesa:ywrap,mtrr vga=788
initrd /boot/ubuntu-i386/initrd.gz

title  New Debian Install (amd64)
kernel /boot/debian-amd64/linux root=/dev/ram0 ramdisk_size=12000 video=vesa:ywrap,mtrr vga=788
initrd /boot/debian-amd64/initrd.gz

title  New Ubuntu Install (amd64)
kernel /boot/ubuntu-amd64/linux root=/dev/ram0 ramdisk_size=12000 video=vesa:ywrap,mtrr vga=788
initrd /boot/ubuntu-amd64/initrd.gz

title Memtest86+
kernel /boot/memtest/memtest86+.bin

Note that the root is hd0, because when booting from an external USB hard drive Windows requires the boot drive to be drive C, so most BIOSes will reorder the drives to put a USB drive first. Linux doesn't have any such restriction, but GRUB does all its i/o through the BIOS. If you encounter a BIOS that doesn't work this way, you will need to edit menu.lst or adjust the boot commands interactively after GRUB is loaded but before attempting to boot. Worst-case, you may need to reinstall GRUB on the flash drive (see below).

For the graphical installer, according to the Debian Installer Manual §4.3 it's necessary to pass some extra kernel arguments to set the video mode, as shown above: video=vesa:ywrap,mtrr vga=788

Install GRUB to the MBR

You will need to copy a minimal set of GRUB files to boot/grub/ on the drive, and then run the host-based GRUB (compiled as a Linux utility) to set up the MBR.

Assuming your drive is formatted as FAT16 or FAT32:

cp -p /boot/grub/{stage[12],fat_stage1_5} MY_DISK/boot/grub/

Before installing to the MBR, unmount the device. This can be done conveniently using the Disk Mounter panel applet, or from the command line using sudo umount ....

Now start GRUB with root privileges (so that it can write to the device):

sudo grub

Although re-installing GRUB on a drive that already has GRUB installed is pretty harmless, you probably want to make sure that you are installing to the right place. Since GRUB's device naming is different from that of the host system, you should run a find command to satisfy yourself that you have the right device:

grub> find /boot/grub/stage2

(grub> indicates the GRUB prompt.) This will list all the devices that have a boot/grub/stage2 on them. For example:


The details will vary from system to system, but you should be able to tell which is the USB drive. The number before the comma is the drive, and the number after the comma is the partition. GRUB numbers both from 0, not 1, which is a common cause of mistakes.

To make absolutely sure you have the right device, try to find a file that is on your flash drive and not on your host drive. For example:

grub> find /boot/debian-i386/linux

Installing to the MBR is now a simple matter of using the setup command. Assuming your USB device is (hd1,0):

grub> setup (hd1) (hd1,0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/fat_stage1_5" exists... yes
 Running "embed /boot/grub/fat_stage1_5 (hd1)"...  16 sectors are embedded.
 Running "install /boot/grub/stage1 (hd1) (hd1)1+16 p (hd1,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded

Exit GRUB by typing "quit". You may now reboot and test your flash drive. Hopefully you will see the GRUB menu that is on the flash drive rather than the one from your main system. You can try running one of the installers as far as entering (but not completing!) the disk partitioning stage without affecting your system. (See below for more information.) You can also try running memtest.

Note that it is necessary to remove the USB drive in order to boot normally from the internal hard drive.

PXE boot

Many BIOSes have a PXE boot capability. The BIOS is able to download a netboot kernel and initrd across the network, so that no external media of any kind (such as CD or flash drive) is required. However, PXE requires the presence of a bootp+tftp server to serve up the files.

The BIOS will expect the DHCP server to identify the TFTP server that is to be used for booting. This takes significant work to set up, and may not be possible in network environments that already have a DHCP server, unless you plug the installation machine directly into another Linux machine. It's probably not worth the effort unless you plan to do a lot of installs this way.

The netboot kernel+initrd are the same as the ones used with GRUB as described above, so this is just an alternative way of getting those into memory.

GRUB from a Windows partition

[Under construction]

There is a version of GRUB built as a Windows NT boot loader. It can be installed alongside the regular Windows bootloader without touching the MBR. By adding one line to the system's \boot.ini file GRUB can be made to appear as an additional Windows boot option. Once GRUB is booted, its menu as configured in menu.lst appears. The various files that GRUB needs, such as menu.lst and the linux,initrd.gz combinations, are all stored in a directory on the Windows partition.

This can be used as a way to start a Linux installation without any external media (not even USB flash). However, it can also be used as a permanent way to boot Linux without touching the MBR. GRUB can be disabled at any point simply by removing the extra line from boot.ini. A borrowed computer can temporarily be turned into a dual-boot system by shrinking the Windows partition and installing Linux into a newly-created partition. Later, the Linux partitions can be deleted, the Windows partition expanded back to its original size, and the original boot setup restored by editing boot.ini (and, optionally, deleting the \boot directory used to hold GRUB and the kernel+initrd files).

Note that this method of booting the installer can be used even if the entire hard drive is to be overwritten with Linux, since once the kernel and initrd are loaded into memory no further use is made of the hard drive.

Using the installer

The machine will boot straight into the installer. You are then asked a series of questions about locale, keyboard and mirror location. It's possible to use a local mirror by selecting enter manually from the mirror list. However, this entry is right at the top and will not be obvious if your country is lower down the list.

Here in the Calgary office, our mirror host name is and the directory is either /debian/ or /ubuntu/. The release name is determined internally by the installer, based on the release from which you downloaded it.

After this, and some preliminary downloading, you will be invited to select "tasks". If you want a minimal install, choose "Standard" and nothing else. You can install your chosen desktop environment later using a console login and apt-get install. This allows you to install KDE, XFCE or LXDE without installing GNOME first.