Results 1 to 2 of 2

Thread: How to initialize HDD using Shell script?

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default How to initialize HDD using Shell script?

    Hi I'm new to Linux.
    I'm wondering how to write a shell script to clear off all the partitions on a IDE HDD? Any help will be much appreciated.
    Thank you
    gail

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,514
    Thanks
    17
    Thanked 808 Times in 511 Posts
    Rep Power
    10

    Default

    You need to use GNU parted utility - a partition manipulation program. It is perfect tool and works from a shell script. Here is a sample shell script. Make changes as per your setup and test script in a dummy environment.

    Code:
    #!/bin/sh
    PART=$1
    if [ $# -eq 0 ]
    then
       echo "$0 partition-name
       echo "$0 /dev/sda1"
       exit 1
    fi
    
    echo "* Creating partition."
    parted -s -- $PART  mkpart primary ext3 0 -1
    
    echo "* Formatting the partition."
    mke2fs -j -m 0 -O dir_index $PART
    Read parted and mke2fs man pages.

    HTH
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Solved] Shell script for ftp the file
    By vishal_titre in forum Shell scripting
    Replies: 4
    Last Post: 21st August 2009, 03:50 PM
  2. Run mv command from ftp shell script
    By subin in forum Shell scripting
    Replies: 6
    Last Post: 2nd May 2008, 09:44 AM
  3. writing a shell script to find out my shell name
    By jaymob123 in forum Shell scripting
    Replies: 1
    Last Post: 8th October 2007, 12:36 AM
  4. require shell script
    By puppen in forum Shell scripting
    Replies: 4
    Last Post: 12th April 2006, 09:42 PM
  5. Shell Script dought
    By Mahesh in forum Shell scripting
    Replies: 3
    Last Post: 16th February 2005, 12:13 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •