0

我想为所有寻找自动化 Clonezilla 恢复选项的人提供一个简短的教程。

假设

  • 仅 UEFI 引导
  • Clonezilla/dev/sdb1和 Image 存储库/dev/sdb2/images都在同一个 U 盘上
  • 恢复到整个 SSD/dev/sda

我想

  1. 从 U 盘启动
  2. 自动选择并启动自定义 Clonezilla 恢复选项
  3. 从 U 盘自动加载图像存储库
  4. 用户选择要恢复的图像
  5. 从选定的图像自动恢复到 SSD
  6. 成功恢复后自动重启
4

1 回答 1

3

脚步

在您的 Clonezilla USB 记忆棒/boot/grub/grub.cfg中使用文本编辑器打开。在以下文本之后Since no network setting in the squashfs image, therefore if ip=, the network is disabled.添加以下内容以使其成为第一个 Clonezilla 默认条目:

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
}

最重要的部分

ocs_prerun="mount /dev/sdb2 /mnt" ocs_prerun1="mount --bind /mnt/images /home/partimag/"挂载/dev/sdb2/images为镜像仓库

ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -k -scr -batch -p reboot restoredisk ask_user sda"恢复映像/dev/sda重新启动

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
}
于 2021-01-22T16:23:11.263 回答