Printing and identifying disks
Another short one. Seems like I haven't completed anything interesting lately, but I have a couple of things in the burner. Also, this is mostly for remembering this myself, because I always spend 30m to come up with this invocation1. This is another of those you-wouldn't-need-to-read-this-post-if-you-read-manpages-from-time-to-time posts.
I have a laptop that's the web/home/media/backup server and it's the AP. For many reasons, it has 4 disks8. I also have
like 10 other old disks laying around, waiting for the day I buy a not so old tower to replace the laptop (which is...
13yo). That day, identifying disks will be a necessity. So far, the best tool I have found that gives me an idea what
is what is lsblk, but I'm not satisfied with its default output format:
mdione@diablo:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sdb 8:16 0 1.8T 0 disk └─sdb1 8:17 0 1.8T 0 part /mnt/trash/mdione/public_html/Pictures /home/mdione/public_html/Pictures /home/backup /mnt/data sdc 8:32 0 931.5G 0 disk ├─sdc1 8:33 0 16G 0 part [SWAP] └─sdc2 8:34 0 915.5G 0 part / sdd 8:48 0 698.6G 0 disk └─sdd1 8:49 0 686.6G 0 part /home/mdione/public_html /mnt/trash sde 8:64 0 1.8T 0 disk ├─sde1 8:65 0 23.8M 0 part ├─sde2 8:66 0 1.8T 0 part └─sde3 8:67 0 48.8G 0 part
Why? Because I don't care about MAJ:MIN, but also I need more info: partition table type2, device model3,
and at least available space4.
Now look at this9:
mdione@diablo:~$ lsblk --all --output NAME,TYPE,VENDOR,MODEL,REV,ROTA,HOTPLUG,RO,SIZE,PTTYPE,PARTTYPENAME,PARTUUID,PARTFLAGS,PARTLABEL,FSTYPE,FSSIZE,UUID,FSAVAIL,LABEL,FSROOTS,MOUNTPOINTS
This space intentionally left blank
It is a lot of info, but:
- NAME: yes, and I love the tree.
- TYPE: OK, this might be extra, but to this day
nvme0n1still feels like a partition, and not a whole device. - VENDOR: Yeah, OK, this looks useless for internal disks (the other two are connected via USB, see HOTPLUG).
- MODEL: yes, please
- REV: OK, not that I upgrade disk firmware ever...
- ROTA: HDD vs SSD/Flash/NVME
- HOTPLUG: mostly, USB, see VENDOR6
- RO: maybe useful for RO SDs?
- SIZE: of course. Unluckily I can't find how to ask for a consistent unit (see the G vs M vs T).
- PTTYPE: dos/MBR vs gpt, which is BIOS/legacy vs UEFI.
- PARTTYPENAME: might be misleading, see
sdb1's and the file system it hosts. - PARTUUID: Debian refuses to allow specifying root partiition by label, and this machine detects disks in the 'wrong'
order, rendering it unbootable if I use
/dev/sdXYinstead, so this is important8. - PARTFLAGS: 0x80 is DOS bootable partition, which I need in this non-UEFI machine7.
- FSTYPE: of course.
- FSSIZE: ditto
- UUID: see PARTUUID.
- FSAVAIL: of course.
- LABEL: except for
/, I mount by label. Sue me, Debian. - FSROOTS: My disk usage is weird8. To me it's imporatnt to know what is mounted where. The many entries with non
/FSROOTs are bind mounts. - MOUNTPOINTS: Ditto.
So, in all, this command replaces mount and even mount -t ext4, df -h, fdisk -l, perusing dmesg and maybe more.
-
Yeah, OK, I made a script out of it, OK? And it's now deployed everywhere (2 machines :) via Ansible. ↩
-
For when I'm upgrading disks and the new one is not booting or something, like I did recently. ↩
-
To identify two very similar disks for said upgrades, or make sure that
/dev/sdais not the main disk on the machine5 but a USB pen drive I want to write a rescue image on; otherwise, I would be/dev[astated]/sad. ↩ -
Who doesn't want to know this, right? ↩
-
Since I have a laptop that can handle NVME devices, this has been
/dev/nvme0n1, but almost 3y of novelty can't beat more than two decades of precious/dev/sda. ↩ -
Yes, circular 'see', sue me. ↩
-
TBF, this machine supports it, but the hassle it means to activate that now is beyond what I'm prepared to fix. ↩
-
Rationale is like this: I have an internal SSD (not NVME, this machine is too old), this is
/; an internal HDD for trash, mainly semi throwaway map tiles mounted in mypublic_htmldirectory, and it's full; an external HDD, this is for local backup but also serves my pics from a subdir from mypublic_html; if I have to run and leave everything behind, this is the first/only thing I pick up; and the external NVME on a USB encasing, which is soon to replace the external HDD. ↩↩↩ -
Chízus, Nikola completely fsck'd it up. Sorry for the text file. And TBH, this does not even fits my terminal on a 170%10 3840x2160 27" monitor, but at least looks fine in my navigator. ↩
-
I'm old, OK? ↩