This mini project took a USB hard drive, made it bootable, and then used it as a disk cloning network. It’s worked very well.
A few years back, making a bootable usb was the popular thing, so you could take your apps and environment with you to any computer. This project is inspired by that work.
The OS I’m using is Ubuntu Server 12.04 LTS. The boot disk burns onto a CD, and is around 700MB.
First, remove the internal hard drive from the laptop or desktop machine. This avoids the problem of accidentally writing to the disk (because the installer tends to favor writing to the first disk). See this article for more details.
The USB disk showed up as /dev/sda, much to my surprise. You might think this would be a problem, if the internal hard disk gets assigned to /dev/sda, but the new Ubuntu uses disk UUIDs to mount partiitons, so it’s OK. Look in /etc/fstab to see what I mean.
The disk is divided into three partitions:
/dev/sda1 - 8G partition for the OS. (Might make it larger to have a GUI on the server.) /dev/sda2 - 2G partition for swap. Everything else is for storing images.
During the install, I set up the networking to use DHCP. This will be changed later, but we need to use the LAN for now. Also, I used the username “zero” and called the computer “drbl”. The computer must be named “drbl” because the Clonezilla system assumes that’s the name of the server. You’ll want to stick with the default network addresses: 192.168.1.1, or something in the 192.168.*.* network. I tried using other values, and hit a lot of glitches.
Disable auto-update. The DRBL system builds on top of Ubuntu, so upgrading seems to require some uninstalling then reinstalling.
Where you install the GRUB bootloader depends on how automatic you want the booting to be. If you want it to always boot off the external USB disk, if possible, then write it to the MBR of /dev/sda (the default location, the external disk).
If you want to force yourself to hit the “boot menu” key, and then select the USB device, install the GRUB bootloader into /dev/sda1. If this turns out not to work, you can use debconf to write the bootloader to the MBR.
The default networking generally works OK, especially if you just have one server and one network card. If you have two network cards, and want to replicate your server, then the specific names of the network interfaces matters. If you have Intel network hardware, you probably want that inteface to feed the cloning network, because it has bigger buffers. If you have a Realtek/DEC Tulip type card, you can use that for the Internet.
In my setup, I want the laptop’s main interface to feed the cloning network. An extra ethernet interface, either via a PC Card or USB, will be the internet.
Generally, I want eth0 to be on the cloning network, and eth1 to do the internet. How do we force this?
Well, first off, you should boot once with all the intefaces up. Then, go to /etc/udev/rules.d, and read the files. Additional instructions are here at Banym’s blog.
The cloning network should use a static address, and the Internet side should use DHCP to get an IP address from the network.
I had some problems with one interface losing it’s IP address, necessitating a ifdown eth0 ; ifup eth0. I think that preventing network-manager from starting may have fixed this problem. This is on an Ubuntu system with upstart. The way to stop running that service is to: echo manual > /etc/init/network-manager.override. Then “stop network-manager”. (Do all this as root.)
In my plans, I’m thinking of adding a third network card to create an “image saving” network that would allow for images to be uploaded simultaneously as other computers were being cloned.
Go to Clonezilla SE and read it, then click on the DRBL link to find the DRBL installation instructions, and read them. Then alter your /etc/apt/sources.list file by adding the lines they specify. I added these:
deb http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse deb http://drbl.sourceforge.net/drbl... drbl stable
Then issue one these commands, depending on what you prefer
wget -q http://drbl.org/GPG-KEY-DRBL -O- | sudo apt-key add - curl http://drbl.org/GPG-KEY-DRBL | sudo apt-key add -
Then these two commands to install the system.
apt-get update apt-get install drbl
Now get into drbl. First run the server setup command:
This will install a bunch of software. It takes a while.
When you’re offered kernels, pick the one that looks generic and would run on older computers like the 386.
If you want to accept the defaults, run:
Or if you want to congfigure it interactively:
You might want to add /opt/drbl/sbin to your path, so add this line to your .profile or .bashrc:
If your system does /etc/profile.d/ scripts, you can make a script with that line above.
Adding a Storage Partition
Use Fdisk or Parted to create a new partition in the empty space. When I did this, I had to double check the /dev/sd* devices. It turns out the external disk was now at /dev/sdb.
Set the partition type to Linux, and create an ext2, ext3, or ext4 filesystem. I just did one with ext4, and it seems slower than ext2 (which lacks journalling). So maybe ext2 is better for this.
Clonezilla uses single file disk images. These are then split up by Clonezilla during delivery.
Go into your BIOS setup and set the boot order to: External USB, CD/DVD, and Internal HDD. This will cause the system to boot from the USB drive. At this point you can re-install the internal HDD and boot from that too.
Running from a USB hard drive will be slower than running from an internal hard drive. While this may sound bad – remember that you cannot really run your multicaster any faster than the slowest hard disk on your LAN.
Run “dcs” and you’ll see a menu to set up the boot mode. Clonezilla can boot the workstations in many different ways, ranging from netbooting into a workstation to booting into Clonezilla.
How Clonezilla Works
DRBL is a system that allows computers on a LAN to boot from a central server into Linux (or any disk image really). The system delivers a small boot image, SYSLINUX, which then mounts shared directories, and then initiates a complete Linux boot. At the very end of that process, it mounts personal shared directories for /etc /home and other directories. These shared directories are all in /tftpboot/ on the server.
(They aren’t all delivered by tftp. Most are mounted via NFS. See /etc/exports for a list of shared directories.)
Once it’s done, you’re booted into a Linux environment. Clonezilla is a specialized Linux environment that allows you to copy images up to the server, or receive images from the server. The whole process is controlled from the server, not at the client.
When you run Clonezilla to save a partition to the server, what it does is configure netbooting with a client environment that will copy the partition up. When you boot one client machine to clone it, it boots into this client environment and starts the copy.
When you set up Clonzilla to multicast this saved partition, the computers netboot a slightly different client environment that restores the data from the image file.
I had all kinds of problems cloning Windows 7, mainly because I was trying to restore a partition. Bad idea. All the success stories involve restoring the entire disk. The Win7 focused tutorial also seem to use the “beginner” mode rather than the advanced (though the answers from experts seem to run in the advanced mode more often).