Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was looking over documentation for ZFS for Linux and I came accross a command that the instructions tell me to run to prepare a disk for use.

The command was;

sfdisk -q /dev/zvol/tank/fish << EOF

The line breaks are included the command took up 3 lines

What does sfdisk do? Is it the same and creating a new partition table or is it something different?

Here is the documentation I was looking at, Link

share|improve this question here's the man page, although I don't know how helpful it'll be, it's a start. – Rob Dec 5 '11 at 18:11
I actually have that exact manpage open. I understand what sfdisk -q does, what I don't understand is the << EOF 0, EOF part. – ianc1215 Dec 5 '11 at 18:13

sfdisk reads and writes partition tables, but is not interactive like fdisk or cfdisk (it reads input from a file or stdin). It's generally used for partitioning drives from scripts or for partition table backup and recovery. Since it's command driven instead of menu driven, I can see the attraction for using it in documentation like this, since you can easily document the input.

share|improve this answer

sfdisk reads lines of the form

<start> <size> <id> <bootable> <c,h,s> <c,h,s>

where each line fills one partition descriptor.

... When a field is absent or empty, a default value is used.

So this sets up a new partition, starting at 0 and ending at the default of size.

The default value of size is as much as possible (until next partition or end-of-disk).

share|improve this answer
So its just a quick way to partition the drive. – ianc1215 Dec 5 '11 at 19:00
Yeah, that's what it seems like. I'd use something I was more comfortable with if it was available. – Rob Dec 5 '11 at 19:18
Yeah I agree, so according to what I listed that would create 1 partition that is the full size of the disk right? Because it shows me 4 partitions but only 1 was Linux and 3 were Empty. – ianc1215 Dec 5 '11 at 19:24
It will create one partition, starting at the beginning of the disk, and ending the start of the next partition. – Rob Dec 5 '11 at 19:49

sfdisk is nice for software raid. When replacing a disk, simply:

sfdisk -d /dev/sda | sfdisk /dev/sdb

and you've cloned the partition table from sda to sdb.

now just add back to mdadm and good to go.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .