On Thu, Feb 03, 2011 at 10:52:05AM +0100, Thomas BÃchler wrote: > The reasons for using -p: > 1) I do not want to check the cache, I only want to look at the device > itself. > 2) -p will also return the PTTYPE=... value, so I don't accidently > overwrite a whole disk's partition table and contents. > > While 2) is undocumented, it is another undocumented "feature" that bugs Fixed, man page updated. > me: If there is no file system, raid superblock or similar found, then > blkid will probe the partition table type, and output something like this: > PART_ENTRY_SCHEME="dos" PART_ENTRY_NUMBER="1" > It will return "0" (success), even though the partition did not contain > any file system (or anything else). Fixed, the PART_ENTRY_* tags are returned only when "-o udev" output format is requested. The man page has been updated too. # blkid -p /dev/sdb1; echo $? 2 #blkid -o udev -p /dev/sdb1; echo $? ID_PART_ENTRY_SCHEME=dos ID_PART_ENTRY_TYPE=0x83 ID_PART_ENTRY_NUMBER=1 0 > I would wish I could have a way to use blkid in a way, such that I will > be able to determine (through its return value) whether a device > contains any known file system, raid superblock, partition table, ... - > anything I would not want to overwrite. Note that "blkid -p" also returns "2" if ambivalent probing result was detected (more superblocks on the device). In the next release (v2.19) it will return "8" in this case. The best way to detect empty device is probably: if test -z "$(blkid -o udev -p $device -s TYPE -s PTTYPE)"; then echo "nothing on the device" fi this works in all cases and all util-linux blkid(8) versions. Thanks for your bug report. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html