Make Your Own Plug ‘N Play Zone Using Ubuntu Linux! 03/12/08

One of the things I dislike is reinstalling any operating system over, and over, and over again. After a while it becomes boring and inconvenient when you’ve a hot idea you want to try out. One of the things I enjoy doing (and I’ve posted several ideas or projects), is to try out new ways, ideas or Linux packages. Often this means starting from a clean system or I have to reinstall because I made mistakes and trashed an existing system. The point? Well, for one it’s a great learning environment for me, it helps my friends who have switched or considering a switch and it gives me information I can share for free in this blog – And that helps everyone!

Today is not any different, actually I’m pretty excited about this post!!! Here’s the scenario:

1) I wanted an easy way for friends to migrate to Linux (I’m using Ubuntu).

2) Personally, I needed a way that Ubuntu could install itself while I go do something else.

Side note: During today’s project, I realized that this would be a great feature for a school, a computer lab, a computer hobby group and even a business or laptop repair shop. If any of you use this idea, please let me know as I’d love to see! :)

The idea? I created my very own “Ubuntu Linux Plug ‘N Play Zone”!

Ubuntu Linux Plug ‘N Play Zone

It’s a simple 3-step method.

Users plug their laptop into one of the two ports pictured above and boot off the network. Go away, come back later and it’s all done. Voilà :)

Also you can see that they have the option for a Gutsy install (7.10) and soon (I’ve not set that up yet, probably over the weekend) a Hardy install (8.04). The picture above is how I’ll leave the “Zone” for now. (I didn’t want to write on the wall so put an old plastic sign over the plug and wrote on the plastic with a marker. Easy to enhance and change later). How is this done? Ahhh… Not as hard as one might think… Grasshopper.

For this to work properly, we need a DHCP server on a separate network (subnet). We also need a TFTP server and of course client laptops (or PC’s) that can netboot. (Netboot is when the BIOS is configured to boot of the network card). Last year I posted “30 Dollars, 30 Minutes, 1 Nice Fileserver” and that’s the unit I wiped clean and used for this project. We can begin by installing Gutsy (7.10) on the system.

Note: Look further down to the IP addresses. Make note and ensure that your server is using a static IP address within your subnet. The first time I did this I messed up and used the wrong address.

After this, here are the steps I took:

Note: Instead of typing “sudo” all the time, we can “sudo su” (become root) and then don’t have to keep using the sudo command.

The first thing we need to do is grab some packages:

apt-get update
apt-get install dnsmasq atftpd atftp

Dnsmasq is:

Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP server. It is designed to provide DNS and, optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS. The DHCP server integrates with the DNS server and allows machines with DHCP-allocated addresses to appear in the DNS with names configured either in each host or in a central configuration file. Dnsmasq supports static and dynamic DHCP leases and BOOTP/TFTP for network booting of diskless machines.” Source: http://www.thekelleys.org.uk/dnsmasq/doc.html

atftpd is:

A TFTP server. By default it is started by inetd on most sytems, but may run as a stand alone daemon. This server is multi-threaded and supports all options described in RFC2347.” Source: http://www.math.ucla.edu/computing/docindex/atftp-man-2.html

atftp is:

A client/server implementation of the TFTP protocol that implements RFCs 1350, 2090, 2347, 2348, and 2349. The server is multi-threaded and the client presents a friendly interface using libreadline. The current server implementation lacks IPv6 support.” Source: http://freshmeat.net/projects/atftp/

Because the first port is Gutsy (7.10) we need to get the netboot files for it. It’s easy to get via wget like this…

Create a directory if it’s not already there:

cd /var/lib
mkdir /tftpboot

Use wget to download the tarball into /source

cd /var/lib/tftpboot
wget http://archive.ubuntu.com/ubuntu/dists/gutsy/main/installer-i386/current/images/netboot/netboot.tar.gz

Note: For Hardy (8.04) the command is “wget http://archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/netboot/netboot.tar.gz”. But remember, to do this with Hardy (or any other Linux platform), make sure the port is being served by another Dnsmasq on another subnet. If not, then the laptop might get the wrong version of Linux installed.

Now untar:

tar -zxf netboot.tar.gz && chown -R nobody:nobody

The chown directive is saying “Change the ownership of everything recursively to Nobody”.

