-- Mike Gore - 2021-10-01

Custom Clonezilla USB Key for UEFI installations

  • For more then on image I suggest a fast 128GB key with known high speed read and write specs

Requirements

  • We assume you will be building the USB key on a Linux computer
  • Assumptions:
    • You have a fast USB key with > 64GB space Note: even at 30MB/s it will take over a half hour to create the key - so faster is better
    • You have root access on your Linux computer via sudo
    • Physical access to USB ports attached to the system
    • An account on asimov.uwaterloo.ca - all CSCF staff have one
    • Network access to asimov.uwaterloo.ca

Location of images on ASIMOV

  • Location *asimov:/coregroup/images/research/CSCF-CLONEZILLA-USB-KEY

Creating a USB key using automated scripts

  • Open a terminal window on your linux system
  • Create a directory to put some scripts: mkdir usbkey
  • cd usbkey
  • Become root on your linux machine
    • sudo bash
  • Get the two scripts that you will need
    • wget "https://cs.uwaterloo.ca/twiki/pub/CF/CustomClonezillaUSBKEY/makeusb.sh"
    • wget "https://cs.uwaterloo.ca/twiki/pub/CF/CustomClonezillaUSBKEY/updateusb.sh"
  • In the terminal window run the command dmesg -w
  • Insert the usb key - take note of any NEW message that appear after inserting the KEY. You are looking for the block device name such as [sdf]
  • Example output of dmesg -w
        [441958.259714] usb 9-2.4: new SuperSpeed Gen 1 USB device number 3 using xhci_hcd
        [441958.282160] usb 9-2.4: New USB device found, idVendor=0781, idProduct=55a3, bcdDevice= 1.00
        [441958.282162] usb 9-2.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
        [441958.282164] usb 9-2.4: Product:  SanDisk 3.2Gen1
        [441958.282165] usb 9-2.4: Manufacturer:  USB
        [441958.282166] usb 9-2.4: SerialNumber: 010160253a1d8f5d6947b26fdaae692d2d062441d07caff0178ab93935e1b8ee247500000000000000000000521a62e4ff0e1700a355810735aacb8d
        [441958.287971] usb-storage 9-2.4:1.0: USB Mass Storage device detected
        [441958.288217] scsi host9: usb-storage 9-2.4:1.0
        [441959.296658] scsi 9:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
        [441959.297039] sd 9:0:0:0: Attached scsi generic sg8 type 0
        [441959.297242] sd 9:0:0:0: [sdh] 240353280 512-byte logical blocks: (123 GB/115 GiB)
        [441959.297816] sd 9:0:0:0: [sdh] Write Protect is off
        [441959.297818] sd 9:0:0:0: [sdh] Mode Sense: 43 00 00 00
        [441959.298589] sd 9:0:0:0: [sdh] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
        [441959.339906]  sdh: sdh1
        
  • press CTRL+C to break out of dmesg -w
  • run the command ./makeusb.sh /dev/sdh username
    • Replace sdh with the drive you system detected
    • replace the username with your CS-GENERAL username
  • You will be prompted twice for your CS-GENERAL password on asimov.uwaterloo.ca
  • Notes:
    • The first prompt will take about a minute or two and then you will be prompted for your password again to copy the images
    • Grab a coffee this will take a while - about 30 minutes - when the script finishes you can remove the usb key

Manual Key creation steps - OLD manual instructions - kept only for reference

Download Clonezilla

