首页 > 其他分享 >mkisofs与isoinfo笔记

mkisofs与isoinfo笔记

时间:2023-06-26 13:55:06浏览次数:44  
标签:isoinfo IMG mkisofs boot 笔记 echo ISO iso ID

#!/usr/bin/env bash

##################################
# Download the Windows 10 x64 ISO

WIN10_IMG_DESTINATION="./windows.iso"
WIN10_IMG_ARCH="x64"

if [ ! -f "${WIN10_IMG_DESTINATION}" ]; then
    if [[ "$WIN10_IMG_ARCH" == "x86" ]] || [[ "$WIN10_IMG_ARCH" == "i386" ]] ; then
        echo "Retrieving the x86 Windows 10 iso URL..."
        WINDOWS_10_ISO_URL=$(curl -LsI -o /dev/null -w %{url_effective} "https://windows101tricks.com/1903-iso-32")
    else
        echo "Retrieving the x64 Windows 10 iso URL..."
        WINDOWS_10_ISO_URL=$(curl -LsI -o /dev/null -w %{url_effective} "https://windows101tricks.com/1903-iso-64")
    fi

    echo "Making sure the URL comes from a trusted Microsoft (sub)domain..."
    if [[ $WINDOWS_10_ISO_URL == https://software-download.microsoft.com/* ]] ; then
        echo "Downloading the Windows 10 installation iso..."
        wget "$WINDOWS_10_ISO_URL" -O "$WIN10_IMG_DESTINATION"
    else
        echo "URL validation failed. Please download the Windows 10 iso manually."
        exit 1
    fi
else
    echo "Windows 10 iso already exists. Skipping download..."
fi
#
##################################



# Variable containing the path to the windows.iso
WIN10_IMG="$WIN10_IMG_DESTINATION"

TMP="./tmp"
ISO_FILES="${TMP}/iso-files"
ISO_MP="${TMP}/iso-mountpoint"

# Remove ./tmp if it already exists, then create ./tmp/iso-files and ./tmp/iso-mountpoint
rm -rf "${TMP}"
mkdir -p "${ISO_FILES}"
mkdir -p "${ISO_MP}"
# Extract the files fromt he ISO to ./tmp/iso-files
sudo mount -t udf "${WIN10_IMG}" "${ISO_MP}"
sudo cp -Rva ${ISO_MP}/* "${ISO_FILES}"
sudo umount "${ISO_MP}"

# Make modifications to the Windows ISO
#BOOT_DIR="${ISO_FILES}/efi/microsoft/boot"
#sudo mv "${BOOT_DIR}/cdboot.efi" "${BOOT_DIR}/tmp.efi"
#sudo mv "${BOOT_DIR}/cdboot_noprompt.efi" "${BOOT_DIR}/cdboot.efi"
#sudo mv "${BOOT_DIR}/tmp.efi" "${BOOT_DIR}/cdboot_noprompt.efi"

# Extract the boot.img (didn't help at all)
#BOOT_SECTOR_LENGTH="$(isoinfo -d -i "${WIN10_IMG}" | grep "Nsect " | grep -o "[^ ]*$")"
#STARTING_SECTOR="$(isoinfo -d -i ./vm-files/windows10.iso | grep "Bootoff " | grep -o "[^ ]*$")"
#dd if="${WIN10_IMG}" of="${ISO_FILES}/boot.img" bs=2048 count="${BOOT_SECTOR_LENGTH}" skip="${STARTING_SECTOR}"


# Extract boot load segment address and size
BOOT_LOAD_SEG="$(dumpet -i "${WIN10_IMG}" | grep "Media load segment: " | cut -d ':' -f2 | cut -d ' ' -f2)"
BOOT_LOAD_SIZE="$(dumpet -i "${WIN10_IMG}" | grep "Load Sectors: " | grep -o "[^:]*$" | cut -d ' ' -f2 | head -1)"

# Extract meta data :
SYSTEM_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "System id: " | cut -d ' ' -f3-)"
VOLUME_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Volume id: " | cut -d ' ' -f3-)"
VOLUME_SET_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Volume set id: " | cut -d ' ' -f4-)"
#PUBLISHER_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Publisher id: " | cut -d ' ' -f3-)" # Always uppercase
PUBLISHER_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "ID '" | cut -d "'" -f2)"
DATA_PREPARER_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Data preparer id: " | cut -d ' ' -f4-)"
APPLICATION_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Application id: " | cut -d ' ' -f3-)"
COPYRIGHT_FILE_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Copyright file id: " | cut -d ' ' -f4-)"
ABSTRACT_FILE_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Abstract file id: " | cut -d ' ' -f4-)"
BIBLIOGRAPHIC_FILE_ID="$(isoinfo -d -i "${WIN10_IMG}" | grep "Bibliographic file id: " | cut -d ' ' -f4-)"

# Create a new ISO image using mkisofs
# (.mkisofsrc is necessary, because some options are not available on the cli directly)
rm ".mkisofsrc"
echo "APPI=${APPLICATION_ID}" >> ".mkisofsrc"
echo "COPY=${COPYRIGHT_FILE_ID}" >> ".mkisofsrc"
echo "ABST=${ABSTRACT_FILE_ID}" >> ".mkisofsrc"
echo "BIBL=${BIBLIOGRAPHIC_FILE_ID}" >> ".mkisofsrc"
echo "PREP=${DATA_PREPARER_ID}" >> ".mkisofsrc"
echo "PUBL=${PUBLISHER_ID}" >> ".mkisofsrc"
echo "SYSI=${SYSTEM_ID}" >> ".mkisofsrc"
echo "VOLI=${VOLUME_ID}" >> ".mkisofsrc"
echo "VOLS=${VOLUME_SET_ID}" >> ".mkisofsrc"

sudo rm "${WIN10_IMG}.tmp.iso"
sudo mkisofs \
  -no-emul-boot \
  -b boot/etfsboot.com \
  -boot-load-seg "${BOOT_LOAD_SEG}" \
  -boot-load-size "${BOOT_LOAD_SIZE}" \
  -eltorito-alt-boot \
  -e efi/boot/bootx64.efi \
  -no-emul-boot \
  -iso-level 2 \
  -boot-info-table \
  -udf \
  -D \
  -N \
  -relaxed-filenames \
  -allow-lowercase \
  -o "${WIN10_IMG}.tmp.iso" \
  "${ISO_FILES}"

rm ".mkisofsrc"


# Print the variables that we gathered
echo
echo "Extracted meta data (form original image):"
echo "BOOT_LOAD_SEG: ${BOOT_LOAD_SEG}"
echo "BOOT_LOAD_SIZE: ${BOOT_LOAD_SIZE}"
echo "-------"
echo "SYSTEM_ID: ${SYSTEM_ID}"
echo "VOLUME_ID: ${VOLUME_ID}"
echo "VOLUME_SET_ID: ${VOLUME_SET_ID}"
echo "PUBLISHER_ID: ${PUBLISHER_ID}"
echo "DATA_PREPARER_ID: ${DATA_PREPARER_ID}"
echo "APPLICATION_ID: ${APPLICATION_ID}"
echo "COPYRIGHT_FILE_ID: ${COPYRIGHT_FILE_ID}"
echo "ABSTRACT_FILE_ID: ${ABSTRACT_FILE_ID}"
echo "BIBLIOGRAPHIC_FILE_ID: ${BIBLIOGRAPHIC_FILE_ID}"

# Show difference between new and old image as reported by isoinfo
echo
echo "-------------- isoinfo diff -----------------"
diff <(isoinfo -d -i "${WIN10_IMG}") <(isoinfo -d -i "${WIN10_IMG}.tmp.iso")

# Show difference between new and old image as reported by dumpet
echo
echo " -------------- dumpet diff -----------------"
diff <(dumpet -i "${WIN10_IMG}") <(dumpet -i "${WIN10_IMG}.tmp.iso")


# Overwrite the original ISO with the new one
#sudo rm "${WIN10_IMG}"
#sudo mv "${WIN10_IMG}.tmp.iso" "${WIN10_IMG}"

 

#!/bin/bash

# provide paths, no closing /

ISO_IMAGE="/path/to/Win10.iso"
ISO_IMAGE_OUT="/path/to/Win10_split.iso"
WORKING_DIR="/home/user/working"

echo "Paths set"
echo "ISO_IMAGE $ISO_IMAGE"
echo "WORKING DIRECTORY: $WORKING_DIR"

# prerequisites
# sudo apt-get install libxml2-dev ntfs-3g-dev libfuse-dev libattr1-dev dumpet

# install schily tools http://schilytools.sourceforge.net/
# alias smake=/opt/schily/bin/smake
# alias mkisofs=/opt/schily/bin/mkisofs

# install wimlib https://wimlib.net/

# git clone git://wimlib.net/wimlib
# cd wimlib

# libtoolize --force
# aclocaldc
# autoheader
# automake --force-missing --add-missing
# autoconf
# ./configure

# sudo make install
# gsudo ldconfig -v

printf "\nRemoving/recreating the working directory\n"
rm -r -d -f $WORKING_DIR
mkdir $WORKING_DIR

printf "\nMounting the ISO image\n"
sudo mount -r -t udf $ISO_IMAGE /media/iso

printf "\nCopying the ISO image contents to the working directory\n"
cp -r /media/iso/* $WORKING_DIR
chmod -R 755 $WORKING_DIR

printf "\nUnmounting the ISO image\n"
sudo umount /media/iso

printf "\nSplitting the install.wim archive\n"
wimsplit $WORKING_DIR/sources/install.wim $WORKING_DIR/sources/install.swm 2000
rm -d -f $WORKING_DIR/sources/install.wim

printf "\nGetting the boot image LBA from the ISO\n----------\n"
dumpet -i $ISO_IMAGE

printf "\nShould be a integer number following the second 'Load LBA': "
read LOAD_LBA

printf "\n"
dd if=$ISO_IMAGE bs=2048 skip=$LOAD_LBA count=1 > $WORKING_DIR/efi/win_efi_boot.img

printf "\nNow we get the boot.img and check the right file size.\nThe below output should detect a 'DOS/MBR boot sector' and sectors size should be 2880 which would mean 2880 * 512 / 2048 = 720.\n----------\n"
file $WORKING_DIR/efi/win_efi_boot.img

printf "\nThat would make the input 720: "
read LOAD_COUNT

printf "\n"
dd if=$ISO_IMAGE bs=2048 skip=$LOAD_LBA count=$LOAD_COUNT > $WORKING_DIR/efi/win_efi_boot.img

printf "\nBuilding an image\n"
/opt/schily/bin/mkisofs \
-no-emul-boot \
-b boot/etfsboot.com \
-boot-load-seg 0 \
-boot-load-size 8 \
-eltorito-alt-boot \
-no-emul-boot \
-b efi/win_efi_boot.img \
-boot-load-size 1 \
-iso-level 4 \
-UDF \
-o $ISO_IMAGE_OUT \
$WORKING_DIR/

printf "\n\nImage ready!\n\n" 

 

oscdimg -m -o -u2 -udfver102 -  
bootdata:2#p0,e,bc:\winpe_x64\etfsboot.com#pEF,e,bc:\winpe_x64\efisys.bin c:\winpe_x64\ISO  
c:\winpe_x64\winpeuefi.iso  
#winpe-uefi
https://learn.microsoft.com/en-us/troubleshoot/windows-server/deployment/create-iso-image-for-uefi-platforms

 

dism /capture-image /imagefile:E:\install.wim
/capturedir:D:\ /ScratchDir:E:\Scratch
/name:"W10PROx64" /compress:maximum
/checkintegrity /verify /bootable

 

参考:

https://www.techtarget.com/searchenterprisedesktop/tip/How-to-create-a-custom-ISO-for-Windows-10

https://unix.stackexchange.com/questions/531012/how-to-modify-an-installation-iso-and-keep-it-bootable

 

标签:isoinfo,IMG,mkisofs,boot,笔记,echo,ISO,iso,ID
From: https://www.cnblogs.com/santia-god/p/17505447.html

相关文章

  • Java学习笔记(十七)
    1、手写一个懒汉式的单例模式&解决其线程安全问题,并且说明为什么这样子去解决classMythreadextendsThread{      privatestaticMythreadmythread;      privateMythread(){   }   publicstaticMythreadgetInstance()throwsInterrupte......
  • 【个人笔记】免费可用中文版ChatGPT,国内免费版ChatGPT
    ChatGPT介绍ChatGPT是个啥?Openai团队研发的一个人工智能聊天程序。Chat:表示“聊天”。GPT:则是Generative、Pre-trained、Transformer的缩写,表示“预训练语言模型”,可以理解成一个“会说话”的人工智能。即:可以对话的人工智能,你问他什么他都可以回答。 为什么那么多免费C......
  • 《编写高质量代码》读书笔记系列开篇
    前言:   时间过的好快,进入这个互联网的fe行业已经快*年了,读书还是一个需要坚持的东东,是一种坚持,因为兴趣所以热爱。 正文:   其实这边书一种在间断地看着,今天组里买了一本,决定开一个系列,静静地品一下,重新审视自己的深度和方向。   1、如何做的更好的Web前端工程师?   ......
  • zabbix配置笔记
    1. 登录zabbix系统配置-模板-创建模板 输入模板名称,选择群组 ......
  • zabbix5.0安装和部署笔记
    zabbix版本5.0,操作系统版本Ubuntu18.04 版本5.0,操作系统版本Ubuntu18.041.安装mysql2.解压这个包tar-xvfmysql-5.7.30-1.el7.x86_64.rpm-bundle.tar3.rpm所有程序sudoaptinstallrpmrpm-Uvh*.rpm--nodeps--forceerrorwhileloadingsharedlibraries:libaio.so.1:......
  • Java学习笔记(十六)
    1.什么是线程?线程是指操作系统中的一种执行单元,它是进程中的一部分,可以看作是轻量级的进程。与进程不同的是,线程共享同一进程的地址空间和系统资源,如打开文件和信号处理等,但每个线程都有自己的程序计数器(PC)和栈,用于执行代码和存储局部变量等数据。2。线程和进程有什么区别?线......
  • 人生观察语料学习笔记133
    标题記憶喪失の人を騙し続けたら?如果一直欺骗一个失去记忆的人会怎么样呢?きおく(記憶)【名】记忆そうしつ(喪失)【名】丧失ひと(人)【名】人だます(騙す)【他动词・五段/一类】欺骗つづく(続く)【自动词・五段/一类】继续つづ......
  • 李超线段树 学习笔记
    李超线段树学习笔记今天模拟赛用到了李超线段树(但是本蒟蒻费了半天劲搞了个斜率优化拿到了60pts的好成绩/kk),所以学习一下李超线段树刻不容缓(学会了我貌似也切不来那道题qwq)。引入初中和高中我们都做过函数题吧,是不是有时候给你两根甚至几根直线,然后问你某个点的最值?当然,......
  • 「学习笔记」vector
    本文并不是vector的入门教程。定义std::vector是封装动态数组的顺序容器。vector通常占用多于静态数组的空间,因为要分配更多内存以管理将来的增长。如果元素数量已知,可以使用reserve()函数提前分配内存。操作函数由于vector大家比较熟悉了,这里给大家带来一些其他......
  • C语言学习笔记
    斐波那契定义:斐波那契数列是一个数列,其中每个数字是前两个数字之和,起始于0和1。数列的定义如下:F(0)=0F(1)=1F(n)=F(n-1)+F(n-2)(对于n>1)换句话说,斐波那契数列的第n个数字是前两个数字之和,而前两个数字分别是0和1。数列的前几个数字如下所示:0,1,1,......