In this tutorial I describe how to build a (local) network server using a customized debian-live system. I wrote a first draft in my blog but I'm going to explain it here in more detail.
The objective is to build an image of approximately 200MB.
The resulting image can be copied onto a USB flash drive and can boot from it using persistence. You can read about that procedure in Tutorial 1
FOREWORD: The tools used in this tutorial are provided by the official project Debian-live. For more information I recommend installing their live-manual package:
# apt-get install live-manual
or alternatively read it online here
ACKNOWLEDGEMENT: Having read the entire manual does not mean that I know how to configure/use everything in detail. debian-live tools is a big puzzle made of smaller pieces. Putting them all together takes patience and time. I'm learning real fast though.
In order to succeed building my live-system I requested help from the debian-live team on irc. Thank you very much guys. (Especially SynrG for his invaluable help and patience)
Reasons for building a live-server.
You can test hardware and connectivity before installing anything.
You can easily substitute the operating system in case things break badly. (As easy as unplugging-plugging a new usb device)
It is really fun building your own system. Even more so if you have a special use for it.
In order to follow this tutorial you need:
A basic knowledge of the command line.
A linux distro where you can install the debian-live tools (live-build, live-config, live-boot...) I recommend Debian.
A USB flash drive. The resulting image has ~200MB (512MB is enough!!! It even leaves free space for persistence. I use a pendrive of 1GB)
Let's get down to work
1.Create a working directory and cd into it.
$ mkdir live-server && cd live-server
(That one was easy huh?)
2.Launch lb config with all the necessary options.
- We are interested in a usb-hdd image for a usb flash drive. (Iso-hybrid images can be used as well but they do not allow you (as of now) to use the free space for persistence. So:
-b usb-hdd (-b stands for --binary-images You can choose between: iso,iso-hybrid, net, tar or usb-hdd)
- We want to specify a list of packages to be installed. The cornerstone of a server. Thus:
--packages "apache2 proftpd--basic telnetd"
- That was the initial package selection because I wanted to manually add others, later on I realised that it would be very convenient to add/remove some packages from my initial config:
--packages "apache2 proftpd-basic ssh screen irssi elinks mc nfs-kernel-server"
Networking: The server is going to be up 24/7 so it is not really important to change the default dhcp. However, some may prefer setting a static ip. And in the case of a power outage or occasional reboot, we want the server to boot in live persistent mode and that it does not prompt the user to remove the usb flash drive and press enter before rebooting. This can be achieved like this: --bootappend-live "persistent ip=eth0:192.168.2.40:255.255.255.0:192.168.2.1 noprompt" --syslinux-timeout 5
We can't forget other important customization features provided by live-config like locales, keyboard-layout, hostname, username...The list is very long here. Read live-config man page. I only used three:
-Keyboard: because I'm used to it
-Hostname: because I must follow my very own naming convention
-Username: because I'm very conceited
keyboard-layouts=es hostname=jeremy username=chals
- Adding a splash screen. Here (instead of using --syslinux-splash) I devised a cheap trick. After some trial and error I edited by hand /live-server/config/binary to include a personal splash screen 640x480. On a daily basis I will not see it because this is a headless server, but it is very nice to show it to your friends.
So the final line would look similar to this one:
lb config -b usb-hdd --packages "apache2 proftpd-basic ssh screen irssi elinks mc nfs-kernel-server" --bootappend-live "persistent ip=eth0:192.168.2.40:255.255.255.0:192.168.2.1 noprompt keyboard-layouts=es hostname=jeremy username=chals" --syslinux-timeout 5
Let's build it
As superuser simply type:
# lb build 2>&1 | tee binary.log
This results in a binary.img file of appoximately 200MB ready to be copied to a USB flash drive as described in Tutorial 1
You can also try it beforehand using virtualization. With qemu:
$ qemu -hda binary.img
Enjoy your new toy!!!