I have a udev rule for USB sticks with fat32 format. The rule contains such attributes:
SUBSYSTEM=="block", KERNEL=="sd?1", ...
Normally, it works very well for USB sticks that I tested so far, since the most USB sticks are represented in the device node as /dev/sda1
or /dev/sdb1
.
Now, I have a special USB which has a device node as /dev/sda
. The blkid
command of this USB stick returns such outputs:
/dev/sda: UUID="AC9E-6C58" TYPE="vfat"
Compared to the normal one (/dev/sda1
), I miss the PARTUUID
attribute.
Furthermore, The command sfdisk -l /dev/sda
returns these outputs:
Disk /dev/sda: 1021 cylinders, 247 heads, 62 sectors/track
Units: cylinders of 7840768 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 0 - 0 0 0 Empty
/dev/sda2 0 - 0 0 0 Empty
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
This USB has 0 in the /dev/sda1
row. However, the normal USB stick has such entries:
Device Boot Start End #cyls #blocks Id System
/dev/sda1 0+ 2703- 2704- 7835620 b W95 FAT32
start: (c,h,s) expected (0,1,11) found (0,0,57)
end: (c,h,s) expected (1023,125,46) found (975,125,46)
/dev/sda2 0 - 0 0 0 Empty
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
Based on this discussion, it means that the USB stick doesn't have a partition table.
If I don't want to change my udev rules, how can I modify this USB stick? A normal re-partition either with Windows tool or Gparted doesn't change this layout.
If changing the partition layout is not possible, how can I change my udev rule so that it can deal with USB stick which either recognize on /dev/sda or /dev/sda1?
Thanks.
Update: I changed the term "mount" with "device node" to avoid confusion. Thanks to Austin.
Provided that you have no data you need to keep on the USB stick, and that it shows up as /dev/sda
, run the following as root:
wipefs -a /dev/sda
That will erase the FAT32 signature (and any other filesystem signatures too) from the device so it shows up as empty, at which point Both GParted and the Windows disk manager should create a partition table when you go to reformat it.
Also, just to clarify terminology, the kernel does not 'mount' devices to /dev
, it creates device nodes there which can be used to interact with the devices (though, if you've got udev, it may be creating the device nodes instead of the kernel), but mounting is an operation that specifically refers to filesystems (more specifically, to 'mount X to Y' implies that X contains a filesystem, and you're making that filesystem accessible directly at location Y, which is not what's happening when device nodes get created).
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments