Booting Linux from HTTP

I’ve learned how to boot a host and load the Fedora installer directly from HTTP. This has enabled me to install Fedora in a VPS which didn’t have the Fedora ISOs available and I cannot upload any other. All of this thanks to the virtual ethernet card and its gPXE firmware.

To accomplish this goal, you need a HTTP server like Apache somewhere. In that server, I’ve create the following directory tree inside /var/www/html

boot
├── f21
├── pxelinux.cfg
├── syslinux -> .
└── uefi

Inside the directory boot itself, I’ve copied all the contents of the /tftpboot directory (package syslinux-tftpboot) and also I’ve created two scripts fedora.gpxe and fedora-uefi.gpxe

fedora.gpxe:

#!gpxe
set 209:string boot/pxelinux.cfg/default
set 210:string http://foo.example.com/
chain ${210:string}boot/lpxelinux.0

fedora-uefi.gpxe:

#!gpxe
set 209:string boot/pxelinux.cfg/uefi
set 210:string http://foo.example.com/
chain ${210:string}boot/lpxelinux.0

Each subdirectory contains:

f21:

  initrd.img
  vmlinux

The kernel and the ramdisk. These are copied from https://dl.fedoraproject.org/pub/fedora/linux/releases/21/Server/x86_64/os/images/pxeboot/

pxelinux.cfg:

  default
  uefi

These are the grub menus. default has the following configuration:

default vesamenu.c32
prompt 1
timeout 600

label linux
  menu label ^Install Fedora 21 64-bit
  menu default
  kernel boot/f21/vmlinuz
  append initrd=boot/f21/initrd.img inst.repo=http://download.fedoraproject.org/pub/fedora/linux/releases/21/Server/x86_64/os/ ip=dhcp

label server
  menu label ^Install Fedora 21 Server
  menu default
  kernel boot/f21/vmlinuz
  append initrd=boot/f21/initrd.img inst.repo=http://download.fedoraproject.org/pub/fedora/linux/releases/21/Server/x86_64/os/ ip=dhcp ks=https://git.fedorahosted.org/cgit/spin-kickstarts.git/plain/fedora-install-server.ks?h=f21

label rescue
  menu label ^Rescue installed system
  kernel boot/f21/vmlinuz
  append initrd=boot/f21/initrd.img ip=dhcp root=live:http://download.fedoraproject.org/pub/fedora/linux/releases/21/Server/x86_64/os/LiveOS/squashfs.img rescue
  
label local
  menu label Boot from ^local drive
  localboot 0xffff

And this is the content of uefi:

function load_video {
 insmod efi_gop
 insmod efi_uga
 insmod video_bochs
 insmod video_cirrus
 insmod all_video
 }

load_video
set gfxpayload=keep
insmod gzio

menuentry 'Install Fedora 64-bit' --class fedora --class gnu-linux --class gnu --class os {
 linuxefi boot/f21/vmlinuz ip=dhcp inst.repo=http://download.fedoraproject.org/pub/fedora/linux/releases/21/Server/x86_64/os/
 initrdefi boot/f21/initrd.img
 }
 
menuentry 'Install Fedora 21 Server' --class fedora --class gnu-linux --class gnu --class os {
 kernel boot/f21/vmlinuz
 append initrd=boot/f21/initrd.img inst.repo=http://download.fedoraproject.org/pub/fedora/linux/releases/21/Server/x86_64/os/ ip=dhcp ks=https://git.fedorahosted.org/cgit/spin-kickstarts.git/plain/fedora-install-server.ks?h=f21
 }

menuentry 'Rescue installed system' --class fedora --class gnu-linux --class gnu --class os {
 kernel boot/f21/vmlinuz
 append initrd=boot/initrd.img root=live:http://download.fedoraproject.org/pub/fedora/linux/releases/21/Server/x86_64/os/LiveOS/squashfs.img rescue
 }

syslinux:

This is a symbolic link to “.“, it’s needed because pxelinux was searching several files there.

uefi:

  grubx64.efi
  shim.efi

Copied from the grub2-efi and shim packages

This is enough in the server side. At the client, I had to enter in the gPXE firmware by pressing CTRL-B after the BIOS. Once you are in the prompt, you have to configure the network card and load the scripts created on the web server.

> dhcp net0
> chain http://foo.example.com/boot/fedora.gpxe

And that’s it! this setup is amazingly powerful to install your servers creating your own kickstart files or for creating thin clients with their root filesystem mounted over NFS.

You could obtain more documentation at:

http://etherboot.org/wiki/httpboot

https://docs.fedoraproject.org/en-US/Fedora/21/html/Installation_Guide/chap-pxe-server-setup.html

http://www.syslinux.org/wiki/index.php/PXELINUX

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s