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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

joolsSenior Systems AdministratorCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.