blkid
should work with unmounted disks, but you must make sure that the disk is formatted.
List disks:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1,7T 0 disk
sdb 8:16 0 300G 0 disk
sdc 8:32 0 64G 0 disk
├─sdc1 8:33 0 63G 0 part /
├─sdc2 8:34 0 1K 0 part
└─sdc5 8:37 0 975M 0 part [SWAP]
Before format:
$ blkid -o list
device fs_type label mount point UUID
----------------------------------------------------------------------------------------------------------------------------
/dev/sdc1 ext4 / 9c49994f-6ffd-496a-945b-85e3b04a84ef
/dev/sdc5 swap [SWAP] f14ea985-e1e6-43a8-ba09-12a273604c96
Note: /dev/sdb
is not shown.
Format disk with ext4:
$ mkfs.ext4 /dev/sdb
mke2fs 1.46.2 (28-Feb-2021)
Discarding device blocks: done
Creating filesystem with 78643200 4k blocks and 19660800 inodes
Filesystem UUID: d4b71992-fbc3-4263-b974-e5933a1ebfe4
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
Now running blkid
again:
$ blkid -o list
device fs_type label mount point UUID
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/dev/sdc1 ext4 / 9c49994f-6ffd-496a-945b-85e3b04a84ef
/dev/sdc5 swap [SWAP] f14ea985-e1e6-43a8-ba09-12a273604c96
/dev/sdb ext4 (not mounted) d4b71992-fbc3-4263-b974-e5933a1ebfe4