views:

372

answers:

1

Hi all,

Through a bit of digging, I've discovered how to set and get the volume name of an ext3 partition on my Linux box:

set the volume label

tune2fs -L MY-NEW-NAME /dev/disk/by-path/pci-0000\:00\:1f.2-scsi-2\:0\:0\:0-part1

get the volume's current level

dumpe2fs -h /dev/disk/by-path/pci-0000\:00\:1f.2-scsi-2\:0\:0\:0-part1 | grep 'volume name'

Those work fine, but I have several questions:

1) Are those commands the best way to set/get the volume name? Or is there an easier method that I don't know about?

2) How likely is changing a volume's label to break something? i.e. does a standard Linux system rely on volumes having certain names? Or can I rename volumes to any names I like, without causing problems?

3) At some point I would like to include in my program a GUI interface to the above functionality. One way to do that would be to have my program execute the above shell commands (via system() or whatever), but that seems a bit clunky and heavyweight... are there direct functions that I can call to do the same thing? If so, what are they?

Thanks, Jeremy

+1  A: 

1) What about e2label?
2) The 'mount' command can identify devices via their label, so changing a label could break something inside /etc/fstab.. Anyway normally they aren't used. (At least on Ubuntu and Fedora IIRC)
3) What language are you using? Anyway, it looks like e2label doesn't use any particular API.. It reads and writes to the device directly

Joril
The kernel doesn't care at all, but init scripts and mount (fstab) might.
ephemient
/sbin/vol_id --label <device> - works on other filesystems than extN as well.
Lars Haugseth
I see, I'll update the answer, thanks :)
Joril