Format USB key on Linux

  • Open a terminal window
  • sudo bash to become root
  • dmesg -w
  • plug in USB key - you will see something like this appear momentarily after plugging in the USB key
       [3891853.010914] sd 9:0:0:0: [sdh] Attached SCSI removable disk
          
  • Note only device names in "[]" that appear with the message: Attached SCSI removable disk
    • Such as [sdh] - devices have the names sd followed by a to z
    • CRITICAL: make sure you replace the sdh name of this example with your own device!!!
  • CTRL+C to exit dmesg -w
  • We now will partition the USB key: gparted /dev/sdh substituting your detected device
  • Right click on all partitions one at a time and delete them
  • Menu EDIT -> Apply
  • Create new GPT partition table (gpt will appear in the drop down list
  • Pick the unpartitioned space of the drive with your mouse, right click and create new partition
    • Pick fat32 from drop down and 2000 for size
    • Add CLONEZILLA or Label and Partition name
  • Pick the unpartitioned space of the drive with your mouse, right click and create new partition
    • Pick fat32 from drop down
    • Add IMAGES or Label and Partition name
  • Pick Edit Menu -> Apply
  • Right click on CLONEZILLA partition and pick manage flags
    • check boot
  • Exit gparted
  • run command: sync
  • Unplug USB key and wait 10 seconds
  • cd /
  • umount /mnt

Install Clonezilla on USB Key

  • Open a terminal window
  • sudo bash to become root
  • dmesg -w
  • Plug USB key back into computer
    • On most systems the partitions will auto mount and you will get two popup windows showing the contents of CLONEZILLA and IMAGES
    • If not you will see the same messages as before followed by something like this sdh: sdh1 sdh2
      • The numbers are the partitions
    • CTRL+C to exit dmesg -w
    • mount the partition manually if required like this: mount /dev/sdh1 /mnt - change sdh1 with the your device
  • Unzip the clonezilla image into /mnt
    • Easy way is to cp clonezilla-live-*-amd64.zip /mnt*
    • unzip -x clonezilla-live-*amd64.zip
  • copy the grub.cfg file to /mnt/boot/grub
  • cd /
  • umount /mnt

Adding images to the USB key

  • You can boot the USB key if you have secure boot enabled and pick the CSCF menu item to add images
    • The images are saved in the second partition by default
  • You can also copy the images to the images partition as follows:
  • Open a terminal window
  • sudo bash to become root
  • dmesg -w
  • Plug USB key back into computer
    • On most systems the partitions will auto mount and you will get two popup windows showing the contents of CLONEZILLA and IMAGES
    • If not you will see the same messages as before followed by something like this sdh: sdh1 sdh2
      • The numbers are the partitions
    • CTRL+C to exit dmesg -w
    • mount the partition manually if required like this: mount /dev/sdh2 /mnt - change sdhs with the your device
    • Copy any images you want to /mnt for example : cp -r win10-21h1-updates-drivers-sysprep-t470s-2021-10-01-20-img /mnt
  • cd /
  • umount /mnt

Adding a custom menu item to grub.cfg

  • Example - replace IMAGE-img in twice in example below and add to the USB key boot/grub/grub.cfg file
    # Mike GORE
    menuentry "CSCF automatic IMAGE-img" {
      search --set -f /live/vmlinuz
       $linux_cmd /live/vmlinuz net.ifnames=0 biosdevname=0  boot=live  debug=1 quiet   nosplash noprompt config noswap nolocales locales="en_US.UTF-8" vga=771 edd=
    on nomodeset keyboard-layouts=NONE ethdevice-timeout=30 ocs_netlink_timeout="6" ocs_live_batch="yes" ocs_prerun1="mount -t auto /dev/sda2 /home/partimag" ocs_pr
    erun2="sleep 10" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -scr -r -icds -k1 --batch -j2 -p reboot restoredisk IMAGE-img nvme0n1"
       $initrd_cmd /live/initrd.img 
     }
       
Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatcfg grub.cfg r2 r1 manage 14.6 K 2021-10-05 - 22:29 MikeGore  
Unix shell scriptsh makeusb.sh r1 manage 2.1 K 2021-10-12 - 14:31 MikeGore creats a USB key from scratch including partitions
Unix shell scriptsh updateusb.sh r3 r2 r1 manage 2.2 K 2021-10-12 - 15:14 MikeGore Update an existing USB key
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r5 - 2021-10-12 - MikeGore
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback