Partition and format a new disk

hiandras
hiandras used Ask the Experts™
on
I need a pers script, that makes one maximum sized partition and formats a new hard drive.
Can someone help?

Regards, hiandras
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Systems Administrator
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

Author

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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial