Page 1 of 1

Integrating clonezilla into grub

Posted: Mon Nov 06, 2017 7:36 am
by yamahama
I'm trying to integrate clonezilla into grub for easy one key unattended backups/restores. The best info i could find on doing this is this guide but unfortunately it does not work as it may be outdated. Some guidance would be appreciated (i'm a noob so please be gentle!).

If i enter the menu entries in the guide as is, i get an error that goes something like "iso file not found...you have to mount the kernel first." (The filename and path are correct). I've managed to get clonezilla live working manually by changing the corresponding menu entry (in /etc/grub.d/40_custom)

Code: Select all

menuentry "Clonezilla Live 2.5.2-31" {
set isofile="/isos/clonezilla-live-2.5.2-31-amd64.iso"
loopback loop (hd1,1)$isofile
linux (loop)/live/vmlinuz boot=live live-config noswap nolocales edd=on nomodeset 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
}
to this format (found elsewhere on the web):

Code: Select all

menuentry "Clonezilla Live 2.5.2-31" {
set isofile="/isos/clonezilla-live-2.5.2-31-amd64.iso"
loopback loop (hd1,1)$isofile
linux (loop)/live/vmlinuz boot=live components config findiso=$isofile ip=frommedia toram=filesystem.squashfs union=overlay username=user
initrd (loop)/live/initrd.img
}
unfortunately i'm not sure how i'd apply this to the automated backup and restore menu entries found in the original guide:

Code: Select all

menuentry "Clonezilla Live 2.5.2-31 (Unattended Backup)" {
set isofile="/isos/clonezilla-live-2.5.2-31-amd64.iso"
loopback loop (hd1,1)$isofile
linux (loop)/live/vmlinuz boot=live live-config noswap nolocales edd=on nomodeset ocs_prerun=\"mount /dev/sdb1 /mnt\" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run=\"ocs-sr -q2 --batch -j2 -z1p -i 2000 -sc -p reboot savedisk autoproductname sda\" ocs_live_extra_param=\"\" keyboard-layouts=\"\" ocs_live_batch=\"yes\" locales=\"\" vga=788 ip=frommedia nosplash toram=filesystem.squashfs findiso=$isofile
initrd (loop)/live/initrd.img
}

menuentry "Clonezilla Live 2.5.2-31 (Unattended Restore)" {
set isofile="/isos/clonezilla-live-2.5.2-31-amd64.iso"
loopback loop (hd1,1)$isofile
linux (loop)/live/vmlinuz boot=live live-config noswap nolocales edd=on nomodeset ocs_prerun=\"mount /dev/sdb1 /mnt\" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run=\"ocs-sr -g auto -e1 auto -e2 -r -j2 -p reboot restoredisk autoproductname sda\" ocs_live_extra_param=\"\" keyboard-layouts=\"\" ocs_live_batch=\"yes\" locales=\"\" vga=788 ip=frommedia nosplash toram=filesystem.squashfs findiso=$isofile
initrd (loop)/live/initrd.img
}
how do i do this right?

edit: I'm running a fresh install of 18.2 Cinnamon x64 (dual booting win 7). and the exact error message is as follow:

Code: Select all

error: file '/isos/clonezilla-live-2.5.2-31-amd64.iso' not found.
error: disk 'loop' not found.
error: you need to load the kernel first.

Re: Integrating clonezilla into grub

Posted: Tue Nov 07, 2017 12:55 pm
by pbear
Have to say, I don't see the point. If you want continuous backups of the whole system, you'd be much better off using rsync. That's one of the things it's designed for. Can't help you set it up, as I settled on a different backup strategy, but there are plenty of tutorials online.

Re: Integrating clonezilla into grub

Posted: Tue Nov 07, 2017 1:35 pm
by JoeFootball
yamahama wrote:error: file '/isos/clonezilla-live-2.5.2-31-amd64.iso' not found.
error: disk 'loop' not found.
To me it sounds like your GRUB option isn't pointed to the correct location. For example, the blog entry leverages (hd0,1) where you have (hd1,1). Also note that the blog script forces the skip of the image verification, and then reboots the system.

That said, while it's certainly an interesting project, make that this is the proper backup solution for you. I'm a huge fan of Clonezilla Live for making bare metal images of my hard drive, so I support your intentions.

But speaking for myself, I like the reassurance of the image verification, and seeing the result of the backup session before rebooting. I'd be skeptical that the above option would help me sleep better at night.

Joe

Re: Integrating clonezilla into grub

Posted: Tue Nov 07, 2017 3:31 pm
by yamahama
JoeFootball wrote:
yamahama wrote:error: file '/isos/clonezilla-live-2.5.2-31-amd64.iso' not found.
error: disk 'loop' not found.
To me it sounds like your GRUB option isn't pointed to the correct location. For example, the blog entry leverages (hd0,1) where you have (hd1,1). Also note that the blog script forces the skip of the image verification, and then reboots the system.
Hi Joe,

