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.
More Articles by Tony Lawrence - Find me on Google+
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
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. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar