0

Today I was trying to write a script for partitioning disks using fdisk (since that seemed like the simplest option).

When going through fdisk the first time and pressing n for new partition, the first prompt asked if I wanted to make a primary or extended partition. I q quit. On going back through the same procedure, the first prompt was for what sector I wanted to be first. Since I did not w write any changes, nothing should have changed, right?

If I can't predict when fdisk will give me what prompts, then I can't reliably script it. Most stuff I read recommended sfdisk for scripting, but noted that SUN disk labels are not supported. Since I want to install ZFS on root, my understanding that won't work.

So how do I predict the prompts from fdisk, or what is an alternative for scripted partitioning that supports both UEFI and ZFS?

Note: I am comfortable scripting this because I have the /dev/disk/by-id/ of each device, so as not to be confounded by changing disk labels or UUIDs.

Stonecraft
  • 779
  • 2
  • 13
  • 29
  • 1
    IIRC `parted` supports UEFI, but dunno about ZFS. In any case, wouldn't it be better to use ZFS tools directly once you have created the partition? IMHO `parted` also makes for better scripting. – muru Jun 27 '19 at 17:53
  • Well, I'm making a mix of ZFS and other types of disk but that is a good point. I can just do the regular stuff with parted and use ZFS for the ZFS stuff. – Stonecraft Jun 27 '19 at 18:06
  • 1
    Somehow I was under the impression that parted wasn't scripting friendly, but after you reminded me about parted I found this: https://unix.stackexchange.com/questions/200582/scripteable-gpt-partitions-using-parted – Stonecraft Jun 27 '19 at 18:10

0 Answers0