Centos 7 制作 ISO 镜像文件

在日常使用中, 常见的压缩格式如 rar、zip、tar 和 7z 以 仅存档 模式保存文件。这些文件在使用时需要先解压才能访问。而将文件打包成 ISO 镜像后, 可以直接挂载使用, 无需解压, 从而节省了解压时间和硬盘空间。

制作 ISO 镜像的工具

制作 ISO 镜像时, 可能会接触到两个工具名称: mkisofsgenisoimage

实际上, 最初 Linux 系统使用的是 cdrtools 工具套件来管理 ISO 和光盘, 其中 mkisofs 是 cdrtools 的一个组件。后来, 由于 cdrtools 将授权许可从 GPL 修改为 CDDL, 开源社区又推出了基于 GPL 的工具套件 cdrkit, 其中 genisoimage 替代了 mkisofs。目前大多数系统中的 mkisofs 实际上是 genisoimage 的软链接

以下是验证过程的示例

[root@server ~]# whereis mkisofs
mkisofs: /usr/bin/mkisofs /usr/share/man/man1/mkisofs.1.gz

[root@server ~]# ls -l /usr/bin/mkisofs
lrwxrwxrwx. 1 root root 25 Mar 29 05:32 /usr/bin/mkisofs -> /etc/alternatives/mkisofs
[root@server ~]# ls -l /etc/alternatives/mkisofs
lrwxrwxrwx. 1 root root 20 Mar 29 05:32 /etc/alternatives/mkisofs -> /usr/bin/genisoimage

[root@server ~]# whereis genisoimage
genisoimage: /usr/bin/genisoimage /usr/share/man/man1/genisoimage.1.gz
[root@server ~]# ls -l /usr/bin/genisoimage
-rwxr-xr-x. 1 root root 521240 Oct 31  2018 /usr/bin/genisoimage

安装工具

在基于 CentOS 的系统中, 可以通过以下命令安装 genisoimage

yum install genisoimage -y

制作 ISO 镜像

使用 genisoimage 制作镜像时, 通常需要添加 -lJR 参数。如果未添加这些参数, 文件名可能会被裁剪并转为全大写格式, 以符合 ISO-9660 标准。例如

genisoimage -lJR -o output_image.iso directory_name

常用参数说明

参数 说明
-l 允许完整的 31 个字符文件名
-J 生成 Joliet 目录记录, 支持长文件名
-R 使用 Rock Ridge 协议生成共享协议和扩展记录
-allow-multidot 允许文件名中包含多个 .
-o 指定输出文件名

使用 7z 解压 ISO 镜像

使用 7z 查看 ISO 文件内容

7z l acesheep.iso

通过 7z 解压镜像文件, 并设置解压位置

7z x acesheep.iso -oAceSheep-Folder

完整帮助

手册页: mkisofs
手册页备份: mkisofs.8.html.zip

[root@server ~]# genisoimage --help
Usage: genisoimage [options] file...
Options:
  -nobak                      Do not include backup files
  -no-bak                     Do not include backup files
  -abstract FILE              Set Abstract filename
  -A ID, -appid ID            Set Application ID
  -biblio FILE                Set Bibliographic filename
  -cache-inodes               Cache inodes (needed to detect hard links)
  -no-cache-inodes            Do not cache inodes (if filesystem has no unique unides)
  -check-oldnames             Check all imported ISO9660 names from old session
  -check-session FILE         Check all ISO9660 names from previous session
  -copyright FILE             Set Copyright filename
  -debug                      Set debug flag
  -b FILE, -eltorito-boot FILE
                              Set El Torito boot image name
  -e FILE, -efi-boot FILE     Set EFI boot image name
  -eltorito-alt-boot          Start specifying alternative El Torito boot parameters
  -B FILES, -sparc-boot FILES Set sparc boot image names
  -sunx86-boot FILES          Set sunx86 boot image names
  -G FILE, -generic-boot FILE Set generic boot image name
  -jigdo-template-compress ALGORITHM
                              Choose to use gzip or bzip2 compression for template data; default is gzip
  -checksum_algorithm_iso alg1,alg2,...
                              Specify the checksum types desired for the output image
  -checksum_algorithm_template alg1,alg2,...
                              Specify the checksum types desired for the output jigdo template
  -sort FILE                  Sort file content locations according to rules in FILE
  -split-output               Split output into files of approx. 1GB size
  -stream-file-name FILE_NAME Set the stream file ISO9660 name (incl. version)
  -stream-media-size #        Set the size of your CD media in sectors
  -sysid ID                   Set System ID
  -T, -translation-table      Generate translation tables for systems that don't understand long filenames
  -table-name TABLE_NAME      Translation table file name
  -ucs-level LEVEL            Set Joliet UCS level (1..3)
  -udf                        Generate UDF file system
  -dvd-video                  Generate DVD-Video compliant UDF file system
  -uid uid                    Make the owner of all files this uid.
  -U, -untranslated-filenames Allow Untranslated filenames (for HPUX & AIX - violates ISO9660). Forces -l, -d, -N, -allow-leading-dots, -relaxed-filenames, -allow-lowercase, -allow-multidot
  -relaxed-filenames          Allow 7 bit ASCII except lower case characters (violates ISO9660)
  -no-iso-translate           Do not translate illegal ISO characters '~', '-' and '#' (violates ISO9660)
  -allow-lowercase            Allow lower case characters in addition to the current character set (violates ISO9660)
  -allow-multidot             Allow more than one dot in filenames (e.g. .tar.gz) (violates ISO9660)
  -use-fileversion LEVEL      Use file version # from filesystem
  -v, -verbose                Verbose
  -version                    Print the current version
  -V ID, -volid ID            Set Volume ID
  -volset ID                  Set Volume set ID
  -volset-size #              Set Volume set size
  -volset-seqno #             Set Volume set sequence number
  -x FILE, -old-exclude FILE  Exclude file name(depreciated)
  -hard-disk-boot             Boot image is a hard disk image
  -no-emul-boot               Boot image is 'no emulation' image
  -no-boot                    Boot image is not bootable
  -boot-load-seg #            Set load segment for boot image
  -boot-load-size #           Set numbers of load sectors
  -boot-info-table            Patch boot image with info table
  -XA                         Generate XA directory attruibutes
  -xa                         Generate rationalized XA directory attruibutes
  -z, -transparent-compression
                              Enable transparent compression of files
  -hfs-type TYPE              Set HFS default TYPE
  -hfs-creator CREATOR        Set HFS default CREATOR
  -g, -apple                  Add Apple ISO9660 extensions
  -h, -hfs                    Create ISO9660/HFS hybrid
  -map MAPPING_FILE           Map file extensions to HFS TYPE/CREATOR
  -H MAPPING_FILE, -map MAPPING_FILE
                              Map file extensions to HFS TYPE/CREATOR
  -magic FILE                 Magic file for HFS TYPE/CREATOR
  -probe                      Probe all files for Apple/Unix file types
  -mac-name                   Use Macintosh name for ISO9660/Joliet/RockRidge file name
  -no-mac-files               Do not look for Unix/Mac files (depreciated)
  -boot-hfs-file FILE         Set HFS boot image name
  -part                       Generate HFS partition table
  -cluster-size SIZE          Cluster size for PC Exchange Macintosh files
  -auto FILE                  Set HFS AutoStart file name
  -no-desktop                 Do not create the HFS (empty) Desktop files
  -hide-hfs GLOBFILE          Hide HFS file
  -hide-hfs-list FILE         List of HFS files to hide
  -hfs-volid HFS_VOLID        Volume name for the HFS partition
  -icon-position              Keep HFS icon position
  -root-info FILE             finderinfo for root folder
  -input-hfs-charset CHARSET  Local input charset for HFS file name conversion
  -output-hfs-charset CHARSET Output charset for HFS file name conversion
  -hfs-unlock                 Leave HFS Volume unlocked
  -hfs-bless FOLDER_NAME      Name of Folder to be blessed
  -hfs-parms PARAMETERS       Comma separated list of HFS parameters
  -prep-boot FILE             PReP boot image file -- up to 4 are allowed
  -chrp-boot                  Add CHRP boot header
  --cap                       Look for AUFS CAP Macintosh files
  --netatalk                  Look for NETATALK Macintosh files
  --double                    Look for AppleDouble Macintosh files
  --ethershare                Look for Helios EtherShare Macintosh files
  --exchange                  Look for PC Exchange Macintosh files
  --sgi                       Look for SGI Macintosh files
  --macbin                    Look for MacBinary Macintosh files
  --single                    Look for AppleSingle Macintosh files
  --ushare                    Look for IPT UShare Macintosh files
  --xinet                     Look for XINET Macintosh files
  --dave                      Look for DAVE Macintosh files
  --sfm                       Look for SFM Macintosh files
  --osx-double                Look for MacOS X AppleDouble Macintosh files
  --osx-hfs                   Look for MacOS X HFS Macintosh files

Report problems to debburn-devel@lists.alioth.debian.org.

原文

Create iso image from folder via terminal commands
制作CentOS7的ISO镜像

最后更新于 2022-03-30
使用 Hugo 构建
主题 StackJimmy 设计