Search code examples
linuxbashlive-cd

How can I customise an ISO image of Webconverger with a Linux shell script?


I want to write a simple shell script that downloads the latest ISO image of Webconverger and changes the boot parameters of grub in /boot/live.cfg.

So this is what I have done so far:

#!/bin/bash
# 1. Download the ISO
wget https://build.webconverger.com/latest.iso

# 2. Mount the ISO and create a development folder
sudo mkdir /mnt/webconverger
sudo mount -o loop latest.iso /mnt/webconverger

mkdir devfolder
rsync -av /mnt/webconverger/ devfolder/

sudo umount /mnt/webconverger
sudo rm -r /mnt/webconverger

# 3. Change the file in the development folder. 
chmod -R 777 devfolder/

rm devfolder/boot/live.cfg
echo \
"DEFAULT de

label de
    menu label Start
    kernel /live/vmlinuz
    append initrd=/live/initrd.img boot=live skipconfig quiet splash components=gitfs net.ifnames=0 bootfrom=removable locale=de xkb=-layout%20de homepage=https://www.google.de/" \
> devfolder/boot/live.cfg

# 4. Create a new ISO image
mkisofs -o new.iso -l devfolder
rm -r devfolder/

The generated ISO does not boot. I asume the reasons for the problem are, that I had to run the whole script with root privileges and that I need a more complex mkisofs command.

Does anybody know how to generate a proper ISO image for Webconverger with a shell script? Or is there an alternative method for the whole process? Something like ISO Master but for the command line?


Update

I have replaced the code snippets with the actual shell script. So it is easier to test. And here is the command line output (without the wget part):

mount: /dev/loop0 is write-protected, mounting read-only
sending incremental file list
./
boot/
boot/boot.bin
boot/boot.cat
boot/live.cfg
boot/syslinux/
boot/syslinux/ldlinux.c32
boot/syslinux/libcom32.c32
boot/syslinux/libutil.c32
boot/syslinux/splash.png
boot/syslinux/syslinux.cfg
boot/syslinux/vesainfo.c32
boot/syslinux/vesamenu.c32
live/
live/initrd.img
live/vmlinuz
live/filesystem.git/
live/filesystem.git/HEAD
live/filesystem.git/config
live/filesystem.git/description
live/filesystem.git/packed-refs
live/filesystem.git/shallow
live/filesystem.git/branches/
live/filesystem.git/hooks/
live/filesystem.git/hooks/applypatch-msg.sample
live/filesystem.git/hooks/commit-msg.sample
live/filesystem.git/hooks/post-update.sample
live/filesystem.git/hooks/pre-applypatch.sample
live/filesystem.git/hooks/pre-commit.sample
live/filesystem.git/hooks/pre-push.sample
live/filesystem.git/hooks/pre-rebase.sample
live/filesystem.git/hooks/pre-receive.sample
live/filesystem.git/hooks/prepare-commit-msg.sample
live/filesystem.git/hooks/update.sample
live/filesystem.git/info/
live/filesystem.git/info/exclude
live/filesystem.git/objects/
live/filesystem.git/objects/info/
live/filesystem.git/objects/pack/
live/filesystem.git/objects/pack/pack-1aa978c13266848f4644754d1875dc90ec4bfcdb.idx
live/filesystem.git/objects/pack/pack-1aa978c13266848f4644754d1875dc90ec4bfcdb.pack
live/filesystem.git/refs/
live/filesystem.git/refs/heads/
live/filesystem.git/refs/heads/master
live/filesystem.git/refs/remotes/
live/filesystem.git/refs/remotes/origin/
live/filesystem.git/refs/remotes/origin/HEAD
live/filesystem.git/refs/tags/
live/filesystem.git/refs/tags/initial-revision

