Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

partition table

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
fwm
Posts: 8
Joined: 2024-03-16 20:06

partition table

#1 Post by fwm »

How to print partition table in sector order?
root@debian:~# fdisk -ul /dev/sda gives me:
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 72962047 72960000 34.8G 83 Linux
/dev/sda2 413618176 488396799 74778624 35.7G 5 Extended
/dev/sda3 72962048 145862655 72900608 34.8G 83 Linux
/dev/sda4 145862656 220833791 74971136 35.7G 83 Linux
/dev/sda5 486397952 488396799 1998848 976M 82 Linux swap / Solaris
the printout is in partition order
I want a printout in sector order like

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 72962047 72960000 34.8G 83 Linux
/dev/sda3 72962048 145862655 72900608 34.8G 83 Linux
/dev/sda4 145862656 220833791 74971136 35.7G 83 Linux
free 220833792 413618175 192784384 91,93 G
/dev/sda2 413618176 488396799 74778624 35.7G 5 Extended
/dev/sda5 486397952 488396799 1998848 976M 82 Linux swap / Solaris

Thanks

User avatar
sunrat
Administrator
Administrator
Posts: 6511
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 119 times
Been thanked: 489 times

Re: partition table

#2 Post by sunrat »

Use code tags for terminal text please.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

User avatar
lewulff
Posts: 107
Joined: 2008-12-07 16:55
Location: Tagaytay Philippines
LinkedIN: www.linkedin.com/in/
Has thanked: 3 times
Been thanked: 13 times
Contact:

Re: partition table

#3 Post by lewulff »

If you have sudo access, and parted is installed the following should print out the drive content in sector order, though it will use sizes spacing (KB, MB, GB) instead of sector numbers.

Code: Select all

sudo parted -l

mrmazda
Posts: 339
Joined: 2023-06-02 02:22
Has thanked: 9 times
Been thanked: 44 times

Re: partition table

#4 Post by mrmazda »

Partition tables can be reconstructed so that logical order in the tables can coincide with physical order on disk. I'm not sure there is any option using parted, fdisk , gdisk, or other common free tools that facilitate doing this. Thus reordering the tables changes device names, because device names are assigned in table order. An uncommon partitioning tool, recently made open source, which happens to have binaries for each of DOS, Linux, Mac, OS/2 & Windows, and I've been using exclusively for table write purposes for over two decades, does IIRC have a menu selection that will rebuild the table in coinciding order: DFSee. It also logs, supports scripts, and shows size and location of freespaces, while omitting the often misleading definition of the extended, which it automatically sizes according to requirements of the defined partitions. I use its logs to inventory the content of all the disks in my 50+ computers.

I believe the output you wish for will require you do it manually:

Code: Select all

Device    Start     End       Sectors   Size  Id Type
/dev/sda1      2048  72962047  72960000 34.8G 83 Linux
/dev/sda3  72962048 145862655  72900608 34.8G 83 Linux
/dev/sda4 145862656 220833791  74971136 35.7G 83 Linux
free      220833792 413618175 192784384 91.9G
/dev/sda2 413618176 488396799  74778624 35.7G 5  Extended
/dev/sda5 486397952 488396799   1998848 976M  82 Linux swap / Solaris

fwm
Posts: 8
Joined: 2024-03-16 20:06

Re: partition table

#5 Post by fwm »

Thanks for the input.
I will have to read up on code tags.

mrmazda
Posts: 339
Joined: 2023-06-02 02:22
Has thanked: 9 times
Been thanked: 44 times

Re: partition table

#6 Post by mrmazda »

If you simply click on the reply button in post #3 or #4 you can see how simple it was to do, easier than finding where to "read up".

Post Reply