Sunday, 16 February 2014

Managing Disk Partition in Linux

Disk partitioning is one of the many steps you must take when preparing a system for use. In each system the physical disk drives are divided up logically into partitions that allow you to store data.When adding more storage or creating it for the first time, you should partition your disk space into a logical format for use later.

You can  use two different utilities when partitioning disks:
fdisk      Disk-partitioning utility
parted   Another disk-partitioning utility

Exercise-1 FDISK Utility

1-You can use the fdisk command to manage disks in Linux.
Syntax: fdisk [options] [device]

To list the current partitions on all disks, use this command:
# fdisk -l

Step 1. Choose the disk in my case it /dev/sda
# fdisk /dev/sda
Command (m for help): n
First cylinder (7117-7181, default 7117:
Using default value7117
 Last cylinder or +size or +sizeM or +sizeK (7117-7181, default 7117): +200M

(In above example i have created a partition with 200MB space:)

(Verify your newly created partitions:)
Command (m for help): p

(Write the changes to disk and exit:)
Command (m for help): wq

Step-2 To verify that your partition has been created.
# fdisk -l

Step-3 You need to force the kernel to reread the partition table with partprobe command
(reboot your system if required)
#partprobe /dev/sda

Step-4 To format partition type following command
#mkfs.ext4 /dev/sda8
mkfs means makefile system, ext4 means filesystem, /dev/sda8 my partition number.

Exercie-2 Using PARTED:
You could also use the parted command to obtain the same information.
View all partitions using parted:
# parted -l

Step 1. Start the parted utility the same way you used fdisk:
# parted /dev/sda

(Create your partition in a similar manner to fdisk:)
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? ext4
Start? 33.5G
End? 40.5G
(I want to create a partition with 7GB space)
(Before writing changes to disk, you should verify that they have been created the way you want them:)
(parted) print

(Exit the program to save your changes:)
(parted) quit

Again, you need to force the kernel to reread the partition table:
# partprobe /dev/sda

Once again, verify that your partitions have been created successfully:
# parted -l

No comments:

Post a Comment

RADIUS Server Configure in Server 2012

Home About Me Apple Networking Software Storage Downloads Links Contact How to setup Radius for authentication wi...