sent 598,528,659 bytes  received 726 bytes  239,411,754.00 bytes/sec
total size is 598,380,033  speedup is 1.00
I: -input-charset not specified, using utf-8 (detected in locale settings)
  1.71% done, estimate finish Tue Jul 10 20:12:54 2018
  3.42% done, estimate finish Tue Jul 10 20:12:54 2018
  5.13% done, estimate finish Tue Jul 10 20:13:13 2018
  6.84% done, estimate finish Tue Jul 10 20:13:08 2018
  8.55% done, estimate finish Tue Jul 10 20:13:05 2018
 10.26% done, estimate finish Tue Jul 10 20:13:03 2018
 11.97% done, estimate finish Tue Jul 10 20:13:02 2018
 13.68% done, estimate finish Tue Jul 10 20:13:01 2018
 15.39% done, estimate finish Tue Jul 10 20:13:00 2018
 17.10% done, estimate finish Tue Jul 10 20:12:59 2018
 18.81% done, estimate finish Tue Jul 10 20:12:59 2018
 20.52% done, estimate finish Tue Jul 10 20:12:58 2018
 22.23% done, estimate finish Tue Jul 10 20:12:58 2018
 23.94% done, estimate finish Tue Jul 10 20:12:58 2018
 25.65% done, estimate finish Tue Jul 10 20:12:57 2018
 27.36% done, estimate finish Tue Jul 10 20:12:57 2018
 29.07% done, estimate finish Tue Jul 10 20:12:57 2018
 30.78% done, estimate finish Tue Jul 10 20:12:57 2018
 32.49% done, estimate finish Tue Jul 10 20:12:57 2018
 34.20% done, estimate finish Tue Jul 10 20:12:56 2018
 35.91% done, estimate finish Tue Jul 10 20:12:56 2018
 37.62% done, estimate finish Tue Jul 10 20:12:56 2018
 39.33% done, estimate finish Tue Jul 10 20:12:56 2018
 41.04% done, estimate finish Tue Jul 10 20:12:56 2018
 42.75% done, estimate finish Tue Jul 10 20:12:56 2018
 44.46% done, estimate finish Tue Jul 10 20:12:56 2018
 46.17% done, estimate finish Tue Jul 10 20:12:56 2018
 47.88% done, estimate finish Tue Jul 10 20:12:56 2018
 49.59% done, estimate finish Tue Jul 10 20:12:56 2018
 51.30% done, estimate finish Tue Jul 10 20:12:55 2018
 53.02% done, estimate finish Tue Jul 10 20:12:55 2018
 54.72% done, estimate finish Tue Jul 10 20:12:55 2018
 56.44% done, estimate finish Tue Jul 10 20:12:55 2018
 58.14% done, estimate finish Tue Jul 10 20:12:55 2018
 59.86% done, estimate finish Tue Jul 10 20:12:55 2018
 61.56% done, estimate finish Tue Jul 10 20:12:55 2018
 63.28% done, estimate finish Tue Jul 10 20:12:55 2018
 64.98% done, estimate finish Tue Jul 10 20:12:55 2018
 66.70% done, estimate finish Tue Jul 10 20:12:55 2018
 68.40% done, estimate finish Tue Jul 10 20:12:55 2018
 70.12% done, estimate finish Tue Jul 10 20:12:55 2018
 71.82% done, estimate finish Tue Jul 10 20:12:55 2018
 73.54% done, estimate finish Tue Jul 10 20:12:55 2018
 75.24% done, estimate finish Tue Jul 10 20:12:55 2018
 76.96% done, estimate finish Tue Jul 10 20:12:55 2018
 78.66% done, estimate finish Tue Jul 10 20:12:55 2018
 80.38% done, estimate finish Tue Jul 10 20:12:55 2018
 82.08% done, estimate finish Tue Jul 10 20:12:55 2018
 83.80% done, estimate finish Tue Jul 10 20:12:55 2018
 85.50% done, estimate finish Tue Jul 10 20:12:55 2018
 87.22% done, estimate finish Tue Jul 10 20:12:55 2018
 88.92% done, estimate finish Tue Jul 10 20:12:55 2018
 90.64% done, estimate finish Tue Jul 10 20:12:55 2018
 92.34% done, estimate finish Tue Jul 10 20:12:55 2018
 94.06% done, estimate finish Tue Jul 10 20:12:55 2018
 95.76% done, estimate finish Tue Jul 10 20:12:55 2018
 97.48% done, estimate finish Tue Jul 10 20:12:55 2018
 99.18% done, estimate finish Tue Jul 10 20:12:55 2018
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 30720
Path table size(bytes): 222
Max brk space used 2b000
292387 extents written (571 MB)

And this what I get in VirtualBox: Click here!


Solution

  • What you want to do is to generate an El Torito bootable CD with an MBR in its first bytes.

    mkisofs(8) needs some special options to create an "El Torito" bootable CD:

    mkisofs -r -J -l -V "Webconverger" -b boot/boot.bin -c boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o new.iso devfolder
    

    Explaination:

    -r -J: Enable Joliet and Rock Ridge meta data.
    -l: Allow long filenames.
    -V: Set volume ID. Optional.
    -b: Specify the "El Torito" boot image.
    -c: Specify the "El Torito" boot catalog.
    -no-emul-boot: Specify that this is an "El Torito" bootable CD.
    -boot-load-size: number of 512 bytes sector to load (4 is what usually works)
    -boot-info-table: modify the original boot image appending the Boot Info Table
    

    Then, if you want to be able to just dd the file on a USB drive you will need to write an MBR onto the ISO:

    isohybrid new.iso