Thanks for the reply. indeed it was an incorrect location issue even though i triple checked but i'd forgotten how sensitive linux is to case.

But then it'd fail with an error that went something like "aufs mount failed" which was fixed by adding an option union=overlay. i'll write up updated instructions here in case someone finds it useful.

yeah i love taking the time for that extra verification step too. but honestly i've NEVER seen clonezilla fail and speed is essential here considering how often i intend to use it.

Re: Integrating clonezilla into grub

Posted: Tue Nov 07, 2017 3:39 pm
by JoeFootball
yamahama wrote:i'll write up updated instructions here in case someone finds it useful.
I'm sure someone will appreciate that, and it does sound like an interesting project. :)

Joe

Re: Integrating clonezilla into grub

Posted: Tue Nov 07, 2017 3:50 pm
by yamahama
pbear wrote:Have to say, I don't see the point. If you want continuous backups of the whole system, you'd be much better off using rsync. That's one of the things it's designed for. Can't help you set it up, as I settled on a different backup strategy, but there are plenty of tutorials online.
hi pbear,
as far as i can tell rsync is for files and folders only and not for whole disks/partitions and mbr.

the point is partly glory, partly learning more about linux and partly to make the process of updating the software and configuration on old backups cleaner/easier.

Re: Integrating clonezilla into grub

Posted: Tue Nov 07, 2017 3:58 pm
by pbear
yamahama wrote:as far as i can tell rsync is for files and folders only and not for whole disks/partitions and mbr.
Honest, it'll do the job. I've seen detailed tutorials describing, written by system administrators who really need it to work.

That said, if you'd rather do it the other way, Linux is all about choice. Good luck.

Re: Integrating clonezilla into grub

Posted: Tue Nov 07, 2017 4:36 pm
by yamahama
So just a quick how i got this to work. The original guide here is honestly near perfect as long as you don't make typos so i'll just add a single note:

Apparently new versions of clonezilla no longer use aufs and if you get the "mounting aufs on /root/ failled" error, you need to add the option "union=overlay" to the menu entries to make it work as intended. so:

Code: Select all

menuentry "Clonezilla Live 2.5.2-31" {
set isofile="/boot/isos/clonezilla-live-2.5.2-31-amd64.iso"
loopback loop (hd0,1)$isofile
linux (loop)/live/vmlinuz boot=live components config findiso=$isofile ip=frommedia toram=filesystem.squashfs union=overlay username=user
initrd (loop)/live/initrd.img
}
        
menuentry "Clonezilla Live 2.5.2-31(Unattended Backup)" {
set isofile="/boot/isos/clonezilla-live-2.5.2-31-amd64.iso"
loopback loop (hd0,1)$isofile
linux (loop)/live/vmlinuz boot=live live-config noswap nolocales edd=on nomodeset union=overlay ocs_prerun=\"mount /dev/sdb1 /mnt\" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run=\"ocs-sr -q2 --batch -j2 -z1p -i 2000 -sc -p reboot savedisk autoproductname sda\" ocs_live_extra_param=\"\" keyboard-layouts=\"\" ocs_live_batch=\"yes\" locales=\"\" vga=788 ip=frommedia nosplash toram=filesystem.squashfs findiso=$isofile
initrd (loop)/live/initrd.img
}

menuentry "Clonezilla Live 2.5.2-31 (Unattended Restore)" {
set isofile="/boot/isos/clonezilla-live-2.5.2-31-amd64.iso"
loopback loop (hd0,1)$isofile
linux (loop)/live/vmlinuz boot=live live-config noswap nolocales edd=on nomodeset union=overlay ocs_prerun=\"mount /dev/sdb1 /mnt\" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run=\"ocs-sr -g auto -e1 auto -e2 -r -j2 -p reboot restoredisk autoproductname sda\" ocs_live_extra_param=\"\" keyboard-layouts=\"\" ocs_live_batch=\"yes\" locales=\"\" vga=788 ip=frommedia nosplash toram=filesystem.squashfs findiso=$isofile
initrd (loop)/live/initrd.img
}
Tested on Linuxmint Cinnamon 18.2 Cinnamon x64 with grub, burg and clonezilla v2.5.2-31 x64 iso.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 2:36 am
by Walterjnr
Sorry to revive such an old thread, but I tried this exact method of integrating Clonezilla into Grub, and after many hours and many more swear words, finally got it running. Part of me wanted to do it just to finish something that I started but now that I've got it running I'm not sure that running Clonezilla on the same HDD that I am currently imaging is the best thing. Perhaps others more knowledgeable than me can tell me whether it's ok to do this or should it be run from a totally separate partition or HDD?

