# How to translate sfdisk command to parted command

I'm currently involved in modifying some system setup scripts to use parted rather than sfdisk, and I'm not entirely sure how to convert those commands.

The existing sfdisk command is passed numeric partition-type identifiers; I'm reasonably sure it can only be 82 ("Linux swap") or 83 ("Linux native partition"). For example:

$sfdisk /dev/sda << EOT 0,100,83, 100,200,82, EOT  How would I express this configuration to parted? My best guess at the moment would be: $ parted /dev/sda mkpart primary 0 100 mkpart primary linux-swap 100 200


A lot of my confusion stems from parted's seeming treatment of a Linux swap partition as a type of filesystem, while the fact that it has an assigned partition type ID seems to make it a type of partition.

-

You may want to specify units to mkpart command:

mkpart primary linux-swap 100cyl 200cyl

All specific partition types are hidden in parted, to change first partition to type 0x82 (linux-swap) you would use:

toggle 1 swap


Or for MD RAID (0xFD):

toggle 1 raid


or use set:

set 1 swap on
set 1 raid on

-
I had already been including "unit cyl" among the arguments to parted; I omitted them in my question for clarity. –  Sean Oct 6 '10 at 20:19
yes, using "unit cyl" will give the same effect –  Hubert Kario Oct 6 '10 at 20:25