Now we need to set up the DHCP/DNS configuration (for Dnsmasq). The following information is needed by us:

1) What IP address range to give laptops being plugged into the “Zone”

2) The default gateway (That usually your router, the point for external access to the Internet).

3) The IP address of the server (that’s going to provide Linux to the laptops).

4) The DNS address (should be the same as the server’s address).

After a few tries and a bit of Googling, I found the correct way to do this. (I was putting the wrong numbers in first time around. It was a simply, easy mistake to fix).

Note: The small (cheap) router I used for this defaults to the 192 network, so I just left it at the default. You can change it to match your own subnet!

dhcp-range=192.168.0.150,192.168.0.155,6h
dhcp-boot=pxelinux.0,192.168.0.5
dhcp-option=3,192.168.0.1
dhcp-option=6,192.168.0.1

Here is what the line correspond to:

dhcp-option=6 is the DNS address.

dhcp-option=3 is the default gateway address

dhcp-boot=pxelinux.0 is the IP address of the server

dhcp-range is the pool of IP addresses being leased out to laptops connecting. (Only a very few available as I only have one port per subnet). The 6h means to lease outthe IP addresses for 6 hours.

Now that I finally had the correct addresses configured I can restart like this:

invoke-rc.d dnsmasq restart

After it’s successfully spacerrestarted, make sure the firewall is not blocking. (I didn’t check that and it took me a while and a bit of Googling to find the fix). If your firewall is interfering, you can modify this script to your needs:

#!/bin/bash
# flush all chains
iptables -F
#delete the chains
iptables -X
# set the default policy for each of the pre-defined chains and pipe to /dev/null
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t mangle -F 2>/dev/null
iptables -t mangle -X 2>/dev/null
iptables -t nat -F 2>/dev/null
iptables -t nat -X 2>/dev/null

Original script and idea from http://townx.org/simple_firewall_for_ubuntu_using_iptables via Creative Commons Attribution-Share Alike 3.0 License.

As you can see from the above link, we can further create a customized start/stop feature. After a lot of Googling, I found there are a ton of iptables resources out there!

Now set your laptop (or PC) BIOS to enable booting off the network (PXE). If it works your good to go and your Plug ‘N Play Zone is live! :)

If there is trouble, try the following:

1) Check your /var/log/syslog for issues.

2) Is dnsmasq even listening? (I learned that network boots use bootp through port 67). Is port 67 working? Use this comand:

netstat -nulp | grep '67.*dnsmasq

The response should show udp port 67

Side note: Netstat command are here: http://www.computerhope.com/unix/unetstat.htm

3) What about iptables, are they really turned off?

iptables -L
iptables -L -t nat
iptables -L -t mangle

The first command says “list the active rules”. The second says “list the nat (Network Address Translation) tables and the third says “list the mangle tables”.

Side note: To learn more about iptables and”mangle” read here: http://www.informit.com/articles/article.aspx?p=19626

4) Is atftpd listening on a port? (It’s supposed to be on port 69):

netstat -nulp | grep atftpd

Again, the response should show a udp port and it should be 69.

This was a fun exciting project. Hopefully some of you can use this information to help you. I hope so. As I mentioned, this would be great for schools, a computer lab or lab projects, a computer hobby group and even a business or laptop repair shop. Either way, please let me know.

It’s really cool to just plug and go in the plug and play zone! :)

Update 1: There’s a follow up to this post here: Ubuntu Linux Plug ‘N Play Zone Revisited, where we examine some of the automated installation features via PXELinux and the use of a preseed file to automate the installed environment. That post really helps to round out this hands-on project as a whole. Check it out! :)

Update 2: This post has been featured issue #14 of Full Circle Magazine (The FREE Independent Magazine (and podcast) for the Ubuntu Linux Community)! You can take a look at that issue here: http://fullcirclemagazine.org/2008/06/26/issue-14-is-out/

Care to Share?


You can leave a response, or trackback from your own site.

23 Responses to this article

 
Jann March 12, 2008 Reply

Thanks this is great! We can use this as a drop off for Linux migration. Nice idea and thanks for sharing the information.

 
Martin Fitzpatrick March 13, 2008 Reply

This is a really neat idea. Seriously :) A lot of lugs/etc. would love something like this to help with getting new users on the go.

