How to create an automated and unattended Clonezilla Restore solution

穿精又带淫゛_ 提交于 2021-01-29 09:19:02

问题


I would like to provide a short tutorial to all of you out there looking for an automated Clonezilla Restore option.

Assumptions

  • UEFI Boot only
  • both Clonezilla /dev/sdb1 and Image repository /dev/sdb2/images are on the same USB stick
  • Restore to entire SSD /dev/sda

I would like to

  1. Boot from USB stick
  2. Auto-select and start custom Clonezilla restore option
  3. Auto-load image repository from USB Stick
  4. User selects the image to be restored
  5. Auto-restore from selected image to SSD
  6. Auto-reboot after successful restore

回答1:


Steps

In your Clonezilla USB Stick open /boot/grub/grub.cfg using a text editor. After the following text Since no network setting in the squashfs image, therefore if ip=, the network is disabled.add the following to make this the first Clonezilla default entry:

menuentry "Flysoft RESTORE" {
  search --set -f /live/vmlinuz
  $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 noprompt ocs_prerun="mount /dev/sdb2 /mnt" ocs_prerun1="mount --bind /mnt/images /home/partimag/" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -k -scr -batch -p reboot restoredisk ask_user sda" keyboard-layouts="de" ocs_live_batch="yes" locales=de_DE.UTF-8 vga=788 ip= nosplash net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img
}

Most important sections

ocs_prerun="mount /dev/sdb2 /mnt" ocs_prerun1="mount --bind /mnt/images /home/partimag/" mounts /dev/sdb2/images as image repo

ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -k -scr -batch -p reboot restoredisk ask_user sda" restores image to /dev/sda and reboots

Full example of grub.cfg

#
set pref=/boot/grub
set default="0"

# Load graphics (only corresponding ones will be found)
# (U)EFI
insmod efi_gop
insmod efi_uga
# legacy BIOS
# insmod vbe

if loadfont $pref/unicode.pf2; then
  set gfxmode=auto
  insmod gfxterm
  terminal_output gfxterm
fi
set timeout="30"
set hidden_timeout_quiet=false

insmod png
if background_image $pref/ocswp-grub2.png; then
  set color_normal=black/black
  set color_highlight=magenta/black
else
  set color_normal=cyan/blue
  set color_highlight=white/blue
fi

# Uncomment the following for serial console
# The command serial initializes the serial unit 0 with the speed 38400bps.
# The serial unit 0 is usually called ‘COM1’. If COM2, use ‘--unit=1’ instead.
#serial --unit=0 --speed=38400
#terminal_input serial
#terminal_output serial

# Decide if the commands: linux/initrd (default) or linuxefi/initrdefi
set linux_cmd=linux
set initrd_cmd=initrd
export linux_cmd initrd_cmd
if [ "${grub_platform}" = "efi" -a -e "/amd64-release.txt" ]; then
  # Only amd64 release we switch to linuxefi/initrdefi since it works better with security boot (shim)
  set linux_cmd=linuxefi
  set initrd_cmd=initrdefi
fi

insmod play
play 960 440 1 0 4 440 1

# Since no network setting in the squashfs image, therefore if ip=, the network is disabled.

menuentry "Flysoft RESTORE" {
  search --set -f /live/vmlinuz
  $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 noprompt ocs_prerun="mount /dev/sdb2 /mnt" ocs_prerun1="mount --bind /mnt/images /home/partimag/" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -k -scr -batch -p reboot restoredisk ask_user sda" keyboard-layouts="de" ocs_live_batch="yes" locales=de_DE.UTF-8 vga=788 ip= nosplash net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img
}

menuentry "Clonezilla live (Default settings, VGA 800x600)" --id live-default {
  search --set -f /live/vmlinuz
  $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=788 ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img
}

submenu 'Other modes of Clonezilla live' {
  menuentry "Clonezilla live (Default settings, VGA 1024x768)"{
    search --set -f /live/vmlinuz
    $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=791 ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
    $initrd_cmd /live/initrd.img
  }
  
  menuentry "Clonezilla live (Default settings, VGA 640x480)"{
    search --set -f /live/vmlinuz
    $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=785 ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
    $initrd_cmd /live/initrd.img
  }
  
  menuentry --hotkey=K "Clonezilla live (Default settings, KMS)"{
    search --set -f /live/vmlinuz
    $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on enforcing=0 locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=791 ip= net.ifnames=0  splash
    $initrd_cmd /live/initrd.img
  }

  menuentry --hotkey=R "Clonezilla live (To RAM, boot media can be removed later)"{
    search --set -f /live/vmlinuz
    $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
    $initrd_cmd /live/initrd.img
  }
  
  menuentry "Clonezilla live Safe graphic settings (vga=normal)"{
    search --set -f /live/vmlinuz
    $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" ip= net.ifnames=0 nomodeset vga=normal nosplash
    $initrd_cmd /live/initrd.img
  }
  
  menuentry "Clonezilla live (Failsafe mode)"{
    search --set -f /live/vmlinuz
    $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp ip= net.ifnames=0 nomodeset vga=normal nosplash
    $initrd_cmd /live/initrd.img
  }
}  

menuentry "Local operating system (if available)" --id local-disk {
  echo "Booting first local disk..."
  # Generate boot menu automatically
  configfile /boot/grub/boot-local-efi.cfg
  # If not chainloaded, definitely no uEFI boot loader was found.
  echo "No uEFI boot loader was found!"
  sleep 15
}

#menuentry "memtest"{
#  search --set -f /live/memtest
#  linux16 /live/memtest
#}

#menuentry "FreeDOS"{
#  linux16 memdisk
#  initrd /live/freedos.img
#}

menuentry "Network boot via iPXE" {
  search --no-floppy --set=root -f /live/ipxe.efi
  chainloader /live/ipxe.efi + 1
}

menuentry 'uEFI firmware setup' 'uefi-firmware' {
  echo "Entering uEFI firmware setup..."
  fwsetup
}

menuentry "Clonezilla live 2.7.0-10-amd64 info"{
  echo Clonezilla, the OpenSource Clone System.
  echo NCHC Free Software Labs, Taiwan.
  echo clonezilla.org, clonezilla.nchc.org.tw
  echo \* Boot menu for EFI machine
  echo \* Clonezilla live version: 2.7.0-10-amd64. (C) 2003-2020, NCHC, Taiwan
  echo \* Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY
  sleep --verbose --interruptible 10
}


来源:https://stackoverflow.com/questions/65848953/how-to-create-an-automated-and-unattended-clonezilla-restore-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!