A fusion of technology, music, and geekyness.

Linux Disk Imaging with Clonezilla and PXE

Now that I finally have a file server at home I got curious again with disk imaging solutions. After doing some research I found a pretty awesome tool called Clonezilla. After downloading the live CD and playing around for a while the first thing I wanted to do was test it out in a PXE boot fashion. Here was my quick and hackish approach. My test run was on a VirtualBox VM in Xubuntu 10.04 with a bridged adapter.

1. Install TFTP server

sudo apt-get install tftpd-hpa
sudo start tftpd-hpa

Ensure /var/lib/tftpboot exists. If it does not:

mkdir -p /var/lib/tftpboot

Ensure that the values in /etc/defaults/tftpd-hpa match.

2. Install DHCP server

sudo apt-get install dhcp3-server
sudo vim /etc/dhcp3/dhcpd.conf

Add something similar to the following…

default-lease-time 86400;
max-lease-time 604800;
authoritative;

subnet 192.168.1.0 netmask 255.255.255.0 {
        range 192.168.1.10 192.168.1.15;
        filename "pxelinux.0";
        next-server 192.168.1.121;
        option subnet-mask 255.255.255.0;
        option broadcast-address 192.168.1.255;
        option routers 192.168.1.1;
}
sudo service dhcp3-server start

The next-server option needs to be the IP of the TFTP server. Everything else should be self explanatory.

Before proceeding verify both services are listening.

sudo netstat -upan | awk  '{print $6}' 
2008/dhcpd3
582/dhclient
3627/in.tftpd

3. Install syslinux if it is not already (it should be). Copy over pxelinux.0 into the appropriate location.

sudo apt-get install syslinux
sudo cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot

4. Download latest clonezilla zip from SourceForge.

sudo unzip clonezilla-live-*.zip
sudo cp live/vmlinuz /var/lib/tftpboot/
sudo cp live/initrd.img /var/lib/tftpboot/
sudo cp live/filesystem.squashfs /var/lib/tftpboot/
cd /var/lib/tftpboot
sudo touch boot.txt
sudo mkdir pxelinux.cfg
sudo touch pxelinux.cfg/default

Your tree should end up looking something like this in the end:

├── boot.txt
├── filesystem.squashfs
├── initrd.img
├── pxelinux.0
├── pxelinux.cfg
│   └── default
└── vmlinuz

5. Create configs

sudo vim boot.txt

I made my menu look something like the following…





========================================================================

 .d8888b.  888                                    d8b 888 888          
d88P  Y88b 888                                    Y8P 888 888          
888    888 888                                        888 888          
888        888  .d88b.  88888b.   .d88b. 88888888 888 888 888  8888b.  
888        888 d88""88b 888 "88b d8P  Y8b   d88P  888 888 888     "88b 
888    888 888 888  888 888  888 88888888  d88P   888 888 888 .d888888 
Y88b  d88P 888 Y88..88P 888  888 Y8b.     d88P    888 888 888 888  888 
 "Y8888P"  888  "Y88P"  888  888  "Y8888 88888888 888 888 888 "Y888888 

======== Boot Options: ================================================

>> clonezilla ......... Regular Boot
>> clonezilla_safe .... Failsafe Mode

=======================================================================

And finally the pxe config…

sudo vim pxelinux.cfg/default

Looked something like this:

DISPLAY boot.txt

LABEL clonezilla
	kernel vmlinuz
	append initrd=initrd.img boot=live union=aufs noswap noprompt vga=788 fetch=tftp://192.168.1.121/filesystem.squashfs

LABEL clonezilla_safe
	kernel vmlinuz
	append initrd=initrd.img boot=live union=aufs noswap noprompt vga=normal nomodeset nosplash fetch=tftp://192.168.1.121/filesystem.squashfs

PROMPT 1
TIMEOUT 0

Please note that the IP address should be the IP of the TFTP server!

Now testing with a Dell Latitude E6410 I hit F12 on the BIOS screen, Select Network Adapter, and SUCCESS! You should see your boot.txt with a “boot:” prompt. Please share your experiences and alternative implementations on how you solved this issue. I would love to hear them!

My Test results:
250 GB (239.9 GB after formatting)
67.7 GB in use
175.2 GB free
Transfer Rate: Started at 900 MB/min at first, peaked at 1.91 GB/min, ended at 1.72GB/min, average 1.7 GB/min
Time elapsed: 37 minutes, 41 seconds

9 Responses to “Linux Disk Imaging with Clonezilla and PXE”

  1. gfurg says:

    Check out the Fog Project. http://fogproject.org

    They have a web interface, lots of tools, and it does pxe imaging as well. Setup is pretty straight forward as well.

  2. BT says:

    I’ve been using Fog to image Dell D610′s and D620′s with great success, but Now I have 5 E6410′s with Win 7 Pro to image and fog is not working – boots pxe ok, but doesnt let the PC send its config or register – it just scrolls off the screen. A network test for fog compatibility fails. Clonezilla works, but somehow kludged up with duplicate system names and I had to wipe them and re-install from scratch. I’d love to hear how someone got them working on a fog solution – FOG is awesome but stuff like this drives me NUTS!

  3. BOB says:

    I tried as you mentioned. Bu I am facing some issues. Clonezilla asks me to login. What is the username password to use.
    Thanks

  4. phydo says:

    BT, how did you configure your Latitude D610′s to boot on the network? I’m having trouble getting them to PXE boot.

  5. jesse says:

    I no longer have this machine but I remember having to change some settings in the BIOS config. After than, hitting one of the FXX keys during boot would give you a boot menu and you could select network / pxe. I hope this helps!

  6. dmaster97 says:

    thank you man.
    i had my head spinning arround for clonezilla setup in pxe mode.
    the doc in clonezilla should have been replaced with your guide. it just make me scratch my head over an over again.

    you really saved my day.

    thanks alot.

  7. Tyler Rusk says:

    Hey guys. I was having the same problem others were having with the pxe boot asking for a login username and password. The pxe.cfg/default needs to be changed so boot=live config :

    DISPLAY boot.txt

    LABEL clonezilla
    kernel vmlinuz
    append initrd=initrd.img boot=live config union=aufs noswap noprompt vga=788 fetch=tftp://192.168.1.121/filesystem.squashfs

    LABEL clonezilla_safe
    kernel vmlinuz
    append initrd=initrd.img boot=live config union=aufs noswap noprompt vga=normal nomodeset nosplash fetch=tftp://192.168.1.121/filesystem.squashfs

    PROMPT 1
    TIMEOUT 0

  8. tdrusk says:

    Thanks so much for this. It really helped me and is saving me a ton of time.

  9. sapnwnewbir says:

    Can I use an external HD with other data already on it and clone the installed os. Also, would the size difference in ext HDD and the new HDD matter.

Leave a Reply

Powered by Wordpress | Designed by Elegant Themes