On Mon, Aug 11, 2025 at 08:30:09AM -0500, Richard Owlett wrote:
> I run Debian 12.8 with MATE.
> I'm prepping to to do needed housekeeping prior to Trixie install.
> Current disk partitioning is *UGLY*!
>
> GParted displays desired information.
> *HOWEVER* I need something that facilitates doing a copy-n-paste of the
> information to a straight text document.
>
> What is the recommended procedure?
sudo fdisk -l /my/device/file
sudo parted -l /my/device/file
There are lots of options regarding format (parted can, among
other things, produce machine-readable JSON for your script's
convenience), so make sure to consult the man page.
For an example of the latter's utility, I once needed to get
the starting point, in bytes, of the first partition, to use
it in some script:
/sbin/parted images/bookworm.img -j -- unit B print list | \
jq ".disk.partitions[] | select(.number = 1) | .start"
=> "1048576B"
(For orientation, the full parted output was...
{
"disk": {
"path": "/home/tomas/virt/builder/bookworm.img",
"size": "10737418240B",
"model": "",
"transport": "file",
"logical-sector-size": 512,
"physical-sector-size": 512,
"label": "msdos",
"max-partitions": 4,
"partitions": [
{
"number": 1,
"start": "1048576B",
"end": "10737418239B",
"size": "10736369664B",
"type": "primary"
}
]
}
}
...and the jq magic in the second line picks the element
in the .disk.partitions array having "number": 1 and
extracts its "size" member. Jq is neat, ain't it?)
> I plead the 5th on what I tried.
Whatever that means, but you're welcome :-)
Cheers
--
t
Attachment:
signature.asc
Description: PGP signature