# # 2005/05/21 sfdisk
APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

2005/05/21 sfdisk

I've removed advertising from most of this site and will eventually clean up the few pages where it remains.

While not terribly expensive to maintain, this does cost me something. If I don't get enough donations to cover that expense, I will be shutting the site down in early 2020.

If you found something useful today, please consider a small donation.



Some material is very old and may be incorrect today

© May 2005 Tony Lawrence

An alternative to fdisk, "sfdisk" is especially handy for scripting as it has direct support for reading actions from stdin. However, you need to read the man page very carefully if you are on intimate terms with fdisk, because sfdisk treats some command options quite differently.

Just as a inquiry tool, sfdisk has advantages over fdisk. For example, it can quickly list partitions or sizes:



# sfdisk -l /dev/hda

Disk /dev/hda: 4865 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/hda1   *      0+     23      24-    192748+  83  Linux
/dev/hda2         25    4731    4707   37808977+  83  Linux
/dev/hda3       4733    4861     129    1036192+  82  Linux swap
/dev/hda4          0       -       0          0    0  Empty
# sfdisk -s /dev/hda
39082680
 

You don't even need to tell it where the drives are, though my system does generate an error when it do that:,/p>

# sfdisk -l

Disk /dev/hdd: 2434 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/hdd1   *      0+     12      13-    104391   83  Linux
/dev/hdd2         13      45      33     265072+  82  Linux swap
/dev/hdd3         46    2433    2388   19181610   83  Linux
/dev/hdd4          0       -       0          0    0  Empty
Warning: start=63 - this looks like a partition rather than
the entire disk. Using fdisk on it is probably meaningless.
[Use the --force option if you really want this]
 

That makes me a little nervous.. For duplicating setups, it's "dump" mode can be used (probably after modification) as input for another sfdisk.

# sfdisk -d /dev/hda
# partition table of /dev/hda
unit: sectors

/dev/hda1 : start=       63, size=   385497, Id=83, bootable
/dev/hda2 : start=   401625, size= 75617955, Id=83
/dev/hda3 : start= 76035645, size=  2072385, Id=82
/dev/hda4 : start=        0, size=        0, Id= 0
 

Check the man page for more useful options.


If you found something useful today, please consider a small donation.



Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> 2005/05/21 sfdisk


Inexpensive and informative Apple related e-books:

Take Control of Upgrading to El Capitan

Take Control of Preview

Photos for Mac: A Take Control Crash Course

El Capitan: A Take Control Crash Course

Take Control of iCloud





More Articles by © Tony Lawrence





Printer Friendly Version

Have you tried Searching this site?

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us


Printer Friendly Version





If you don't know anything about computers, just remember that they are machines that do exactly what you tell them but often surprise you in the result. (Richard Dawkins)




Linux posts

Troubleshooting posts


This post tagged:

Disks/Filesystems

Linux

Unix



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode