Disk Partition On Linux

Posted byShailesh Posted onFebruary 20, 2012 Comments0

fdisk is started by typing (as root) fdisk device at the command prompt. device might be something like /dev/hda or /dev/sda . The basic fdisk commands are:

p= print the partition table

n= create a new partition

d= delete a partition

q= quit without saving changes

w= write the new partition table and exit

I start fdisk from the shell prompt:

# fdisk /dev/hdb
which indicates that I am using the second drive on my IDE controller. When I print the (empty) partition table, I just get configuration information.
Command (m for help): p

Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
Units = cylinders of 4032 * 512 bytes
I knew that I had a 1.2Gb drive, but now I really know: 64 * 63 * 512 * 621 = 1281982464 bytes. I decide to reserve 128Mb of that space for swap, leaving 1153982464. If I use one of my primary partitions for swap, that means I have three left for ext2 partitions. Divided equally, that makes for 384Mb per partition. Now I get to work.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-621, default 1):<RETURN>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-621, default 621): +384M
Next, I set up the partition I want to use for swap:
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (197-621, default 197):<RETURN>
Using default value 197
Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M
Now the partition table looks like this:
Device Boot Start End Blocks Id System
/dev/hdb1 1 196 395104 83 Linux
/dev/hdb2 197 262 133056 83 Linux
I set up the remaining two partitions the same way I did the first. Finally, I make the first partition bootable:
Command (m for help): a
Partition number (1-4): 1
And I make the second partition of type swap:
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap)
Command (m for help): p
The end result:
Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
Units = cylinders of 4032 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 196 395104+ 83 Linux
/dev/hdb2 197 262 133056 82 Linux swap
/dev/hdb3 263 458 395136 83 Linux
/dev/hdb4 459 621 328608 83 Linux

In last write command (w) to write the table on the disk.

Than we need to make file type of created partition using below command:

# mkfs -t ext3 /dev/hdb1

# mount -t ext3 /dev/hdb1 /opt2(where this partition mounted).

 

Happy To Help You ….;)

Genowin Technologies
All Linux, UNIX Solution & Linux UNIX Shell Scripting Corporate Training.
Genowin Technologies

Category

Leave a Comment