Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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

 
discard

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.