Menu

Creating a grub2 mention option to unattended Capture and Deploy Single Image

2024-03-12
2024-03-22
  • Christopher Frankland-Wright

    Hi there,

    I'm struggling with creating a grub2 menu item. I want to create a rescue disk for our servers which runs a particular bit of software with some custom settings, the idea being once it's built we capture it onto the MicroSD card on the motherboard and then can have a Deploy image (or restore system) menu item.

    Here is what I have so far, but I was hoping someone might have something prepepared which does this:

    menuentry "Create Clonezilla Image" --id live-toram {
        search --set -f /live/vmlinuz
        set root_device="/dev/sda"
    
        linux /live/vmlinuz boot=live components config noswap nolocales edd=on nomodeset ocs_prerun="sudo ocs-sr -q2 -j2 -z1p -i 4096 -sc -p true saveparts ask_user ${root_device}" ocs_live_run="sudo ocs-sr -q2 -j2 -z1p -i 4096 -sc -p true saveparts -sfsck -c -r -v -k -p reboot restoreparts ask_user" ocs_live_extra_param="" keyboard-layouts="us" ocs_live_batch="no" locales="en_US.UTF-8" vga=788 ip=frommedia toram=filesystem.squashfs findiso=/live/filesystem.squashfs
        initrd /live/initrd.img
    }
    

    This currently errors and I'm not sure why it does it.

     
  • Christopher Frankland-Wright

    Here is the error message I am getting, I'm getting all rather lost in this.

     
  • Christopher Frankland-Wright

    These are the lines that clonezilla give me to use for future capture/restore, is there a way to create a gub entry using it?

    /usr/sbin/ocs-sr -q2 -c-j2 -zp9 -i 4096 -sfsck -senc -p reboot savedisk mRes-Recover sda

    /usr/sbin/ocs-sr -g auto -e1 auto -e2 -r -j2 -c -k0 -p reboot restoredisk mRes-Recover sda

     
  • Christopher Frankland-Wright

    This is the current grub entry I am using for capture:

    menuentry "Clone from sda to Clonezilla device" {
    search --set -f /live/vmlinuz
    linux ($root)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 ocs_live_run="/usr/sbin/ocs-sr -q2 -c -j2 -zp9 -i 4096 -sfsck -senc -p reboot savedisk mRes-Recover sda" keyboard-layouts=NONE locales=en_US.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
    }

    This kind of works, but it create the image on the incorrect device. The machine has the following:
    sda - system drive
    sdb - drive for record train
    sdc - 64GB SD card running Clonezilla and Grub on the onboard sd reader on the motherboard

    as it stands, it looks like it will clone SDA to SDB and I can't find a way to tell it to only clone to SDC

    Thanks for the help so far,

     

    Last edit: Christopher Frankland-Wright 2024-03-19
  • Steven Shiau

    Steven Shiau - 2024-03-20

    That's true. Actually sda, sdb, sdc are random...
    You might be able to use PTUUID or SERIALNO (short format), e.g., PTUUID=03c8b280-47aa-4881-aca5-9b9c66fe28c7 to assign that. Please use "sudo ocs-sr --help" to show the help messages, or you can refer to
    https://clonezilla.org/advanced/reserved-word-ocs-sr.php

    Steven

     
  • Christopher Frankland-Wright

    I wonder if I search for a known file on each device, so for the system disk we look for the hidden folder $SysReset and the SD card we find the Clonezilla-Live-Version file at it's root. Then using that we grab the PTUUID.

    I'm still struggling with finding the part that defines the source and target for the clone.

    menuentry "Clone from sda to Clonezilla device" {
    search --set -f /live/vmlinuz
    linux ($root)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 ocs_live_run="/usr/sbin/ocs-sr -q2 -c -j2 -zp9 -i 4096 -sfsck -senc -p reboot savedisk mRes-Recover sda" keyboard-layouts=NONE locales=en_US.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
    }

    I can see that we define the source at the end of the ocs-sr string, but no where does it define where to write the image file to. Currently it tries to write to the wrong place that isn't running the Clonezilla.

     
  • Christopher Frankland-Wright

    I think the issue I've encountered is that running this it can't write to the SD card because it is mounted. I've been playing with trying to run the clonezilla to toram but it's not successfully parsing the line through, it just loads clonezilla in the RAM

    Current entry is:

    menuentry "MRES Create Recovery" --id live-toram {
    search --set -f /live/vmlinuz
    linux ($root)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 ocs_live_run="/usr/sbin/ocs-sr -q2 -c -j2 -zp9 -i 4096 -sfsck -senc -p reboot savedisk mRes-Recover sda ocs_repository=\"dev:///LABEL=MRESRECOVER\"" keyboard-layouts=NONE locales=en_US.UTF-8 vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= nosplash net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
    $initrd_cmd /live/initrd.img
    }

    @steven_shiau - can you see what might be wrong here please?

     

    Last edit: Christopher Frankland-Wright 2024-03-21

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.