Let's say I want to create 128-1024 GPT partitions on a SSD 1 TB drive (smallest possible, for even FAT). Let's also say that I can do that in Linux Mint 19.3. I assume that I do not want to create script which will call gdisk many times putting its output to gdisk, but looking for a simple solution beside manual adding of these partitions.

What would be the smartest way to do that?

  • 1
    Have you checked sfdisk? superuser.com/a/1132834/62676
    – Robert
    Jan 29 '20 at 16:04
  • @Robert oh, nice! Let me try.
    – pbies
    Jan 29 '20 at 16:25
  • I suggest sgdisk rather than sfdisk
    – phuclv
    Jan 29 '20 at 16:37
  • I presume MB. KB is rather small. And 1024 GB would be the entire disk, so that is probably not what was meant. Still, as a general practice, I dislike needing to presume (and then analyze different possibilities) when a simple "M" would have just clarified this, simply.
    – TOOGAM
    Feb 2 '20 at 9:29

I've created a bash script for that, seems working fine:

#!/usr/bin/env bash

# comment to run
exit 1


    echo "label: gpt"
#   echo "label-id: 89B1365E-CD48-4A4C-95FB-117A92909321"
    echo "device: /dev/$drive"
    echo "unit: sectors"
    echo "first-lba: 2048"
#   echo "last-lba: 1953525134"
    # exFAT type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
    # NTFS type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
    # ext4 type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
    for i in {0..127}; do
        echo "start=" $(($i*$size+2048)) ", size=$size, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"
} | sfdisk /dev/$drive

# comment to run
exit 1

for i in {1..128}; do
    mkfs.exfat -n $i "/dev/$drive$i"

Thank you, @Robert!

PS. Don't mess with partitions near midnight! You can loose data!

PS2. Will try sgdisk later, thanks, @phuclv!

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.