It plays on one of the biggest benefits of Linux: it’s free (in every sense) to give away. You could put one of these boxes anywhere and it wouldn’t matter.

How “big” is the equipment to do this and do you think it would be feasible to shrink it down onto a mini-pc (ITX size for instance)?

BootBox.

I’m drooling ;)

 
 
UbuntuLinuxHelp March 14, 2008 Reply

@Martin Fitzpatrick – Thanks for the feedback! You sure can put this on a smaller box (ITX), even on an older laptop, tucked away somewhere. If someone wants to get really “snazzy” (there’s a word I’ve not heard in a while), they could install 4 network cards in a box and have each card porting a different “Plug ‘N Play Zone” flavour! :) Even different distributions! Fedora and so on…

i’m in ur bootbox servin ur zones :)

I’d like to build further on this idea, including other apps, different builds, etc…

I looked at your blog, very practical – Nice!
I liked the “Throttle” project here: http://www.mutube.com/projects/throttle/ :)
Cheers!

 
Fr33d0m March 14, 2008 Reply

An NSLU2 running slugOS, an external drive and a small router could make this quite portable.

 
 
UbuntuLinuxHelp March 14, 2008 Reply

For readers not familiar with slug, check them out here: http://www.nslu2-linux.org/wiki/SlugOS/HomePage
Very effective! There are even recipe pages here: http://www.nslu2-linux.org/wiki/HowTo/HomePage That’s sweet! :)

Wow! Look at this page everyone!! =:) Very nice! http://www.nslu2-linux.org/wiki/Applications/HomePage

 
Anoj March 21, 2008 Reply

awesome tip. I was planning to start a similar remote auto installation in my university.

 
 
UbuntuLinuxHelp March 22, 2008 Reply

@Anoj – Glad I could make someone smile! :) If you are able to do this at your university, I think all the readers here would enjoy a follow up with a photo or two. It would be great to have a link to you in the follow-up post.

On a personal note, I spent much of my childhood in the Far East. Singapore and then Kuala Lumpur, so was nice to see I have readers in the Far East.

 
Stephan March 23, 2008 Reply

This should be expanded into a customizable drop-off zone.
You don’t boot into the installer, but rather into a live system that can be customized any way the provider wishes. You could have a shiny menu that provides access to OS installs, media, you name it.

It’s a very cool idea. Kudos!

 
 
UbuntuLinuxHelp March 24, 2008 Reply

@Stephan – Now you’re talking. Yes! Yes! Yes! We’ll call it “Zone Linux”. :) Way cool! :)

 
Brian March 28, 2008 Reply

I think that it would be cool to expand on the mini itx idea a little bit. Mod a hub by installing a mini itx system in it, and then set it up somewhere so that the entire hub can be used for installing linux.

 
gnu April 2, 2008 Reply

1) I plugged in my laptop
2) I booted off the network
3) I came back later

the laptop was gone

 
 
UbuntuLinuxHelp April 2, 2008 Reply

@gnu – Very funny sense of humor! :) :p
Everyone, remember to secure your laptops to the plug ‘n play zone with a heavy chain!

 
JohnP April 2, 2008 Reply

#4 the laptop was gone. hee hee hee. Maybe you should add handle bars to the zone.

While the comment from gnu has some amusement. He has made a valid point! Have a metal handrail beside the zone so laptops can be secured. This is very important if there is no monitoring. We used your idea and it’s working nicely, but there’s always someone there to make sure nothing walks away.

 
 
UbuntuLinuxHelp April 2, 2008 Reply

@JohnP – I agree, gnu did raise an important issue! It’s one thing to have this in an area where people are watching what’s going on, quite another in an area that is not secure!! In addition to the “bar” suggestion, maybe it’s a good idea to put this in a locked room (in areas where security would be a concern).

 
Matt April 4, 2008 Reply

This will replace whatever O/S is on the laptop am I correct in assuming this?

Is it then possible to have a live cd setup so that we can provide a lab for people to come in, customized with some apps that we want setup for them so they can bring their machine, plug it in, get the live cd install, we can teach them, and they then restart and their xp image is back?

 
 
UbuntuLinuxHelp April 4, 2008 Reply