It's certainly easier to do this than muck around with my Bios boot order that always resets to the main HDD after 5 or 6 boots so I hope to be able to use this method going forward.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 5:31 am
by AndyMH
I developed foxclone, which is a lot more user friendly than clonezilla. The way I use it: All my PCs (3xlaptop, 1xdesktop) have a separate internal/removable 2TB backup HDD. There are two partitions on the HDD, a large ext4 one to store backups and a small ext4 partition with LM19.3 installed in it. foxclone is installed in LM19.3. When I boot, grub gives me the choice of either booting as normal or booting LM19.3 from the HDD to do a foxclone image backup (or restore, or clone).

As well as being able to boot into LM19.3 as normal, grub is also installed to the backup HDD so in the event that my main SSD fails I can still boot it. Why LM19.3 - simply to have a different OS to the main one on the SSD which is LM20.1.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 7:58 am
by t42
Walterjnr wrote: Fri Apr 09, 2021 2:36 am I'm not sure that running Clonezilla on the same HDD that I am currently imaging is the best thing.
It makes no difference if you load the Clonezilla image from the same HDD. You only need to follow Clonzilla's standard warning not to place partimg home on the saved partition /disk. I'm regularly save a partition where Clonezilla image is placed.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 8:06 am
by t42
Walterjnr wrote: Fri Apr 09, 2021 2:36 am Sorry to revive such an old thread, but I tried this exact method of integrating Clonezilla into Grub, and after many hours and many more swear words, finally got it running.
It's quite easy to implement. If someone is interested:

Place a Clonezilla image in /iso/ directory
Create a file /boot/grub/custom.cfg with this content:

Code: Select all

#-----------------------------
menuentry "Clonezilla live" {
set isofile="/iso/clonezilla-live-20210127-groovy-amd64.iso"
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap nolocales edd=on nomodeset ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" keyboard-layouts= ocs_live_batch=\"no\" locales= vga=788 ip=frommedia toram=live,syslinux,EFI findiso=$isofile
initrd (loop)/live/initrd.img
}
#-----------------------------
Change clonezilla-live-20210127-groovy-amd64.iso for another Clonzilla version.
Just reboot, that's all.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 8:36 am
by bodge99
Hi,

I'd view this as a worthy project.. Some folk have developed their own backup strategy and/or tools, some use existing tools such as Timeshift etc..
Unfortunately a large number of folk don't backup at all..

I personally would approach this particular project by extracting the Clonezilla iso(s) to a discrete partition on an external device (and mod from there)..
This could then be set up to support legacy or UEFI boot (32/64bit.. Yes, 32bit UEFI based kit does exist!) and so would be usable on any PC that has a USB port. You could then add tools or tweak Clonezilla to suit any specific requirements or ways of working.

I'm **NOT** saying that this is in any way "better" or that anyone should do this.. It's just a "thought experiment" for me at this stage.

A superb way to learn something new!

Bodge99

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 9:06 am
by Moonstone Man
t42 wrote: Fri Apr 09, 2021 8:06 am Change clonezilla-live-20210127-groovy-amd64.iso for another Clonzilla version.
Just reboot, that's all.
Thanks for that. I'm going to give it a burl.

Edit: It worked like a charm, thanks again.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 9:47 am
by t42
You're welcome!

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 10:04 pm
by Walterjnr
I tried performing a restore with this setup, and while it all worked in the end, I'm unsure about one part of it. After the image was restored it went through a process of rebuilding GRUB. I've never seen this before so wasn't sure how normal this was. I've performed a few restores whilst using LM, plus many years of using Clonezilla with Windows, and haven't had this pop up until now. GRUB was installed at the time but the menu was always hidden. Does Clonezilla need to rebuild GRUB if there are modifications to the GRUB files? I really like the simplicity of having Clonezilla built in to GRUB so I don't want to go back to booting USBs or CDs if I can avoid it.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 10:30 pm
by Moonstone Man
Walterjnr wrote: Fri Apr 09, 2021 10:04 pm Does Clonezilla need to rebuild GRUB if there are modifications to the GRUB files?
No. Clonezilla must always reinstall grub. The fact that you've not seen Clonezilla do this before implies only that you've never noticed it before.

Grub must be reinstalled because it takes up the first few bytes of the drive for the bootstrap loader, then switches to the grub stored on a partition, which the bootstrap points to. The bootstrap, by definition, lies outside of any and all partitions, and since Clonezilla images partitions it therefore follows that grub must be reinstalled.

Re: Integrating clonezilla into grub

Posted: Fri Apr 09, 2021 10:47 pm
by Walterjnr
Kadaitcha Man wrote: Fri Apr 09, 2021 10:30 pm
Walterjnr wrote: Fri Apr 09, 2021 10:04 pm Does Clonezilla need to rebuild GRUB if there are modifications to the GRUB files?
No. Clonezilla must always reinstall grub. The fact that you've not seen Clonezilla do this before implies only that you've never noticed it before.
That was my other thought. Thanks for clarifying that.