2

regarding blkid command

please help me to approve this assumption

can we say that blkid will print all disk devices only if these disks are with filesystem ( by mkfs )

blkid
/dev/sda1: UUID="cc749f07-ad00-49e8-ab19-eceef99f5e28" TYPE="xfs"
/dev/sda2: UUID="v0593a-KiKU-9emb-STbx-ByMz-S95k-jChr0m" TYPE="LVM2_member"
/dev/sdb: UUID="9b44be8e-fa59-4d84-ada5-1345498663ba" TYPE="ext4"
/dev/sdc: UUID="239505a3-8fb2-4da9-9edd-465299ce15c0" TYPE="ext4"
/dev/sde: UUID="986cd2f3-4d5d-4431-a221-30b142a61c7c" TYPE="ext4"
/dev/sdf: UUID="b8c3c3db-7e13-47b9-b4f9-f706a5223b76" TYPE="ext4"
/dev/sdd: UUID="3c3730ec-d23a-4d1b-8880-224eb658d3ab" TYPE="ext4"
/dev/mapper/vg00-lv_root: UUID="a8c48724-98b7-44b4-89ac-28214462638c" 
TYPE="xfs"
/dev/mapper/vg00-lv_swap: UUID="1beb675f-0b4c-4225-8455-e876cafc5756" 
TYPE="swap"
/dev/mapper/vg00-lv_var: UUID="3de01172-29a2-4b5f-9aef-f9b3032eb7c5" TYPE="xfs"
jango
  • 403
  • 2
  • 13
  • 18
  • 1
    almost duplicate of [How to capture all disks that don’t have a file system](https://unix.stackexchange.com/questions/412483/how-to-capture-all-disks-that-don-t-have-a-file-system) – cas Jan 02 '18 at 07:32
  • Additionally to @cas: `lsblk -a -f -l -o NAME,FSTYP` gives you a list, where the second column is the fiesystem type, if any recognized. So you may look for devices _without_ a filesystem. – ridgy Jan 02 '18 at 12:36
  • @ridgy read the answers and the comments in the linked post. Your suggestion has exactly the same problem as mentioned there. I pointed out several times in the comments and in my answer that `lsblk` does not recognise all valid block devices on linux so does not try to identify what filesystem might be on them `blkid` does a far better job (it works with all kinds of block devices that i'm aware of but as I was careful to point out, that is not an absolute guarantee). – cas Jan 02 '18 at 12:44
  • @cas , I am confuse , you say NO , so can you show me exactly the syntax command that will capture only the disks that with file system or after mkfs ? – jango Jan 02 '18 at 13:05
  • @cas even `blkid` is not reliable. E.g., two loop devices (loop0, loop1) both have three partitions, recognized by `fdisk -l`. But `sudo blkid` (even with `-c /dev/null`) only shows the partitions of loop0, though both devices are equivalent (use just a copy of the same file each). – ridgy Jan 02 '18 at 13:13
  • @cas what you say about my remark? – jango Jan 02 '18 at 14:26
  • what i say is "read the answers and comments in the linked question". then you will understand that `blkid | grep ' TYPE='` will give you most of what want, but it will **not** guarantee that unlisted block devs aren't in use. – cas Jan 03 '18 at 01:36
  • yes I read but you said - formatted with a filesystem or not , so I guess you mean that disk is after mkfs or before , and this mean that blkid according to you will print all disks that are with filesystam and also the disk without filesystem , but what I am say iis that blkid in my Linux print only the disks with filesystem and not the disks without filesystem , so can you please agree with me about this? – jango Jan 03 '18 at 08:19

1 Answers1

0

No.

blkid lists all block devices (of all kinds - including HDD, SSD, USB drive, LVM member, ZFS ZVOL, etc), regardless of whether they have been formatted with a filesystem or not.

cas
  • 1
  • 7
  • 119
  • 185
  • but how you explain that if I add new disk to machine blkid not recognize it , unless we do mkfs then it will appears on blkid – jango Jan 02 '18 at 08:22
  • maybe you not understand what we need , actually we need all disk that mkfs not run on them – jango Jan 02 '18 at 08:30