sobota, 10 października 2015

Run clonezilla live from hd

Clonezilla server is a very useful tool when you need to create and restore operating systems often but for home setups it is a bit too much.
Thats when clonezilla live come into play, of course you can make a pendrive with it or burn it on cd but I often want to make backup and not have to download iso and burn it.
I have decided to make bootable clonezilla live so each time I boot up my laptop I have choice of making backup with clonezilla.
The method I have decided to use is mounting iso image placed in /boot/clonezilla directory.

Prerequsities:
Download iso for your architecture (in most of cases it is amd64 - works as well for intel 64 processors).

Create directory:
mkdir /boot/clonezilla

Move iso image to /boot/clonezilla
mv clonezilla-live-2.4.2-32-amd64.iso /boot/clonezilla

Copy part of your /boot/grub2/grub.cfg
In my case it was

menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-amd64' --class debian --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set a9b0693b-85e9-4cd9-941d-6192145ee0f2
echo 'Loading Linux 2.6.32-5-amd64 ...'
linux /vmlinuz-2.6.32-5-amd64 root=UUID=eec16201-b3de-4f50-8536-930ec2f78152 ro quiet
echo 'Loading initial ramdisk ...'
initrd /initrd.img-2.6.32-5-amd64
}

Paste it into /etc/grub.d/40_custom and modify it so it will look like that (not exactly like that):
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "Clonezilla live" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
set isofile="/clonezilla/clonezilla-live-2.4.2-32-amd64.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap nolocales edd=on nomodeset nodmraid ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" keyboard-layouts= ocs_live_batch=\"no\" locales= vga=788 ip=frommedia nosplash toram=filesystem.squashfs findiso=$isofile
initrd (loop)/live/initrd.img
}


So you can see that part of configuration up to line with set root='(hd0,msdos1)' is exactly the same, after that we specify isofile, mount it and use loop for vmlinx and initrd.

After saving changes to /etc/grub.d/40_custom we need to regenerate grub.cfg with command:
grub2-mkconfig -o /boot/grub2/grub.cfg

Reboot and choose Clonezilla live in grub menu and you should have backup utility at hand.

When using clonezilla live make sure that you have storage drive mounted in /home/partimag (local or over network sshfs or nfs).

When using clonezilla live network in my case did not work, I had to manually bring it up but it is topic for another post.