Posts Tagged ‘clonezilla’
Clonezilla is for me the best cloning HD opensource project I know. It’s similar to Norton Ghost, but Clonezilla is free. We could use clonezilla two ways: Clonezilla LiveCD y Clonezilla Server Edition.
Clonezilla LiveCD let us create image partitions or whole hard disk and save it on another directory using Samba, ssh or nfs. Also, we could clone from disk to disk.
Clonezilla LiveCD let us install Clonezilla as a service in our network. Problem? Clonezilla only works on Debian, CentOS, Fedora, Red Hat or Ubuntu. Gentoo not supported. And i don’t want to reinstall my server-router-firewall 🙂
So, my idea is install a TFTP service in that server, copy kernel, initrd and filesystem images from LiveCD to tftp directory and configure a PXE service using TFTP
Ok, let’s go. First, download Clonezilla LiveCD: http://clonezilla.org/download/sourceforge/
Mount ISO:
mount -o loop /home/user/clonezilla-livecd.iso /mnt/cdrom
We need to install DHCP and TFTP Services:
# emerge -v dhcp tftp-hpa syslinux
Next, we’ve cofigure DHCP server:
authoritative;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style interim;
allow booting;
allow bootp;
option domain-name "yourcompany.net";
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option domain-name-servers 192.168.1.1;
option routers 192.168.1.1;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option broadcast-address 192.168.1.255;
option netbios-name-servers 192.168.1.10;
option routers 192.168.1.1;
# For bootp - pxe clients
range dynamic-bootp 192.168.1.201 192.168.1.230;
next-server 192.168.1.1;
filename "/pxelinux.0";
}
For example, i configured my dhcp service next way:
- All my clients get dynamic IP from 192.168.1.100 to 192.168.1.200
- My gateway will be the same server, 192.168.1.1
- Configure PXE:
- range dynamic-bootp: We’ll give from 192.168.1.201 to 192.168.1.230 for all PXE clients.
- next-server: IP of server which have kernel images and tftp service, router
- filename: Path to PXE Loader, / by default.
Next, let’s configure tftpd service. First, edit /etc/conf.d/in.tftpd:
# /etc/init.d/in.tftpd # Path to server files from # Depending on your application you may have to change this. # This is commented out to force you to look at the file! INTFTPD_PATH="/images" INTFTPD_USER="nobody" # For more options, see in.tftpd(8) # -R 4096:32767 solves problems with ARC firmware, and obsoletes # the /proc/sys/net/ipv4/ip_local_port_range hack. # -s causes $INTFTPD_PATH to be the root of the TFTP tree. # -l is passed by the init script in addition to these options. INTFTPD_OPTS="-u ${INTFTPD_USER} -l -vvvvvv -p -c -s ${INTFTPD_PATH}"
Next, create /images directory:
mkdir -p /images
So next, copy pxelinux.0 loader from syslinux package.
cp /usr/lib/syslinux/pxelinux.0 /images/
Create /images/pxelinux.cfg directory.
mkdir /images/pxelinux.cfg
chown nobody:nobody /images
Edit default configuration to load kernel and parameters. We could copy file from Clonezilla LiveCD, /isolinux/isolinux.cfg, but next you’ll see a simple configuration example, and it’s OK for starting:
vim /images/boot/pxelinux.cfg/default default local timeout 70 prompt 0 noescape 1 MENU MARGIN 5 MENU BACKGROUND bg.png # Set the color for unselected menu item and timout message MENU COLOR UNSEL 7;32;41 #c0000090 #00000000 MENU COLOR TIMEOUT_MSG 7;32;41 #c0000090 #00000000 MENU COLOR TIMEOUT 7;32;41 #c0000090 #00000000 MENU COLOR HELP 7;32;41 #c0000090 #00000000 say ********************************************** say Welcome to Clonezilla. say www.yourcompany.net say ********************************************** # Do NOT allow client to edit the parameters #ALLOWOPTIONS 0 # simple menu title MENU TITLE YOUR_COMPANY_NAME (http://www.yourcompany.net) label clonezilla MENU DEFAULT MENU LABEL Clonezilla live kernel vmlinuz append initrd=initrd.img boot=live union=aufs fetch=tftp://tftp_server_ip/filesystem.squashfs vga=791 noswap noprompt ocs_lang=en_US.UTF-8 ocs_live_keymap=NONE label local # MENU DEFAULT MENU HIDE MENU LABEL Local operating system (if available) # MENU PASSWD # 2 method to boot local device: # (1) For localboot 0, it is decided by boot order in BIOS, so uncomment the follow 1 line if you want this method: # localboot 0 # (2) For chain.c32, you can assign the boot device. # Ref: extlinux.doc from syslinux # Syntax: APPEND [hd|fd] [] # [] is optional. # Ex: # Second partition (2) on the first hard disk (hd0); # Linux would *typically* call this /dev/hda2 or /dev/sda2, then it's "APPEND hd0 2" # kernel chain.c32 append hd0 TEXT HELP Boot local OS from first hard disk if it's available ENDTEXT
Next, we need copy kernel, initramfs filesystem images from LiveCD to /images/ on our server:
cp /mnt/cdrom/live/vmlinuz /images/vmlinuz cp /mnt/cdrom/live/initrd.img /images/initrd.img cp /mnt/cdrom/live/filesystem.squashfs /images/filesystem.squashfs
Last, run services:
/etc/init.d/in.tftp start /etc/init.d/dhcp start rc-update add in.tftp default rc-update add dhcp default