Linux – way to change a .iso files volume id from the command line

disk-imageisolinux

I have a .iso file under linux and have been trying to find a way to change the volume id without having to recreate the .iso file. Most of the authoring tools such as mkisofs provide a switch for setting the volume (-V) for example. However I can't figure out how to change it on a pre-existing .iso file.

For clarification, the bit I'm trying to change is this Volume id: string. Here's an example dump from the isoinfo command.

% 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

Best Answer

Volume ID is always stored at offset 0x8028 as 32 byte ASCII string. Edit it in place.

#!/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]);

Test - (isovolid.pl is a name of the above script):

$ 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