If you are looking for a way to setup and partition (fdisk) the hard drive (a) into several partions on multiple system in the same fashion, you will probably be better off automating the setup configuration. Especially if it is on Linux machine.

First familiarise yourself with FDISK Utility.

Common fdisk commands

b    enters BSD disklabel command line mode
m    displays help
p    displays the current partition table
d    deletes a partition
n    creates a new partition
w    writes the partition table to disk
t    sets the type of partition
L    displays the list of partition types
q    quits fdisk

It is a good idea to note down which partitions you want to concern yourself with, or what device you are partitioning
Fdisk /dev/hda (where hda is our concerned hard drive)
Fdisk /dev/hda -s (shows you the HDD full size in bytes)
Fdisk /dev/hda -l (shows you all currently saved partitions on HDD (hda))

My dilemma:

I need to auto configure partitions on multiple HDDs.
>> I need to delete old existing 3 or 4 partitions
>> I need to create 3 partitions on the HDD with specific sizes 100GB, 300mb, 10GB
>> I need to ensure that first partition is FAT12 standard.

Formatting those partitions is optional (will see if i implement it) is simpler to implement at a later stage if necessary.

I decided to write a shell script for Linux.

---Start of File---
#!/bin/bash

## deleting all partitions and recreating all 3 required ones
###################################################
echo "*************Running Custom FDISK configurations*****************"
delete_unused_partitions()
{
    echo "delete_unused_partitions"
    cat<<EOM | fdisk /dev/hda
d
3
d
4
w
EOM
}

delete_partition_1()
{
    echo "Deleting partition 1"
    cat<<EOM | fdisk /dev/hda
d
1
w
EOM
}

delete_partition_2()
{
    echo "Deleting partition 2"
    cat<<EOM | fdisk /dev/hda
d
2
w
EOM
}

delete_partition_3()
{
    echo "Deleting partition 3"
    cat<<EOM | fdisk /dev/hda
d
3
w
EOM
}

delete_partition_4()
{
    echo "Deleting partition 4"
    cat<<EOM | fdisk /dev/hda
d
4
w
EOM
}

#hda1 cannot be recreated independently of hda2.
# Therefore always call BOTH delete_partition_1 and delete_partition_2 before calling this function.
create_partition_hda1()
{
    echo "create_partition_hda1"
    cat<<EOM | fdisk /dev/hda
n
p
1
+100G
t
1
1
w
EOM
}

# Creating the 300megs partition
create_partition_hda2()
{
    echo "create_partition_hda2"
    cat<<EOM | fdisk /dev/hda
n
p
2
+300M
t
1
1
w
EOM
}

# Creating the 10gigs partition
create_partition_hda3()
{
    echo "create_partition_hda3"
    cat<<EOM | fdisk /dev/hda
n
p
3
+10G
t
1
1
w
EOM

}


print_partition_table()
{
    echo "Current state of partition table is printed below:"
    cat<<EOM | fdisk /dev/hda
p
q
EOM

}
#Call functions one by one

        delete_partition_1
        delete_partition_2
        delete_partition_3
        delete_partition_4
        create_partition_hda1
        create_partition_hda2
        create_partition_hda3

---- End of file---


This can probably be refactored further, however i needed to ensure script was easy to understand for my team, hence the simplicity and efficiency.

 

Your Tech Admin

Deli.cio.us    Digg    Facebook    Newsvine