Read Linux Disk and Partition Metadata from /proc/partitions
You will inspect the kernel's block-device inventory, identify a disk or partition by its major and minor numbers, and convert its reported size without changing storage. Allow about ten minutes. You need a shell and read access to /proc; the workflow is read-only and normally needs no elevated privileges.
The route
Jump straight to the step you need, or tick off Done means at the end.
1. Confirm the local contract
The installed reference is the proc_partitions(5) page from Linux man-pages 6.7, shipped here by the Debian package manpages version 6.7-2. It defines /proc/partitions as a list containing each entry's major number, minor number, number of 1024-byte blocks and partition name. It does not promise filesystem labels, mount points, UUIDs or a human-friendly size.
Read the exact page installed on the machine before relying on a detail in a script:
$ man 5 proc_partitions
Checkpoint: the page should identify the file as /proc/partitions. If the manual page is absent, stop and check the package installation rather than guessing at a different interface.
2. Display the raw inventory
Print the file directly. This is an ordinary command and does not require sudo:
$ cat /proc/partitions
major minor #blocks name
7 0 13444 loop0
8 0 3907018584 sda
8 1 16777216 sda1
Your entries will differ. The first two data columns are the device's major and minor numbers. The third is a count of 1024-byte blocks, not a count of 512-byte sectors. The final column is the kernel's device name, such as sda, sda1, nvme0n1 or a mapped device.
Do not treat every line as a partition. Whole disks, loop devices, RAID devices and other block devices can appear too. A name ending in a number is a useful clue, not a universal partition rule.
3. Find one device without losing the heading
Use a name anchored to the last column when you need one exact entry. This example selects a placeholder device name and leaves the header visible:
$ DEVICE_NAME='sda1'
$ awk -v wanted="$DEVICE_NAME" 'NR <= 2 || $4 == wanted { print }' /proc/partitions
major minor #blocks name
8 1 16777216 sda1
Replace sda1 only after checking the raw listing. The comparison uses column four because the heading line and the blank line make the first two records special. It also avoids accidentally matching a similar name in another column.
Checkpoint: if the command prints only the heading, the requested name is not present in the current snapshot. Re-read /proc/partitions; device names can change when hardware, virtual disks or mappings appear and disappear.
4. Convert the block count carefully
The manpage's unit is 1024 bytes per block. Convert the third field to MiB and GiB with arithmetic rather than calling it a sector count:
$ awk -v wanted="$DEVICE_NAME" '$4 == wanted { blocks = $3; printf "%s: %d blocks, %.2f MiB, %.2f GiB\n", $4, blocks, blocks / 1024, blocks / 1024 / 1024 }' /proc/partitions
sda1: 16777216 blocks, 16384.00 MiB, 16.00 GiB
These are binary units derived from the file's 1024-byte blocks. They are not a promise about usable filesystem capacity. A filesystem can reserve space, a partition can contain metadata, and a virtual or mapped device may have its own capacity rules.
If the command prints nothing, the device was not present when this read occurred. If it prints a surprising size, compare the raw block count first. Do not resize or repartition anything to make two tools agree.
5. Cross-check before using the result operationally
For a human investigation, compare the entry with another read-only inventory tool if one is installed:
$ lsblk -o NAME,MAJ:MIN,SIZE,TYPE,MOUNTPOINTS
$ findmnt --source "/dev/$DEVICE_NAME"
lsblk can add type, size and mount information that /proc/partitions intentionally does not provide. findmnt may print nothing when the device is not mounted, which is a result rather than an error in /proc/partitions. These commands are supplemental; the authoritative behaviour covered by this guide is the local procfs file.
Keep the device identity together with its major and minor pair when recording an incident. Names can be assigned differently after a reboot or hardware change, while the pair is the more precise identifier for the device represented by that snapshot. Still verify the current machine before acting: an old record is not permission to operate on a newly appearing device.
Common traps and safe boundaries
- Confusing blocks and sectors: divide by 1024 bytes per entry block as documented; do not apply a 512-byte sector conversion.
- Expecting mount data: this file has names and sizes, not mount points, labels or UUIDs. Use a separate read-only tool for those.
- Filtering too broadly:
grep sdacan match several entries. Anchor anawkcomparison to the name field when one device matters. - Using root by reflex: reading the file normally works as an unprivileged user. Elevation does not add missing entries or make a stale snapshot current.
- Taking action from a name alone: do not run formatting, partitioning, mounting or removal commands based only on this listing. Those actions can destroy data or disrupt services and are outside this read-only workflow.
There is no undo step because the examples only read procfs and calculate values in the shell. If a later storage command is needed, stop, identify the device through an independent check, make a backup, and follow the procedure for that storage tool separately.
Done means
- You read the installed
proc_partitions(5)documentation. - You can locate an exact device by its final-column name.
- You can report its major number, minor number and 1024-byte block count.
- You converted the count to binary units without calling it filesystem capacity.
- You cross-checked any operational decision and made no storage changes.