Disk Partitioning in Linux
Disk partitioning is one of the many steps you must take when preparing a system for use.
Partitioning means to divide a single hard drive into many logical drives.
In each system the physical disk drivers are divided up logically into partitions that allow you to store data on them.
There are also special types of partitions such as RAID that allow for increased performance, redundancy, or both. LVM, like RAID, is an advanced form of partitioning that eases management of partitions and makes growing them for increased storage capacity simple.
One of the key points to remember when working with partitions is to always plan ahead
Disk partitioning criteria:
MBR —–> Master Boot Record.
P —–> primary partition
Extended —–> Extended partition
L —–> logical partition
Free —–> Free space
- Every disk can have only 3 primary partitions
- Primary partition is a partition which usually holds the operating system
- Extended partition is a special type of primary partition which can be subdivided into multiple logical partitions
- Logical partitions are the partitions which are created under extended partitions
- As in the real world, it is the results that matter. It doesn’t matter whether you use Disk Druid, fdisk, or parted to create partitions. You can create new partitions at the command line or use GUI front ends to these tools such as the Disk utility.
- Remember Disk Druid is available only during the installation process.
- You can use two different utilities when partitions disks:
F disk —–> Disk partitioning utility
parted —–> Another Disk partitioning utility
- While f disk is more common, it is slowly being replaced by parted, which is more flexible.
Different types of disks will be having different initials in linux
IDE drive will be shown as /dev/had
SCSI/SATA drive will be shown as /dev/sda
virtual drive will be shown as /dev/vda
Note: The first two letters represent whether the disk is a SCSI (sd) (or) IDE (hd) disk. The third letter represents which disk it actually is If there is a number after the three letters, it is the number of the partition
To view information about the current partition layout,
#cat /proc/partitions / grep hd For IDE
#cat /proc /partitions / grep sd For SCSI / SATA
You need to view their current partitions to see if any exist.
Syn: fdik [options] [device]
-b —–> specifies the sector size of the disk
-h —–> number of heads on the disk
-l —–> lists current partition table.
Note: There are some limitations when it comes to working with partitions. You can have only four partitions to a physical disk with one exception. If you want to make more than the four, you need to create three primary partitions and one extended partition, although the primary partitions aren’t required for extended partition, creation. The extended partition can then hold 11 logical partitions (5-16) on it.
Creating a partition:
Step 1): # f disk /dev/sda
Step 2): view all the options available to you
command (m for help) : m
P—–> print the partition table
n —–> add a new partition
d —–> delete a partition
m —–> print this menu
q —–> quit without saving changes
t—–> change a partition’s system id
w —–> Write table to disk and exit
Inclined to build a profession as Linux Developer? Then here is the blog post on Linux Training Online.
- Create a new partition
#f disk /dev/sad
First Cylinder (1-1044, default 1 ) :
Using default value 1
Last cylinder or + size ………..(1-1044,……..) : + 500M
- Create a second partition
- Verify newly created partitions
- Write the changes to disk
- Now that two new partitions have been created and written to disk, you should verify their existence. Before doing that, however, you want the kernel to reread the partition table to make sure that it recognizes all disks and partitions correctly. To do this, you use the part probe cmd.
Syn: part probe [options] [device]
-d does not actually inform the operating system
-s prints a summary of contents.
- Now call the part probe command
- Now that you have created partitions with the f disk utility, do it again using the parted command
- Create a partition:
#parted / dev/ sda
- Menu (parted) help
- Create your first partition in a similar manner to fdisk
partition type? Primary/extended/ logical?
File system type? [ex:2]?
- Make your second partition again
- Before writing changes to disk, you should verify that they have been created the way you want them:
- Exit the program to save your changes
- There are a few things you should notice here. First, you need to specify exactly where you want the start and end of the partition to be. If you don’t plan this out ahead of time, you will end up with incorrect partition sizes. You should also take note of the fact that you don’t have to write the changes to disk manually; this is done for you when you quit the parted program.
- Again, you need to force the kernel to reread the partition table
- Once again, verify that your partitions have been created successfully:
Deleting a partition: Deleting a partition is much easier than creating one because you need to specify only the partition number that you want to delete.
- Start the f disk utility: # f disk / dev / sda
:p—–> printout the current partition
:d—–> Delete a partition
:6—–> want to delete 6th partition
:w —–> write changes to disk
- Don’t forget to reread the partition table
#part probe /dev/sda
- Start the parted utility: #parted /dev/sad
(parted) rm 5
Indepth understanding of Linux click on