0

I need to create 20 partitions of the same size (cue to the first comment only the first 3 can be primary and the 4th needs to be extended an the other remaining 17 in it)

I tried:

for i in $(seq 1 20); do  echo 'start=2048, type=83' | sfdisk /dev/ram0p${i}; done

but doesn't work.

Is there a way to do it in Linux, using parted, sfdisk or other tool? So at least is there a way to create the 17 logical partitions programatically?

2
  • 3
    Well, obviously all 20 partitions can't start on sector 2048, for one thing. You will also need to figure out how large the partitions should be, and pass that. Note also that DOS partition tables only support 4 primary partitions.
    – wurtel
    Mar 12, 2019 at 8:59
  • @wurtel that's the problem how do I calculated the offset Mar 13, 2019 at 9:11

1 Answer 1

0
  1. use Ansible for the same. below is the ansible module for partition creation.

    • parted: device: /dev/sdb # device details number: 1 # this is number of partion. you can define numbers with varilabe from 1 to 20 # state: present part_end: 2GiB

    parted: device: /dev/sdb number: "{{ item.num }}" state: present with_items: - {num : 1, 2, 3, 4, 5 .... till 20} - filesystem: fstype: ext2 dev: /dev/sdb"{{item.num}}" with_items: - {num : 1, 2, 3, 4, 5 .... till 20}

4
  • Can you please write the final command Mar 12, 2019 at 9:40
  • - parted: device: /dev/sdb number: "{{ item.num }}" state: present with_items: - {num : 1, 2, 3, 4, 5 .... till 20} - filesystem: fstype: ext2 dev: /dev/sdb"{{item.num}}" with_items: - {num : 1, 2, 3, 4, 5 .... till 20} Mar 12, 2019 at 9:48
  • I am not familiar with ansible how do you use this in command line? Mar 12, 2019 at 18:05
  • 1
    ansible is used to orchestrate the configuration of a (large) number of systems from a central point, you can't use it to configure a local server like you want.
    – wurtel
    Mar 13, 2019 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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