I have done some research on this and found this question many times. However, all the answers I have found only address how to change a partition label.
I am talking about what is reported by lsblk -o label
not lsblk -o partlabel
.
I have created a new partition table and created new partitions with both parted
and fdisk
and I am quite surprised that the old label is still there.
I have tried msdos and gpt as partition tables.
This is all the more confusing because parted
has this mklabel
command with the description "create a new disklabel" but it is equivalent to mktable
and does not change the label.
How is the device label stored so that it's independent of the partition table? How can I change it?
The USB stick did not always have this label, it was named when I put a Debian Live System on it. Now where I would like to use it as a normal USB stick again I would like to give it a different name.
EDIT:
With
# fatlabel /dev/sdb1 TEST
I can change the label
of a partition which is a good step in the right direction but I can not change the label of the device:
# fatlabel /dev/sdb TEST
Currently, only 1 or 2 FATs are supported, not 251.
Same goes for mlabel
which I have installed with pacman -S mtools
:
# mlabel -i /dev/sdb1 TEST
works but
# mlabel -i /dev/sdb TEST
init :: non DOS media
mlabel: Cannot initialize the device
I have created the partition table for gpt with:
# parted /dev/sdb
GNU Parted 3.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable
New disk label type? gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do
you want to continue?
Yes/No? yes
(parted) mkpart
Partition name? []? test partition
parted: invalid token: partition
File system type? [ext2]? fat32
Start? 0%
End? 100%
(parted) q
and for msdos with:
# parted /dev/sdb
GNU Parted 3.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable
New disk label type? msdos
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do
you want to continue?
Yes/No? yes
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? fat32
Start? 0%
End? 100%
(parted) q
EDIT2:
The output of lsblk -o +label,partlabel
before I executed dd if=/dev/zero of=/dev/sdb
:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT LABEL PARTLABEL
sdb 8:16 1 3.8G 0 disk Debian Jessie-DI-rc1 i386 1
└─sdb1 8:17 1 3.8G 0 part Debian Jessie-DI-rc1 i386 1
sudo mlabel -i /dev/sdc1 ::<new_label>
– hanxue Jan 16 '20 at 08:57label
not apartlabel
but it only shows how to change the label of a partion not of a device, I think my question was not explicit enough in that regard. Please see my updated question. – jakun Jan 16 '20 at 10:20mlabel
withpacman -S mtools
I can change the label of a partition with that but I would like to change the label of the device itself. What does the-i
do? It is not mentioned inman mlabel
. – jakun Jan 16 '20 at 10:26lsblk
show the label opposite the device node, or the partition node? – Stephen Kitt Jan 16 '20 at 12:29dd if=/dev/zero of=/dev/sdb
removes the device label. I don't really need to set it, a partition label works as well, but I would be curious to know how to set it, anyway. – jakun Jan 16 '20 at 12:30/dev/sdb
as well as next to the partition/dev/sdb1
if I did not set a label for the partition. – jakun Jan 16 '20 at 12:32/dev/sdb
, where they install their own internal structure. A related question might be https://unix.stackexchange.com/questions/516381/why-is-lsblk-showing-the-old-fstype-and-label-of-a-device-that-was-formatted. – AdminBee Jan 16 '20 at 13:10