@Matt – Yes. Plug it in and (network) boot off it. Whatever software is on that laptop is gone – Permanently.

A liveCD is something altogether different. LiveCD is an actual CD, and the laptop (or PC) boots off that physical CD. It does NOT work with the Plug N’ Play Zone. The “Plug N’ Play Zone” will remove any existing software off the hard drive and replace it with Ubuntu Linux (or whatever other Linux distribution you choose). That software will be lost unless the existing drive is imaged prior to being erased. This does open up the opportunity for users to complain if something does not work when the get their original system back. Granted, if their HDD was properly imaged, they will get the identical image returned. But there are often a few who just don’t understand and then complain or complain because they think something might be wrong.

One way you can use a similar idea for teaching is to use a Linux terminal server. In this scenario it does not matter what OS is on the students laptop. They can have a virtual client installed which lets them connect (log into) the terminal server. Then they can run commands, install applications and learn about Linux. When they are done, they simply log off and go about their day (without ever having to replace any OS on their laptops!)

I posted a Media based terminal server project for Freevo and MythTV users here: http://ubuntulinuxhelp.com/creating-a-linux-terminal-media-server-for-your-home-pcs/ We could take the same principles and adapt them to your “lab” needs instead. Albeit, I’d probably provide a different project guide for that (because you would not need all the media fluff).

Let me know if you have any more questions about this.

 
UbuntuLinuxHelp April 4, 2008 Reply

@Matt – Oh wait… I just thought of something why not use VMware? That might be another good idea. If you’re not familiar with it, I have a post in the “Linux Projects – Hands On” category here: http://ubuntulinuxhelp.com/how-to-install-vmware-in-ubuntu-linux/

 
Abdreas April 4, 2008 Reply

Great autoinstalltion :)
Like the idea with “… just plugin dirnk a coffe and eh voilla” :D

 
 
UbuntuLinuxHelp April 6, 2008 Reply

@Abreas – Thanks for the comment. There has been a lot of interest. Perhaps this spring or summer, I may develop the same idea with customized applications. Or perhaps a server with multiple distributions.

Vielen Dank für den Kommentar. Es hat ein sehr großes Interesse. Vielleicht in diesem Frühjahr oder Sommer, kann ich entwickeln, die gleiche Idee mit kundenspezifischen Anwendungen. Oder vielleicht ein Server mit mehreren Distributionen.

 
Daeng Bo April 14, 2008 Reply

This is a nice howto, but I’m a little confused on one point. It may have to do with me not actually doing the steps … but I have used netboot images before, both on Ubuntu and on Debian.

My problem is that the netboot images I’ve always used just launched an installer. I know you can kickstart autoinstall, but I don’t see that step here. Has netboot changed in the last year, or am I missing something?

Signed,
Confused in Korea ;)

 
UbuntuLinuxHelp April 15, 2008 Reply

@Daeng Bo – Here however, the laptops in this case would use the PXELinux boot loader. (Much in the same way as netboot).
PXE boot would be set up on the TFTP server (using the netboot.tar.gz files from Ubuntu repositoiries via wget).
If PXELinux cannot find a configuration file (pxelinux.cfg – remember the MAC address is included in the config file), then it will fall back to a default config that will load a default kernel.
Additionally, to avoid the “prompts” (language, timezone, etc.) you could use a preseed file. To instruct the server to get the preseed file, you’d create an entry in the …/pxelinux.cfg/default that points to the preseed file.

This post was just to show the idea, I can at a later date provide some actual configuration of PXELinux information.
Hope this brief blurb helps you. :)

 
Sam May 11, 2008 Reply

Nice idea! I think it’d be nice to do this but mix it up a bit. That is, add a bootloader to install various OSs over the network. I’d set mine up for Ubuntu, Debian, Arch Base, Arch + Gnome, Arch + KDE, Arch + XFCE, and Fedora.

It’s easy to see that I like Arch.

 
 
UbuntuLinuxHelp May 13, 2008 Reply

@Sam – Thanks, I agree, it’s good to mix and ad more OS’s in. ;) Did you get a chance to read the follow-up, part 2 of this post? It’s here: http://ubuntulinuxhelp.com/ubuntu-linux-plug-n-play-zone-revisited/

Leave a Reply

close comment popup

Leave A Reply