6

It may be a very basic question, but I have USB devices that keep their old name after reformating it with mkfs and even after a repartitioning with fdisk.

I wonder if there is a way to change the disk label with simple basic tools (note that, I do not want to use the mtools as answered here).

perror
  • 216
  • 2
  • 4
  • 16
  • I am a bit surprised after a short web browsing, because I found pages claiming that the volume naming depends on the file system installed on it. But, I had reformated several volumes, changed from one fs to another and the label is still here. So, my guess is that it is located in the MBR and do not depends on the file system... Am I wrong ? – perror Apr 15 '13 at 10:05

2 Answers2

9

It is depends on which file system is in the partition.

If the fs is ext2/ext3/ext4, e2label should work:

e2label  /dev/sda5 my_label

If that is NTFS, choose ntfslabel:

ntfslabel  /dev/sda9  my_label

If that is FAT, choose mtools that is what you already got:

mlabel -i /dev/sda4 ::my_label
perror
  • 216
  • 2
  • 4
  • 16
Hans Chen
  • 449
  • 2
  • 5
  • Is there a way to tag directly the /dev/sda ? My problem is that I have a persistent tag that survive even after deleting and creating new partitions. – perror Apr 15 '13 at 11:26
  • I once had a USB drive that I wrote an iso image to and even recreating the partition table didn't reset the name, so I used dd to overwrite the whole drive with zeros (dd bs=1M if=/dev/zero of=/dev/sdX) and recreated the partition table. – FSMaxB Apr 15 '13 at 12:44
1

If the name you're seeing is descriptive (such as "20GB volume"), it might be something that your file manager is creating in the absence of a true filesystem label. The name is "persistent" only because the file manager is generating the same description when you create a new filesystem without a name. If that's the case, then renaming the filesystem with any of the commands that Hans Chen has mentioned, or with GParted, should do the trick.

The MBR Partitioning system does not support partition labels; however, the GPT system does. To the best of my knowledge, no Linux file browsers display GPT partition labels, though. If you want to edit them, you can use the GPT fdisk (gdisk) tool -- but you should not use gdisk on MBR disks, since it will convert them to GPT form, which will render a disk unbootable until you re-install your boot loader. (gdisk warns you and gives you the chance to abort when you launch it on an MBR disk, so just stay alert to such a warning.)

Rod Smith
  • 21,455
  • 3
  • 43
  • 55