DEV Community

Gloria Adhiambo
Gloria Adhiambo

Posted on

LINUX DISK PARTITIONING

Introduction

Disk partitioning in Linux partitions secondary storage devices (hard disks) in servers to different logical parts known as partitions using fdisk and gdisk commands. Partitions make it easier to segregate and manage data and files.

Creating a Partition in Linux

  1. To create a partition, first list available storage devices using lsblk or fdisk -l commands.

For lsbk, the output is as below:

Image description

For fdisk -l

Image description

2 . Choose the device you want to partition and run fdisk /dev/disk-name in this instance fdisk /dev/sda

Image description

3 . Use n command to create a new partition i.e

Image description

4 . Specify partition details after creating the new partition. You can use defaults in this case.

Image description

5 . Write the changes by typing w:

Image description

6 . Create a file extension for the partition: mkfs.ext4
For our case mkfs.ext4 /dev/sda1

Data on a disk can be structured and stored using a file system, such as FAT32, NTFS, or EXT4.

This step is required after a successful partition. It prepares the new partition for usage by formatting it with the ext4 filesystem.

7 . Mounting the newly created partition:
Create a new directory using mkdir to create a path for mounting the partition.
mkdir /boot
Mount using the mount command i.e: mount /dev/sda1 /boot

After a successful partition, you should see the newly created partition and mount points when you run lsblk command.

Image description

                 Happy Partitioning
Enter fullscreen mode Exit fullscreen mode




Disclaimer

Opinions presented in this article are personal and belong solely to me, and do not represent people or organizations associated with me in a professional or personal way. All the information on this site is provided "as is" with no guarantee of completeness, accuracy or the results obtained from the use of this information

Top comments (0)