1LIBBLKID(3) Programmer's Manual LIBBLKID(3)
2
3
4
6 libblkid - block device identification library
7
9 #include <blkid.h>
10
11 cc file.c -lblkid
12
14 The libblkid library is used to identify block devices (disks) as to
15 their content (e.g. filesystem type) as well as extracting additional
16 information such as filesystem labels/volume names, unique identi‐
17 fiers/serial numbers. A common use is to allow use of LABEL= and UUID=
18 tags instead of hard-coding specific block device names into configura‐
19 tion files.
20
21 The low-level part of the library also allows to extract information
22 about partitions and block device topology.
23
24 The high-level part of the library keeps information about block
25 devices in a cache file and is verified to still be valid before being
26 returned to the user (if the user has read permission on the raw block
27 device, otherwise not). The cache file also allows unprivileged users
28 (normally anyone other than root, or those not in the "disk" group) to
29 locate devices by label/id. The standard location of the cache file
30 can be overridden by the environment variable BLKID_FILE.
31
32 In situations where one is getting information about a single known
33 device, it does not impact performance whether the cache is used or not
34 (unless you are not able to read the block device directly).
35
36 The high-level part of the library supports two methods to evaluate
37 LABEL/UUID. It reads information directly from a block device or read
38 information from /dev/disk/by-* udev symlinks. The udev is preferred
39 method by default.
40
41 If you are dealing with multiple devices, use of the cache is highly
42 recommended (even if empty) as devices will be scanned at most one time
43 and the on-disk cache will be updated if possible.
44
45 In some cases (modular kernels), block devices are not even visible
46 until after they are accessed the first time, so it is critical that
47 there is some way to locate these devices without enumerating only vis‐
48 ible devices, so the use of the cache file is required in this situa‐
49 tion.
50
52 The standard location of the /etc/blkid.conf config file can be over‐
53 ridden by the environment variable BLKID_CONF. For more details about
54 the config file see blkid(8) man page.
55
57 libblkid was written by Andreas Dilger for the ext2 filesystem utili‐
58 ties, with input from Ted Ts'o. The library was subsequently heavily
59 modified by Ted Ts'o.
60
61 The low-level probing code was rewritten by Karel Zak.
62
64 libblkid is available under the terms of the GNU Library General Public
65 License (LGPL), version 2 (or at your discretion any later version).
66
68 blkid(8), findfs(8)
69
71 libblkid is part of the util-linux package since version 2.15 and is
72 available from https://www.kernel.org/pub/linux/utils/util-linux/.
73
74
75
76util-linux May 2009 LIBBLKID(3)