-1

I'm trying to figure out how to partition a disk in a programmatic way so that my disk will have three "msdos" primary partitions: one for /boot, one for swap and the last for logical volumes. I can't use puppet or ansible or suchlike because of our customer's policies.

All the systems are configured with a single, 1TB disk.

  • sda1 = /boot should be 512MB
  • sda2 = swap should be 16GB
  • sda4 = the rest of the disk, extended partition for logical volumes.

I'd like to have these partitions aligned properly and I keep getting errors regarding the last partition not starting on a physical sector boundary.

Which type of unit should I use with parted? Would sfdisk be easier? I see posts where folks are using mebibytes and sectors in the same mkpart command and wonder why.

  • I've updated the title to remove the opinion-inducing aspect and focused it instead on the actual question you seem to have. – Jeff Schaller May 12 at 21:20
0

I don't see what's wrong with having an opinion about disk partitioning tools. In any case I went with parted, since parted is what we've been using at work. Just a reminder, this is for a physical disk. I wanted swap and boot on a physical partition and the remainder of the disk in one big partition for the logical volumes.

parted -s /dev/sda mklabel msdos
boot slice: 'parted -a optimal -s /dev/sda mkpart primary xfs 2048s 800MB'
swap slice: 'parted -s -a cylinder -- /dev/sda mkpart primary xfs 800MiB' 7720MiB
rest of disk: 'parted -s -a cylinder -- /dev/sda mkpart primary xfs 19087MiB -0'<br>
'pvcreate /dev/sda3' create physical volume
'vgcreate star /dev/sda3 create volume group
'lvcreate --size 10G --name tmp star' create temp volume
'lvcreate --size 30G --name home star' create home volume
'lvcreate --size 20G --name var star' create var volume
'lvcreate --size 20G --name var_log star' create /var/log volume
'lvcreate --size 20G --name var_audit star' create /var/log/audit volume
'lvcreate -l 100%FREE -n home star' create home volume with remaining space.

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.