Understanding Linux Disk Management
Before we start creating the partitions it’s very important to know the basis of the disk management, So let us first learn the basic concepts of the Linux disk management.
The disk management Includes Adding the disk, Removing a disk from the storage, creating partitions and mounting the partitions to the directory structure
1.BIOS(Basic Input and Output System)
2UEFI(Unified Extensible Firmware Interface)
3.File system type
4.MBR (Master Boot Recorder)
a)This is the first program that starts when you power on your system(based upon the operating system either BIOS/UEFI it starts)
b)The main task for the BIOS/UEFI is to perform the hardware test on your system,This will check each and every hardware devices that are associated with your system,if it found no error then it will search and run the next process(i.e starting the boot loader program)This test is called as Power on Self-Test(POST).
Let me show you some of the important difference between BIOS and UEFI
BIOS(Basic Input and Output System)
1.Very old method to connect and detect the hardware in the system.
2.It doesn’t provide us any Troubleshooting options.
3.It runs in 16-bit processor mode &4.It has only 1MB of space
4.It supports only MBR partition.
5.It doesn’t have drivers for the latest network cards and other storage devices.
6.Settings are saved in Non-Volatile CMOS memory
UEFI(Unified Extensible Firmware Interface)
1.It came as a replacement of BIOS
2.It has very advanced options for troubleshooting such as emergency mode, remote diagnosis, internet connectivity and backup.
3.It can run in 32-bit or 64-bit mode
4.It supports MBR and GPT partition
5.It can detect and support all the latest modern devices.
6.All settings are saved in Flash memory
Now let us see what is MBR partition and GPT Partition
MBR(Master boot recorder) Partition :
1.It stores in the 1st sector of the hard disk, it contains the information that is necessary to boot the systems, Inside MBR the bootloader program resides.
2.Bootloader contains only the partition layout pieces of information and how many harddisks connected, it doesn’t know anything about the operating system filesystems.
3.The default size of the sector is only 512 bytes and from these only 64 bytes are taken to save the partition table pieces of information.So due to this less space, it allows creating only 4 partitions(With the limitations of 2Tib(Tebibyte) in each partition).
4.Out of four partitions, MBR it allows one partition to use as an extended partition, with this extended partition we can create more logical partitions(It depends upon the operating system it allows to create more logical partitions), In Linux, we could create 15 partitions.
Note: The size of the extended partition and it’s all logical partitions should not exceed 2TiB
The below diagram explains you the MBR partition scheme:
1.It supports a maximum of 128 partitions.
2.Here all partitions are equal(i.e, Primary, Extended and Logical partition method not used here)
3.It allows the maximum partition size is 8 ZiB(Zebibyte)
4.It uses the 64-bits standard to save the partition information
5.It has one main feature the information is saved in two locations, so if any one location is corrupted, the system will boot from the alternative one.
Note: In MBR all the information are saved in first sector of the hard disk, so in case if this sector corrupted, then booting process will get fail.
Linux file system types:
In order to use the disk to store your data, a filesystem must be created on the partition.We can also create a separate filesystem type in each partition or can create same filesystem type in all partitions.
File system types support in Red Hat Enterprise Linux:
EXT:(Extended file system): Early version of Linux, Now EXT is not in use.
EXT2:( Extended file system2): It has very less features only, This was the default file system up to RHEL4.
EXT3:( Extended file system3): The default file system for RHEL5, It has so many features.
EXT3: (Extended file system3)
1.It supports the Journaling features
2.A directory can have 32,000 sub-directories
3.Supports filesystem up too 16TiB in size.
4.Up to 2TiB file size, it supports
EXT4: (Extended file system4) The default file system in RHEL6
1.A directory can have 62,000 subdirectories
2.Supports filesystem up too 1EiB in size.
3.Up to 16TiB file size, it supports
4.It also supports the Journaling features with an additional feature to enable and disable the journaling features.
Now, Let us see how to create a partition from the command line Before you start creating you should know the procedures to create the partition.
Procedure to create a partition:
1.Identify the correct hard disk from the server(coz in production servers you will see more than one hard disk connected)
2.Plan the layout(i.e How many partitions needed, size of the partition, where to mount that partition etc..)
3.Create the partition with the required size
4.Save the partition to the memory
5.Reboot the Linux system (so that that newly created partitions information will get saved in the kernel memory)
6.Make a new filesystem on the partition(i.e in Windows we call it as format a drive )
7.Mount the partition to some mount point directory
Ex:1 Create a 10GB Partition and mount it to the directory /sysbase
Let me demonstrate by using oracle virtual box, let me show you first how to add a new hard disk to the server in virtual box
First Power off the running virtual box, we cannot add a disk when the machine is in running state(In real production servers you can add and remove the disk while the server is in running state)
Step:1 Power off the virtual machine
Step:2 Now add a new hard disk to the server with the size 30GB(U can give the size as u wish, but I recommend minimum 15 Gb you have to give)
Step:3 After choosing the new hard disk click the option .vdi disk and in the next screen it will ask you to choose the storage on the physical hard drive, here you have to choose “Dynamically allocated” after that the size of the hard disk screen will display, give the total size of the hard disk.
After assigning the size click create, you will see the newly attached disk under the controller
Then give ok and power on the virtual machine,thats it.. we have completed the initial steps up, now it’s time to create a partition on the newly attached hard disk
Step 4: Run the following command to check how many harddisks attached and its partition layout information:
From the above output we have confirmed two harddisk were attached on the server, The first one /dev/sda is a default bootable harddisk and the second one /dev/sdb is a newly attached disk to the server.
Note:/dev/sda indicates either SCSI or SATA hard disk, The name of the first hard disk start with the letter “a” ,if the server has more hard disk, the next avaiable letter will be used for that one(ex:sdb,sdc,sde so on)
Step:5 To format the Hard Disk, run the following command
#fdisk <Logical name of the harddisk>
This will take you to the format menu ..
choose “m” to see all the available options from the format menu
From this output u will come to know which option to use to create a new partition, “n” to ccreate a new partition..
Now, choose “n” and enter, this will prompt you two options which partion you are going to create either primary or extended, choose primpary by giving “p”, As we know in MBR partition it allowed to create only four partions.If you want to create more partition then we have to use one primary partition as extended one, In extended it allowed to create 15 logical partitions.
We are going to create the first partition on this disk, Since we haven’t created any partitions on this, so give the partition number as “1”. Then after that it will ask you to give the starting cylinder value,don’t give any value here since system will take the default available cylinder, After this, it will prompt you to enter the total size of the parrtition(give the desired size at the end cylinder)
Step 6: Now to save this allocated partition information we have to press “w”
From the above output, u can see a Warning message, it says the fdisk program cannot update the inmemory kernel partiton table since the disk is mounted(busy), so we have to restart the system then after that the kernel reads the partion table.
Note: You can also use the command “partprobe” to force the kernel to read the partition table with out reboot.
From the above output if you see it didn’t show any warning or error messages because here we used the disk which doesn’t contain any mounted partition.
Step 7: Check the partiton details
Now the partition created successfully, inorder to use this partition(i.e to store your data) we need to create a filesystem on this, if we dont create a filesystem on this partiton then it would become useless.
Step 8: Create a new file system
#mkfs -t <filesystem> <Partition>
-t =To mention the filesystem type
Now format the newly created partition with ext3 filesystem.
#mkfs -t ext3 /dev/sdb1
Step 9: Mount the filesystem
Mount: In order to make use of this partition and visible to all users you need to mount the filesystem to some mount point directory
Note: Mounting and unmounting concepts I will explain in our next Tutorial
To mount a file system to a directory
#mount <filesystem> <mount point directory>
Let me create a mount point directory
Now mount the newly created partition to this directory
#mount /dev/sdb1 /Sybase
Step 10: Now to check the currently mounted filesystem details,run the following command
df (Disk File System)- to display the disk space usage details
h- Human readable format(to display the size in (kb,mb.gb format)
From the above output, it’s now confirmed the filesystem /dev/sb1 is mounted on the directory /Sybase
In our next tutorial, we will see how to create an extended partition.
If you found this article useful, Kindly Subscribe here 👉🏿👉🏿 Click this link to Subscribe