【问题标题】:How can I customise an ISO image of Webconverger with a Linux shell script?如何使用 Linux shell 脚本自定义 Webconverger 的 ISO 映像?
【发布时间】:2018-07-10 14:14:28
【问题描述】:

我想写一个简单的shell脚本来下载Webconverger的最新ISO镜像并在/boot/live.cfg更改grub的启动参数。

这就是我到目前为止所做的:

#!/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/

生成的 ISO 无法启动。 我认为问题的原因是,我必须以 root 权限运行整个脚本,并且我需要一个更复杂的 mkisofs 命令。

有人知道如何使用 shell 脚本为 Webconverger 生成正确的 ISO 映像吗?或者整个过程是否有替代方法?类似于 ISO Master 但用于命令行的东西?


更新

我已将代码 sn-ps 替换为实际的 shell 脚本。所以更容易测试。这是命令行输出(没有 wget 部分):

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)

这是我在 VirtualBox 中得到的: Click here!

【问题讨论】:

    标签: linux bash live-cd


    【解决方案1】:

    所以这个问题的完整答案是:

    #!/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. 
    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://duckduckgo.com nobrand" \
    | sudo tee devfolder/boot/live.cfg
    
    # 4. Create a new ISO image
    sudo 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
    sudo isohybrid new.iso
    sudo rm -r devfolder/
    

    由于某种原因 dd 不适用于 Webconverger 图像。即使使用原封不动的latest.iso,也无法创建可启动的 USB 闪存驱动器。所以我使用了Win32DiskImager

    【讨论】:

      【解决方案2】:

      您要做的是生成一个 El Torito 可引导 CD,其第一个字节中包含 MBR

      mkisofs(8) 需要一些特殊选项来创建“El Torito”可启动 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
      

      说明:

      -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
      

      然后,如果您希望能够仅dd USB 驱动器上的文件,则需要将 MBR 写入 ISO:

      isohybrid new.iso
      

      【讨论】:

      • 谢谢!这就像一个魅力。我仍然收到I: -input-charset not specified, using utf-8 (detected in locale settings),但我不知道它是什么意思。
      • 这意味着它正在解释输入文件名,因为它们是 UTF-8 编码的。这可能是一个安全的选择,除非您有理由相信文件名是另一种编码。
      猜你喜欢
      • 2017-03-09
      • 2011-09-06
      • 1970-01-01
      • 1970-01-01
      • 2019-12-01
      • 1970-01-01
      • 2021-05-22
      • 2015-03-26
      • 1970-01-01
      相关资源
      最近更新 更多