The blog contains all the required information about partition size in the Linux server, and how to extend partition size in Linux step-by-step.
What are Partitions?
A hard disk can split into four primary partitions (maximum). Therefore, to have more, we use an extended partition. Partitions serve as containers for smaller and logical partitions dividing the large storage devices into separate sections.
They are the divisions of the hard drives or USB drives. These partitions are required to get structured in different ways to get used. It also includes separating the hard disk into two separate configuration parts. The partitions created can be shared on the network that will never interfere with each other unless the user allows them to die physically.
Users can also have multiple partitions, each dedicated to a different “file system.” Wondering what a file system is? It is the modification of a disk into a table through which the operating systems can read and interpret. While tons of file system types are out there, we have only three kinds of partitions mentioned below:
The process of creating partitions is extremely beneficial if you are running multiple operating systems parallelly.
Minimum Partition Sizes in Linux
Resizing Partition on Linux Using fdisk
With the help of fdisk, users can create and manipulate partition tables on Linux for GPT, MBR, Sun, SGI, and BSD. However, if GUID Partition Table (GPT) is in use, only the parted utility is recommended; its support on fdisk is yet in an experimental phase.
Also, never forget to back up your file system’s data before resizing the partition size on Linux. You may wish to test the procedure because it is mandatory to delete your data before recreating the partition.
- Before proceeding, have at least one partition along with its name. You can check the name by running cat /etc/fstab. The only way to create a partition size is by deleting and recreating the partition; therefore, make sure to back up your information.
- Ensure to resize only the last partition of a disk.
Step 1: Unmount the device
Run the following code to unmount your device.
# umount /dev/vda
Step 2: Run fdisk command
Run the command:
You’ll get the following information displayed on your screen:
Welcome to fdisk (util-Linux 2.23.2).
Step 3: Select the number of partitions
Enter p in the command line. It will help you to select the line number of the partitions you want to delete.
Step 4: Delete the partition
Now type d in the command line to delete the partition of your choice. If more than one partition, fdisk will ask you to provide the total partitions you want to delete.
Command (m for help): d
Partition number (1,2, default 2): 2
Step 5: Create new partition
Type n to build a partition. Make sure to give some extra space to resize in the future. Press “enter” to use the complete space of your device.
Step 6: Set partition as LVM
Set the partition as LVM.
Command (m for help): t
Partition number (1,2, default 2): *Enter*
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM.'
Step 7: Save changes
To implement the change type w after making sure that the changes are correct. Remember that any error can cause dysfunction to your partition.
Step 8: Check the partitions
To check the consistency of your partitions, you can run e2fsck on the device.
Step 9: If needed, resize the partition
Run the resize2fs command that will help you extend the file system for consuming all the partition’s additional space.
Step 10: Mount the device
The last step is to run the mount command to mount the device. Before mounting, ensure no more modification regarding increasing or decreasing the file system is required.
Points to Consider Before Extending Partitions on Linux
The following points will help you decide the allocation of your partitions on disk space. However, these are not one-size-fits-all approaches as partition setup depends on the usage of the Linux system majorly:
- Encrypt those partitions that are composed of sensitive data or any confidential information. It will prevent your information from unauthorized individuals on the partitions, even if they break into the physical storage device. An individual should encrypt the /home partition.
- Remember that every kernel on your system has a basic necessity of approx 30 MB on the /boot partition. Therefore, ensure to allot 250 MB for /boot so that it can suffice if you’re not planning to install tons of kernels.
- The /var directory holds information regarding the applications like the Apache webserver and stores downloaded update packages temporarily. Therefore, make sure to allow enough space for /var directory to download pending updates and save other important pieces of information.
- The /usr directory contains most of the contents of the Linux system. Therefore, an individual should assign a minimum of 4 GB of space to this.
- Also, it is suggested to leave unallocated space for an LVM volume group. This free space will help users with flexibility regarding more requirements change without removing data from other partitions to reallocate storage.
- For retaining your content on installing new versions, it is required to separate subdirectories into partitions. The contents will be retained in the subdirectories even if you opt to install a new Linux version on your device.
- The UEFI (Unified Extensible Firmware Interface) systems should be allotted with 50-150MB /boot/efi partition along with an EFI (Extensible Firmware Interface) System Partition filesystem.
Partitioning is an important procedure that helps users to utilize their storage systems or hard disk to the fullest. You can extend partition in Linux with all the nine steps mentioned in the blog. Moreover, pay extra attention to the points to consider mentioned above before performing partitioning of your Linux system.
People also read: