MatthewL Posted February 2, 2025 Posted February 2, 2025 I use Clonezilla from a USB stick to take images and sometimes restore them. I haven't worked it out and struggling through the documentation I believe you can from a config file in somewhere that specifys all what you set so the path where your imaging to, file size etc etc all I want it to then do is prompt me to name the file and away we go. Can anyone help? Also has anyone got it working in a PXE environement, do away with the USB drive and go from there? Any hints and tips?
JRA Posted February 5, 2025 Posted February 5, 2025 Probably not much of a direct help to you but I mostly use dd for that, and boot into a linux distro off a stick if I want to do any raw disk copying. Piping dd output to netcat means I can get an image off "something" and then spit that image out over the network to "another something" if that's booting a USB disk too, but it's rare I'll do that. Bit of a quick and dirty thing to do but it gets the job done when I need it! Never have tried doing more than one at once (might be a proper basic network imaging solution in it somewhere) but it might work! I use FOG for imaging here and honestly I think its days are numbered now. I'm reasonably content (for a low-level linux fumbler I might add) with using it but I'm finding crawling around the internet for updated boot binaries, dead-end blogs and the upcoming battle with W11 24H4 not working with secure boot disabled to image might knock it on the head. If any of that sounds like gobbledygook btw let me know!
MatthewL Posted February 5, 2025 Author Posted February 5, 2025 I do disk to disk, dump the file on my NAS in a share. I don't do it very often but would of been nice to fire it up and then all I had to do is put the file name in and the rest of it is taken care of rather than having to selection the options each time.
Sephiroth Posted February 5, 2025 Posted February 5, 2025 I do almost exactly this. I use iPXE to boot the clonezilla image with a few menu options to select what I want to do. This is the clonezilla section of my iPXE menu.config: :czinteractive set os-root ${boot-path}/clonezilla/live kernel tftp://${server-ip}/${os-root}/vmlinuz initrd tftp://${server-ip}/${os-root}/initrd.img imgargs vmlinuz boot=live config noswap nolocales edd=on nomodeset ocs_live_run="ocs-live-general" keyboard-layouts="uk" ocs_live_extra_program="" ocs_live_keymap="uk" ocs_live_batch="no" ocs_daemonon="ssh" usercrypted=Kb/VNchPYhuf6 ocs_lang="" vga=788 nosplash noprompt fetch=tftp://${server-ip}/${os-root}/filesystem.squashfs boot :czsavedisk set os-root ${boot-path}/clonezilla/live kernel tftp://${server-ip}/${os-root}/vmlinuz initrd tftp://${server-ip}/${os-root}/initrd.img imgargs vmlinuz boot=live config noswap nolocales edd=on nomodeset enforcing=0 keyboard-layouts="uk" ocs_prerun1="mount -t cifs -o user='${czuser}',password=${czpass} //${czroot}/Clonezilla /home/partimag" ocs_live_run="ocs-sr -q2 -c -j2 -z9 -i 0 -sfsck -scs -senc -p choose savedisk ask_user ask_user" ocs_live_keymap="uk" ocs_live_batch="no" ocs_daemonon="ssh" usercrypted=Kb/VNchPYhuf6 ocs_lang="" vga=788 nosplash noprompt fetch=tftp://${server-ip}/${os-root}/filesystem.squashfs boot :czrestoredisk set os-root ${boot-path}/clonezilla/live kernel tftp://${server-ip}/${os-root}/vmlinuz initrd tftp://${server-ip}/${os-root}/initrd.img imgargs vmlinuz boot=live config noswap nolocales edd=on nomodeset enforcing=0 keyboard-layouts="uk" ocs_prerun1="mount -t cifs -o user='${czuser}',password=${czpass} //${czroot}/Clonezilla /home/partimag" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -c -r -j2 -k0 -scr -p choose restoredisk ask_user ask_user" ocs_live_keymap="uk" ocs_live_batch="no" ocs_daemonon="ssh" usercrypted=Kb/VNchPYhuf6 ocs_lang="" vga=788 nosplash noprompt fetch=tftp://${server-ip}/${os-root}/filesystem.squashfs boot Interactive just runs the default clonezilla instance; SaveDisk asks you what name you want to give the file, then just saves it to the required destination; RestoreDisk searches for images and asks which one you want to restore. The variables are set elsewhere in the config files. If you want to go more into that, let me know. I got the arguments by running it manually then copying the code it gives you before it starts the process. Alternatively, I believe that you can achieve the same without PXE boot by putting the arguments in a script file on the drive and calling that with the clonezilla command line, rather than going through the prompts. 1
MatthewL Posted February 5, 2025 Author Posted February 5, 2025 Thanks for the reply, this is exactly what I want to achieve. So do you have a server running Clonezilla then? I was hoping I could achieve the same using a USB stick and dumping a similar file on that so when I boot from USB I get the option.
Sephiroth Posted February 5, 2025 Posted February 5, 2025 I have a server running iPXE, which houses various tools and utilities that can be booted over the network. The Clonezilla object in iPXE is set to use our deployment server as a repository using CIFS, which has the authentication saved in the configs. You could in theory get it to prompt for credentials as well. The place to start is to run Clonezilla manually and copy the arguments it gives you before it starts to a file. That will give you the cli version of the options that you select. Do you plan on using the USB as a repository as well as the boot medium or are you copying straight to NAS? If the former, it does simplify the config. Let me have a play and see what I can come up with based on our setup.
MatthewL Posted February 5, 2025 Author Posted February 5, 2025 Thanks for that, I plan to just use it as a boot medium and then dump or read the file from the NAS. I can create a DHCP option to specify the server just need to get it to point somewhere although I don't want to bring up a machine to host this on if I can help it hence using USB boot.
Sephiroth Posted February 5, 2025 Posted February 5, 2025 So having had a look at this, you can create a custom command and inject it into a bootable image, then create your own menu items to look at the relevant server and configs. Manually run clonezilla to set up your image and get it to generate the backup file to /tmp/ocs-, copy the file to '/home/partimag', and have a look at it in your preferred editor. It will still prompt for any required options by specifying "ask_user", so you can automate as much or little as you need. you will likely want to set this for the filename and source drive. It will look something like this: /usr/sbin/ocs-sr -q2 -c -j2 -z9p -i 0 -sfsck -scs -senc -p choose savedisk ask_user ask_user Once you're happy, cd to '/home/partimag' and run something like (where './custom-ocs' is the name of the file you've generated):ocs-live-dev -g en_GB.UTF-8 -k gb -s -c -m ./custom-ocs I advise getting the "-g" switch for language (probably 'en_GB.UTF-8'), and "-k" switch for keyboard layout (probably 'gb') right so you don't have to mess around later. Extract the contents of the resultant file and edit the '/boot/grub/grub.cfg' file to add a new menu item, something like this:menuentry "Custom Save Disk" --id custom-save { search --set -f /live/vmlinuz $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components noswap edd=on nomodeset enforcing=0 noeject locales=en_GB.UTF-8 keyboard-layouts=gb ocs_prerun1="mount -t cifs -o user='',password= /// /home/partimag" ocs_live_run="custom-ocs" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= net.ifnames=0 quiet nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 $initrd_cmd /live/initrd.img } The actual custom-ocs file is placed in the 'pkg' directory. You can add multiple here (suggest naming 'ocs-savedisk' and 'ocs-restoredisk' with the appropriate settings) and reference them in multiple menu entries. Once you're happy, copy to a USB stick and boot to it. Hopefully everything should just load. More information on creating the custom image Here. Also good references Here on creating bootable drives.
MatthewL Posted February 5, 2025 Author Posted February 5, 2025 Thanks for that, will have a look when I get 5 minutes and see how I get on, thanks for that.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now