2

I'm trying to script to gdisk to create a new partition of LVM type (for pvcreate) so I typed this but I does not work :

diskModelName=yourDiskModel
diskSerialNumber=yourDiskSerialNumber
lvmPartitionNumber=2
cat<<-EOF | sudo gdisk $disk
p
n


8E00
c
$lvmPartitionNumber
$diskModelName-$diskSerialNumber
p
w
y
EOF

Can you help me ?

don_crissti
  • 79,330
  • 30
  • 216
  • 245
SebMa
  • 1,941
  • 4
  • 22
  • 37

1 Answers1

2

You can use sgdisk (it should be available from the same package as gdisk and it's the same tool just non-interactive). For your case you should be able to use something similar to

sgdisk -n $lvmPartitionNumber:0:0 -t $lvmPartitionNumber:8E $disk

(the 0:0 part is start and end of the partition and zero is for automatic).

SebMa
  • 1,941
  • 4
  • 22
  • 37
Vojtech Trefny
  • 16,922
  • 6
  • 24
  • 48