These are my links for February 24th from 17:15 to 17:49:
Have you ever needed to change the Volume ID on a pre-existing ISO file? I thought for sure there had to be a command-line tool that would allow for this. But after googling for over an hour I could only find 2 methods to do this.
- The first was simply firing up a GUI, such as ISO Master and changing the Volume ID.
- The second method involved remastering the ISO by copying the files out to a directory, and then essentially recreating a new .iso file.
Neither of these were exactly what I was looking for so I asked the question on serverfault.com. My question: Is there a way to change a .iso files volume id from the command line?. Thankfully someone answered and provided a pretty painless way to manipulate the Volume ID of a .iso file.
NOTE: The Volume ID I’m talking about is this string within a given .iso file, as seen in the example below, or more typically when you mount a CD/DVD in Windows Explorer or Nautilus as the CD/DVD’s label.
% isoinfo -d -i /usr/share/virtualbox/VBoxGuestAdditions.iso | grep "Volume id"
Volume id: VBOXADDITIONS_4.1.8_75467
According to kupson, the person that answered my question, the Volume ID is stored at offset 0×8028 as a 32 byte ASCII string within the .iso file. With this information it’s pretty straightforward to put together a Perl script to manipulate the .iso file.
# SCRIPT: chkisovol.pl
# DESCRIPTION: Change a given .iso file's Volume ID to something else
# - http://perldoc.perl.org/functions/open.html
# - http://serverfault.com/questions/361474/is-there-a-way-to-change-a-iso-files-volume-id-from-the-command-line
die "Use: $0 <iso_file> <new volume id>\n" unless @ARGV == 2;
# open file for read/write updates (+<) doesn't clobber file 1st
open my $file, "+<", $ARGV or die "Cannot open: $!";
seek $file, 0x8028,0;
# write new Volume ID all uppercased (uc). The -32.32s takes care of left
# aligning the output, and forcing it into a 32 byte long string
printf $file "%-32.32s", uc($ARGV);
Now for a test.
% isoinfo -d -i ~/netware.iso |grep "Volume id"
Volume id: VMWTOOLS
# Change the Volume ID
% ./chgisovol.pl ~/netware.iso SOMENEWVOL
isoinfo -d -i ~/netware.iso |grep "Volume id"
Volume id: SOMENEWVOL
Again, thanks to kupson for providing the technique on how to accomplish this.
NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.
These are my links for February 23rd through February 24th: