10

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
slm
  • 8,010

4 Answers4

12

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
kupson
  • 3,778
4

xorriso can do this:

$ 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'
$ 
slm
  • 8,010
0

TL;DR

xorriso -dev [isofile] -boot_image isolinux keep -boot_image grub keep -volid 'NEWVOL' -commit

I haven't had any luck using only the script provided by @kupson and the command from @illiterate made my ISO file unbootable. I will preface this by saying I'm writing the ISO file to a partition and the partition label reported by blkid/lsblk is not changing (reboot and partprobe had no impact).

isoinfo -d however does pick up the changes. It think the crux of my issue may be I'm still having to use genisoimage, which is basically dead/deprecated. It seems to generate ISO files that don't want to change the label, or at least the way it is being used by me (RHEL8, before xorriso takes it over).

I tried switching direct to xorriso but didn't have luck. I finally stumbled on that I can take my broken ISO file from genisoimage, run it through xorriso to clean it up and pass the parameters to keep it bootable .

At this point, the "isovolid.pl /dev/sdX# LABEL" command worked as expected.

I would have posted this as a comment but serverfault won't let me do that. yay! I can comment on my own answer

Update So after looking at this more, i think i misdiagnosed everything. While this worked for me, it worked because this was removing the joliet filesystem label. But unlike @Elrohir, my joliet label was at position 0x9028. I originally checked for that but believe I was grepping for the wrong case letter like an idiot. So if you made it this far, the isovolid.pl does work with the joliet extensions but you have to find the label location.

0

As suggested by @kupson, you can change the 32 bytes starting at position 32808 in the file. He showed how to do this in perl; you can also use bash and dd:

isovolid()
{

local iso newid oldid id offset=32808 length=32

iso=${1?$'\e[10D'Specify the iso file}

newid=${2?$'\e[10D'Specify the new volume id} oldid=$(dd if=$iso skip=$offset bs=1 count=$length 2>&-)

: "${newid:0:$length}" printf %-${length}s "${_^^}" | dd of=$iso seek=$offset bs=1 conv=notrunc 2>&-

id=$(dd if=$iso skip=$offset bs=1 count=$length 2>&-) printf "Old [$oldid]\nNew [$id]\n"

}

Testing:

$ isovolid memtest86.iso 'abcdefghijklmnopqrstuvwxyz  123456'
Old [MT86PLUS_64                     ]
New [ABCDEFGHIJKLMNOPQRSTUVWXYZ  1234]

$ isoinfo -d -i memtest86.iso | grep Volume.id Volume id: ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234