0

I need to routinely do these steps on various machines that have the same hardware:

  1. delete any partitions on /dev/sda
  2. create a 100G primary partition on /dev/sda
  3. change partition type of created partition to linux raid auto (type fd)
  4. write the table
  5. do the exact same thing for /dev/sdb

I currently use fdisk -u for doing this, but i was thinking, there has to be a way of scripting this? Any ideas?

Jarmund
  • 535
  • 2
  • 6
  • 17

2 Answers2

4

The parted command has a scripting interface as does the sfdisk command, either of these could be used to do what you want.

user9517
  • 115,471
  • 20
  • 215
  • 297
2
#!/bin/bash
dd if=/dev/zero of=/dev/sda bs=512 count=1

cat <<EOF | fdisk /dev/sda
n
p
1
+102400M

t
fd
w
EOF

partprobe
quanta
  • 51,413
  • 19
  • 159
  • 217