volume serial number + volume label

Sergey Babkin babkin at verizon.net
Thu Feb 23 04:40:47 PST 2006


>From: andrew clarke <mail at ozzmosis.com>
>
>How can I programmatically retrieve the "volume serial number" and
>"volume label" of a removable disc in FreeBSD?  This is the same
>information that's presented by issuing a "dir" command in Windows:
>
> Volume in drive D is FooBar
> Volume Serial Number is 58BB-96AA

I've been reading on the Windows filesystems recently,
so here is the quick answer:

The serial number is contained in DOS/Windows
partition's boot block, 8 bytes at offset 0x48.

For the label you have to parse the DOS/Windows
filseystem format. On FAT it's the name of the file
in the root directory with the special attribute
(VOL or LABEL - something like this, can't remember 
now). On NTFS it's stored I think as the attribute
$VOLUME_NAME of the system file $Volume contained in the
inode 3 of the Master File Table.

-SB


More information about the freebsd-hackers mailing list