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


8

.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

Answers:


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]);

测试-(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

我想补充一点,以防ISO额外包含Joliet文件系统,可以从该文件系统中使用卷ID。就我而言,它存储在UTF-16中的偏移量0x8828处。我还添加了以下两行来更改该ID:seek $ file,0x8828,0; binmode($ file,“:encoding(utf-16be)”); printf $ file“%-16.16s”,uc($ ARGV [1]);
Elrohir

2

xorriso可以这样做:

$ xorriso -dev ./VBoxGuestAdditions.iso -volid 'YourLable' -commit
xorriso 1.4.6 : RockRidge filesystem manipulator, libburnia project.

xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE : 32 nodes read in 1 seconds
Drive current: -dev './VBoxGuestAdditions.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Media summary: 1 session, 29111 data blocks, 56.9m data, 20.3g free
Volume id    : 'VBOXADDITIONS_5.1.34_121010'
xorriso : WARNING : -volid text does not comply to ISO 9660 / ECMA 119 rules
ISO image produced: 27 sectors
Written to medium : 192 sectors at LBA 29120
Writing to './VBoxGuestAdditions.iso' completed successfully.

xorriso : NOTE : Re-assessing -outdev './VBoxGuestAdditions.iso'
xorriso : NOTE : Loading ISO image tree from LBA 0
xorriso : UPDATE : 32 nodes read in 1 seconds
Drive current: -dev './VBoxGuestAdditions.iso'
Media current: stdio file, overwriteable
Media status : is written , is appendable
Media summary: 1 session, 29147 data blocks, 56.9m data, 20.3g free
Volume id    : 'YourLable'
$ 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.