[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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
0
hiandras
Asked:
hiandras
1 Solution
 
joolsCommented:
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now