Server Fault is a question and answer site for system and network administrators. 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'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

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.

share|improve this question
up vote 1 down vote accepted

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
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.