86 - Dynamically change the disk volume label using grub4dos
Yesterday, I came across the need to have a multiboot grub4dos USB Flash drive that needs to have different volume labels on the same USB drive at different times!
For instance, when I boot one ISO, the volume label of the flash drive needs to be OODIPRO for O&O DiskImage ISO booting, but some other ISOs require a different or at least a known label - e.g. Trinity Rescue and Fedora. It would be nice if grub4dos could change the volume label of the boot device (e.g. USB Flash drive or HDD).
We can use the grub4dos cat command to change the volume label of a FAT16 or FAT32 USB boot drive as follows:
1. First we need to find the sector that that the volume label is in..
In RMPrepUSB - select your multiboot drive and then hit CTRL-D to invoke Disk Doctor - click on the Search Disk button and search for the volume label - e.g. 'MYLABEL' by entering the search string TMYLABEL (the T denotes a non-case sensitive Text search string) - DiskDoctor should display the sector and the label will usually be at the start of the sector followed by the first files in the directory. The volume label is 11 bytes followed by 08 or 28. If the label is shorter than 11 bytes it is always padded out by spaces (20).
# now continue with rest of menu for an ISO or flat file boot...
map /_ISO/OODI_6.8.1_PRO_ENU.ISO (0xff)
map (hd0) (hd1)
map (hd1) (hd0)
chainloader (0xff)/BOOTMGR || chainloader (0xff)
Note that the character after 30704+1 is a vertical bar (OR) character - I recommend you cut and paste the menu so that you get the correct character. Depending on your country and keyboard it may appear as ¦ or | .
You do not need to know which sector the label is in, if you use a large number of sectors to search and already know the volume label - but this will take several seconds and it relies on the volume label being a unique string not found anywhere before the directory entries - e.g.
All of this will only work on FAT volumes though. For NTFS boot drives you would need to modify the code to search and replace unicode 2-byte strings. The length of the string is also crucial, so changing an NTFS volume label is far more complex!