2005/05/21 sfdisk
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.
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
Inexpensive and informative Apple related e-books:
Take Control of Parallels Desktop 12
Yosemite Crash Course
Take Control of iCloud, Fifth Edition
Take Control of Numbers
Take control of Apple TV, Second Edition
More Articles by Tony Lawrence
Find me on Google+
© 2009-11-07 Tony Lawrence
Printer Friendly Version
sfdisk Copyright © May 2005 Tony Lawrence
Have you tried Searching this site?
Support RatesThis 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