有没有办法从命令行更改 .iso 文件卷 ID?

slm*_*slm 8 linux iso disk-image

.iso在 linux 下有一个文件,并且一直试图找到一种无需重新创建.iso文件即可更改卷 ID 的方法。例如,大多数创作工具都mkisofs提供了用于设置音量的开关(-V)。但是我不知道如何在预先存在的.iso文件上更改它。

为了澄清起见,我想改变的一点是这个Volume id:字符串。这是来自 isoinfo 命令的示例转储。

% isoinfo -d -i /usr/share/virtualbox/VBoxGuestAdditions.iso 
CD-ROM is in ISO 9660 format
System id: Win32
Volume id: VBOXADDITIONS_4.1.8_75467
Volume set id: 
Publisher id: 
Data preparer id: 
Application id: MKISOFS ISO 9660/HFS FILESYSTEM BUILDER & CDRECORD CD-R/DVD CREATOR (C) 1993 E.YOUNGDALE (C) 1997 J.PEARSON/J.SCHILLING
Copyright File id: 
Abstract File id: 
Bibliographic File id: 
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 22203
Joliet with UCS level 3 found
Rock Ridge signatures version 1 found
Run Code Online (Sandbox Code Playgroud)

kup*_*son 11

卷 ID 始终作为 32 字节 ASCII 字符串存储在偏移量 0x8028 处。就地编辑。

#!/usr/bin/perl
use strict;
use warnings;

die "Use: $0 <iso_file> <new volume id>\n" unless @ARGV == 2;
open my $file, "+<", $ARGV[0] or die "Cannot open: $!";
seek $file, 0x8028,0;
printf $file "%-32.32s", uc($ARGV[1]);
Run Code Online (Sandbox Code Playgroud)

测试 - (isovolid.pl 是上述脚本的名称):

$ genisoimage -V A123456798012345678901234567890X -o aaa.iso *
$ isoinfo -d -i aaa.iso | grep 'Volume id:'
Volume id: A123456798012345678901234567890X
$ ./isovolid.pl aaa.iso NEWVOLUMEID
$ isoinfo -d -i aaa.iso | grep 'Volume id:'
Volume id: NEWVOLUMEID
Run Code Online (Sandbox Code Playgroud)