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?

2 Answers 2

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
4

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .