Partition and format a new disk

I need a pers script, that makes one maximum sized partition and formats a new hard drive.
Can someone help?

Regards, hiandras
LVL 5
hiandrasAsked:
Who is Participating?
 
joolsConnect With a Mentor Commented:
what is a pers script???

in bash ... off the top of my head... limited error checking so becareful how you run it.
I may have mis counted the prompts for fdisk as well and you have not mentioned how you want it formatted.
When I get access to a system, I'll knock up a quick check but you will need to be happy what it does before you run it!

#!/bin/bash
if [[ $1 = "" ]]
then
   echo "you must specify a disk device"
   exit 99
fi

disk=$1
echo "Formatting $disk"
fdisk $disk <EOF
d
1
d
2
d
3
d
4
d
5
n
1



w
q
EOF

mkfs.ext3 ${disk}1
0
 
hiandrasAuthor Commented:
Hi,

(I ment perl.)

Thanks for the reply!
I needed a "p" after "n", so it looks like this:
n
p
1

Thanks, I were a great help!

Regards, hiandras
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.