20200628--CloneZilla实现无人值守还原镜像

202006/30更新,

CloneZilla以EFI Grub模式启动时, 配置文件为 I:\EFI\boot\grub.cfg 则CloneZilla官网的修改syslinux.cfg的方法无效. 需要修改grub.cfg文档内容,如下是实测示例:

镜像盘:

移动固态硬盘, 第一分区为CloneZilla启动分区, 第二分区为镜像存放分区. 

镜像目录: \TestImage\CUDE-20200630-Image

三条主要命令:

ocs_prerun="mount /dev/sda2 /mnt"
ocs_prerun1="sudo mount --bind /mnt/TestImage /home/partimag"
ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -c -scr -p choose restoredisk CUDE-20200630-Image nvme0n1"

以下是grub.cfg配置文件的部分内容:

(仅修改800*600分辨率部分, 可以修改默认菜单描述 Clonezilla live (Default settings, VGA 800x600))

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 "Clonezilla live (Default settings, VGA 800x600)"{
  search --set -f /live/vmlinuz
  linux /live/vmlinuz boot=live config noswap nolocales edd=on nomodeset noprompt ocs_prerun="mount /dev/sda2 /mnt" ocs_prerun1="sudo mount --bind /mnt/TestImage /home/partimag" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -c -scr -p choose restoredisk CUDE-20200630-Image nvme0n1" ocs_live_extra_param="" keyboard-layouts=NONE ocs_live_batch="no" locales=en_US.UTF-8 vga=788 ip= nosplash
  # linux /live/vmlinuz boot=live union=overlay username=user hostname=artful config quiet components noswap edd=on nomodeset 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 /live/initrd.img
}
menuentry "Clonezilla live (Default settings, VGA 1024x768)"{
  search --set -f /live/vmlinuz
  linux /live/vmlinuz boot=live union=overlay username=user hostname=artful config quiet components noswap edd=on nomodeset 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 /live/initrd.img
}

 

 

--------------------------------------------------------------

此示例中, 会自动选择语言、键盘布局、镜像存储路径、选择镜像分区、还原镜像到分区。

处理的选项

  1. 语言选择为"English"

1 locales=en_US.UTF-8

  2. 键盘布局=无变化

1 keyboard-layouts=NONE

  3. 设置镜像源位置,  假设镜像位于第一颗磁盘的第二个分区(/dev/sda4) ,在/Backup文件夹内. 预设变量如下:

1 ocs_prerun="mount /dev/sda4 /mnt"
2 ocs_prerun1="mount --bind /mnt/Backup /home/partimag/"

 

  注意!!! 此处需要将磁盘分区和镜像文件夹分别挂载一次.  如果镜像位于分区的根目录,则无需分两次。

  如果镜像在网络服务器上, 如samba server, 可以这样做:

1 ocs_prerun1="dhclient -v eth0"
2 ocs_prerun2="sleep 2"
3 ocs_prerun3="mount -t cifs -o user=$ACCOUNT,password=$PASSWD //$SAMBA_SERVER_IP/$PATH_TO_IMAGE /home/partimag"
  • (替换$ACCOUNT, $PASSWD, $SAMBA_SERVER_IP, $PATH_TO_IMAGE变量,
  • 如: "mount -t cifs -o user=administrator,password=apple //192.168.1.3/images2/clonezilla /home/partimag").
1 ocs_prerun4="sleep 2"

  此处设想网络内已经有DHCP服务器分配IP地址. 如果想设置固定IP地址, 可以用网络配置工具实现, 如ifconfig, rute等.

  如镜像在SSH 服务器上, 可以这样设置ocs_prerun3:

1 ocs_prerun3="sshfs $SSH_ACCOUNT@$SSH_SRV:"$SSHFS_DIR" /home/partimag/"
  • (替换$SSH_ACCOUNT, $SSH_SRV, AND $SSHFS_DIR变量,
  • 如: "sshfs chopin@192.168.100.254:/home/chopin /home/partimag"

  4. 还原操作, 将Backup的镜像还原到/dev/sda 变量ocs_live_run如下:

1 ocs_live_run="ocs-sr -g auto -e1 auto -e2 -c -r -j2 -k -p choose restoredisk Backup sda"
  • 此命令也可以在手动还原步骤中的最后一步看到.

  

  5. 在U盘Clonezilla Live中, syslinux.cfg或者isolinux.cfg配置文件如下:

 1 label Clonezilla live
 2 MENU DEFAULT
 3 # MENU HIDE
 4 MENU LABEL Clonezilla live (Default settings, VGA 800x600)
 5 # MENU PASSWD
 6 kernel /live/vmlinuz
 7 append initrd=/live/initrd.img boot=live config noswap nolocales edd=on nomodeset noprompt ocs_prerun="mount /dev/sdb1 /mnt" ocs_prerun1="mount --bind /mnt/Backup /home/partimag/" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -c -r -j2 -k -p true restoredisk Backup sda" ocs_live_extra_param="" keyboard-layouts=NONE ocs_live_batch="no" locales=en_US.UTF-8 vga=788 ip= nosplash
 8 TEXT HELP
 9 * Clonezilla live version: 2.2.2-37-i686-pae. (C) 2003-2014, NCHC, Taiwan
10 * Disclaimer: Clonezilla comes with ABSOLUTELY NO WARRANTY
11 ENDTEXT

 

 

 

文章参考

https://clonezilla.org/show-live-doc-content.php?topic=clonezilla-live/doc/05_Preseed_options_to_do_job_after_booting

https://clonezilla.org/fine-print-live-doc.php?path=clonezilla-live/doc/99_Misc/00_live-boot-parameters.doc

posted on 2020-06-28 16:00  没什么事我就先挂了  阅读(2072)  评论(0编辑  收藏  举报