Posts Tagged ‘deploy’


HowTo: Clonezilla & PXE on Gentoo

Thursday, January 7, 2010
posted by otioti

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:

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:

default-lease-time 600;
max-lease-time 7200;
ddns-update-style interim;
allow booting;
allow bootp;
option domain-name "";
option subnet-mask;
option broadcast-address;
option domain-name-servers;
option routers;
subnet netmask {
   option broadcast-address;
   option netbios-name-servers;
   option routers        ;
   # For bootp - pxe clients
   range dynamic-bootp;
   filename "/pxelinux.0";

For example, i configured my dhcp service next way:

  1. All my clients get dynamic IP from to
  2. My gateway will be the same server,
  3. Configure PXE:
    1. range dynamic-bootp: We’ll give from to for all PXE clients.
    2. next-server: IP of server which have kernel images and tftp service, router
    3. 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!

# 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

# 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 **********************************************

# Do NOT allow client to edit the parameters

# simple menu title

label clonezilla
  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 LABEL Local operating system (if available)
  # 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
  Boot local OS from first hard disk if it's available

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

Uso de cookies

Este sitio web utiliza cookies para que usted tenga la mejor experiencia de usuario. Si continĂșa navegando estĂĄ dando su consentimiento para la aceptaciĂłn de las mencionadas cookies y la aceptaciĂłn de nuestra polĂ­tica de cookies, pinche el enlace para mayor informaciĂłn. ACEPTAR

Aviso de cookies