Using parted module ..I am unable to create multiple partitions on the disk.

Hi,

I have a query here and request your help .I am trying to create multiple partition on the disk with parted module , but it only creates one partition. Is parted module creates only one partition of the entire disk or is there is way to achieve this.

  • name: create of partitions
    parted: “label=gpt device=/dev/sdb state=present number=2 unit=MiB part_end=1GiB”

when try to create on more partition on the disk gives the below error.

[student@puppetclient ~]$ ansible 192.168.3.157 -m parted -a “device=/dev/sdb number=3 state=present part_end=1GB”
192.168.3.157 | FAILED! => {
“changed”: false,
“err”: “Error: You requested a partition from 0.00kiB to 976563kiB (sectors 0…1953125).\nThe closest location we can manage is 17.0kiB to 1024kiB (sectors 34…2047).\n”,
“failed”: true,
“msg”: “Error while running parted script: /sbin/parted -s -m -a optimal /dev/sdb – unit KiB mkpart primary 0% 1GB”,
“out”: “”,
“rc”: 1

Thank you for looking into it.

This looks like you are trying to create overlapping partitions. I have not tried it, but to me looks like you need to add part_start=1GB part_end=2GB

Thank you for looking into it. but i am unable to create multiple partitions.Although I gave the part_start and part_end as mentioned by you (( ansible test -m parted -a "device=/dev/sdb number=3 part_start=3GB part_end=4GB")) but it doesnot create a new partition. already have two partitions on the test host on /dev/sdb…below snippet. I am trying to create a third partition sdb3 with parted module…does work …

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 3G 0 part [SWAP]
└─sda3 8:3 0 26.7G 0 part /
sdb 8:16 0 5G 0 disk
├─sdb1 8:17 0 953M 0 part
└─sdb2 8:18 0 1G 0 part
└─oravg-oralv 253:0 0 1000M 0 lvm /oradata1
sr0 11:0 1 53.3M 0 rom
sr1 11:1 1 4G 0 rom /mnt

`Thank you for help…I was able to figure out…

In open source community it's custom to share the answer you find, we are here to help each other.

Think about it, if you are the one searching for the answer and find someone else with the exact same problem, only to find "got it" as an answer.

Haven’t found much on Google about creating multiple partitions. You will have to workout the disk dimensions, but this worked for me:

Sure…I did not mentioning the number correctly which is required for the partitioning…the partition already created was giving error…so changing the number did the work for me…also

I am looking for how to add a logical partitions in the extended ones…Thank you for highlighting and looking into it…