1 (edited by enda 2012-08-13 21:09:25)

Topic: [SOLVED] Cannot set partition label

The usb drive works fine, I can read and write files, there is a /dev/sdb , but no /dev/sdb1 .

GParted 0.12.1 --enable-libparted-dmraid

Libparted 2.3

Set Partition Label "USBDRIVE" on /dev/sdb1  00:00:00    ( ERROR )
        
calibrate /dev/sdb1  00:00:00    ( SUCCESS )
        
path: /dev/sdb1
start: 0
end: 15,794,175
size: 15,794,176 (7.53 GiB)
Set partition label to "USBDRIVE" on /dev/sdb1  00:00:00    ( ERROR )
        
export MTOOLSRC=/tmp/gparted-XYgBZIW4 && mlabel H:"USBDRIVE"
        
Can't open /dev/sdb1: No such file or directory
Cannot initialize 'H:'
mlabel: Cannot initialize drive

2

Re: [SOLVED] Cannot set partition label

Perhaps the USB drive does not have a partition table, and is instead simply formatted with a file system.

Would you be able to provide the output from the following command?

fdisk -l -u

where one of the options is a lower case "L" and not the number one.

3

Re: [SOLVED] Cannot set partition label

Disk /dev/sdb: 8086 MB, 8086618112 bytes
249 heads, 62 sectors/track, 1023 cylinders, total 15794176 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6b10756d

This doesn't look like a partition table
Probably you selected the wrong device.

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   ?   778135908  1919645538   570754815+  72  Unknown
/dev/sdb2   ?   168689522  2104717761   968014120   65  Novell Netware 386
/dev/sdb3   ?  1869881465  3805909656   968014096   79  Unknown
/dev/sdb4   ?  2885681152  2885736650       27749+   d  Unknown

Partition table entries are not in disk order

4

Re: [SOLVED] Cannot set partition label

Based on the output from fdisk, it would appear that the USB drive does not contain a partition table.

As such, you might try the following command to determine the current label on the USB drive:

sudo dosfslabel /dev/sdb

If this returns the label you expect, then you might try changing the label with:

sudo dosfslabel /dev/sdb "MyNewLabel"

Be sure to have a backup of your data in case this does not work as you expect.

5

Re: [SOLVED] Cannot set partition label

$ sudo dosfslabel /dev/sdb
Currently, only 1 or 2 FATs are supported, not 0.

6

Re: [SOLVED] Cannot set partition label

enda wrote:
$ sudo dosfslabel /dev/sdb
Currently, only 1 or 2 FATs are supported, not 0.

Hmm... that was not the output I expected.

Perhaps you have more than one drive configured as a motherboard BIOS RAID.  If so you might try listing the contents of the /dev/mapper directory to see if there are any entries for RAID devices.

ls -l /dev/mapper

7

Re: [SOLVED] Cannot set partition label

$ ls -l /dev/mapper
total 0
crw------T 1 root root 10, 236 Aug 2  2012 control

8

Re: [SOLVED] Cannot set partition label

Hmm.... I don't know how this device is formatted or partitioned.  Perhaps there is some encryption level involved?

9

Re: [SOLVED] Cannot set partition label

gedakc wrote:

Hmm.... I don't know how this device is formatted or partitioned.  Perhaps there is some encryption level involved?

It is formatted with the NTFS file-system on Windows 7.

There is no encryption.

On Windows, nothing seems amiss (reading and writing to the device work fine). On Linux, nothing seems amiss (reading and writing to the device work fine) except that there is a /dev/sdb and no /dev/sdb1 .

10

Re: [SOLVED] Cannot set partition label

enda wrote:

It is formatted with the NTFS file-system on Windows 7.

On Windows, nothing seems amiss (reading and writing to the device work fine). On Linux, nothing seems amiss (reading and writing to the device work fine) except that there is a /dev/sdb and no /dev/sdb1 .

This extra information helps to clarity the situation.

Since you know that the USB drive is formatted with NTFS, and since you know there is a /dev/sdb, but no sdb1, that should mean that there is no partition table, and that the entire USB device is formatted as NTFS.

As such, dosfslabel is the wrong command as this is used for FAT16 and FAT32 file systems.

To confirm that the USB drive is formatted as NTFS, you should be able to view the current NTFS label using the following command:

sudo ntfslabel --force /dev/sdb

If this works as expected, you might try setting the NTFS label with the following command:

sudo ntfslable --force /dev/sdb "MyLabel"

NOTE:  Be sure to have a backup of your data in case this does not work as you expect.

11

Re: [SOLVED] Cannot set partition label

I changed the drive's name in Windows 7, and in Linux, I get the desired result:

$ sudo ntfslabel /dev/sdb
USBDRIVE

Thanks.

12

Re: [SOLVED] Cannot set partition label

'Glad to hear you were able to resolve the problem.

To help others searching for answers to similar problems, you can edit the initial post and prefix "SOLVED" in front of the title.