brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: parted print free shows the unused space on a disk

Disk
~/tips/tip-disk-parted-print-free-space

sudo parted /dev/sdb unit GiB print free

Lists partitions together with the unallocated gaps between them, in readable units.

Before I add a partition I want to see where the gaps are. A plain partition table print hides them.

sudo parted /dev/sdb unit GiB print free

print free adds the unallocated areas as extra rows labelled Free Space, and unit GiB makes the sizes easy to read. The command only reads and changes nothing. It also works on GPT and MBR disks alike. Be careful with the commands you type after it inside an interactive parted session: mkpart and rm write to the partition table immediately, there is no confirmation step at the end.

Further reading: parted manual page

More Disk tips sudo e2freefrag /dev/sdb1 sudo smartctl -a --json /dev/sda | jq '.smart_status.passed' lsscsi -s udisksctl power-off -b /dev/sdX du -sh — .[!.]* * 2>/dev/null | sort -h All Disk tips (44) All topics

Link