Re: blkid: need to determine whether it is "safe" to overwrite a block device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



First of all, thanks for your replies and quick fixes Karel.

Am 03.02.2011 13:17, schrieb Karel Zak:
>> 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. 

This was something I was a bit worried about, but ignored it - all
recent versions of the commonly used tools (mkswap, cryptsetup, mkfs.*)
avoid this situation entirely. It would only be a problem for legacy
systems.

>  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.

This will still return nothing in case of ambivalent results, right? Or
would is print an ID_FS_AMBIVALENT line?


However, with the changes queued up for 2.19, my method of using 'blkid
-p' should do exactly what I want (correct me if I am wrong here).

Raising the userspace requirement to 2.18 with the backported patches
(they apply cleanly to the 2.18 source) or to 2.19 is not a problem in
my case, so I'll probably go with that.

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux