There are many powerful tools available to do partition in Linux. Deleting and partitioning a storage device is very important because in large storage devices you need to manage different section with separate storage space. Partitioning is also very useful if you are using multiple operating systems (multiple operating systems means running Linux and windows on the same system).

Already mentioned there are different tools in Linux to do partition but in this page, I will use parted command for partitioning

Install Parted command

In most of the Linux operating systems, this command will already installed. But if in any case you do not have parted command installed by default you can install it. Follow the process below:

  • Open terminal application in your Linux OS
  • Run the following commands

$    sudo apt-get update

$    sudo apt-get install parted

  • If you are using CentOs or fedora then use the following command

$     sudo yum install parted

Select the partitioning standard

There are partitioning standards GPT and MBR. GPT is more modern and widely used partitioning standard, while MBR is giving wider support among operating systems. If we do not have some special needs then we simply use GPT.

To choose GPT to run the following command.

$    sudo parted /dev/sda mklabel gpt

To choose MBR to run the following command

$    sudo parted /dev/sda mklabel mbr msdos

Create a new partition

When you have selected the partitioning format then you can create a partition. Run the following command to create new partition.

$    sudo parted -a opt /dev/sda mkpart primary ext4 0% 100%

We can check new partition created by running the following command

$    sudo lsblk

Create a filesystem on a new partition

Now we have created a new partition we can pass it filesystem by using mkfs.ext4 utility.

$     sudo mkfs.ext4 -L datapartition /dev/sda1

Once you have created a filesystem on new partition you have to mount this filesystem. It makes no recommendations on where to mount more permanent storage, so you can choose whichever scheme you would like. For this tutorial we will mount under /mnt/data.

Create the directory to mount the partition by running the following command

$    sudo mkdir -p /mnt/data

There are two ways to mount the partition temporary mount and mount the partition automatically at boot.

Mount the partition temporarily by typing the following command

$    sudo mount -o defaults /dev/sda1 /mnt/data

If you want that filesystem should mount each time system boots you can use the following command.

$    sudo nano  /etc/fstab

Now save and close the file when you are finished. In this tutorial, we have learned how to create partition, format and mount the filesystem.

How do I partition a hard drive in Ubuntu?

In the hard disk partition table menu, select the hard drive free space and hit on + button in order to create the Ubuntu partition. In the partition pop-up window, add the size of the partition in MB, choose the partition type as Primary, and the partition location at the beginning of this space.

How partitions are created in Linux?

Creating a Disk Partition in Linux. In this section, we will explain how to partition a storage disk in Linux using the parted command. The first step is to view the partition table or layout on all block devices. This helps you identify the storage device you want to partition.

How do I manually create a Linux partition?

The rule of thumb is that you choose between 1.5 to 2 times the amount of RAM as the swap space, and you put this partition in a place that is quick to reach, like at the beginning or end of the disk. Even if you install a ton software, a maximum of 20 GB for your root partition should be enough.

What are different kinds of partitions available in Linux?

There are two kinds of major partitions on a Linux system:
  • data partition: normal Linux system data, including the root partition containing all the data to start up and run the system; and.
  • swap partition: expansion of the computer’s physical memory, extra memory on hard disk.

What are three types of partitions?

There are three types of partitions: primary partitions, extended partitions and logical drives. A disk may contain up to four primary partitions (only one of which can be active), or three primary partitions and one extended partition.

How many partitions are required for Linux?

For a single-user desktop system, you can ignore just about all of that. Desktop systems for personal use don’t have most of the complications that require so many partitions. For a healthy Linux installation, I recommend three partitions: swap, root, and home.

How can I see all partitions in Linux?

View all Disk Partitions in Linux

The ‘-l’ argument stand for (listing all partitions) is used with fdisk command to view all available partitions on Linux. The partitions are displayed by their device’s names. For example: /dev/sda, /dev/sdb or /dev/sdc.

How do I see drives in Linux?

Let’s see what commands you can use to show disk info in Linux.
  1. df. The df command in Linux is probably one of the most commonly used.
  2. fdisk. fdisk is another common option among sysops.
  3. lsblk. This one is a little more sophisticated but gets the job done as it lists all block devices.
  4. cfdisk.
  5. parted.
  6. sfdisk.

How do I view partitions?

Double-click “Storage” and then double-click “Disk Management(Local).” This window contains tools that allow you to manage the way your computer works. A table at the top of the window displays the following columns: Volume, Layout, Type, File System and Status.

How do I list all devices in Linux?

The best way to list anything in Linux is to remember the following ls commands:
  1. ls: List files in the file system.
  2. lsblk: List block devices (for example, the drives).
  3. lspci: List PCI devices.
  4. lsusb: List USB devices.
  5. lsdev: List all devices.

How do I list all USB devices in Linux?

The widely used lsusb command can be used to list all the connected USB devices in Linux.
  1. $ lsusb.
  2. $ dmesg.
  3. $ dmesg | less.
  4. $ usbdevices.
  5. $ lsblk.
  6. $ sudo blkid.
  7. $ sudo fdisk -l.

What are devices in Linux?

In Linux various special files can be found under the directory /dev . These files are called device files and behave unlike ordinary files. The most common types of device files are for block devices and character devices.

How do I find memory in Linux?

  1. Open the command line.
  2. Type the following command: grep MemTotal /proc/meminfo.
  3. You should see something similar to the following as output: MemTotal: 4194304 kB.
  4. This is your total available memory.

How do I increase memory on Linux?

If you have less than 1 GB of total memory, create a swap file to increase the available system memory. Linux swap files allow a system to harness more memory than was originally physically available (RAM).

How do I find hard drive size in Linux?

Howto Find Out or Learn Harddisk Size in Linux or UNIX
  1. Task: Display Hard Disk Partition Size. Open a command-line terminal (select Applications > Accessories > Terminal), and then type:
  2. Task: Display Hard Disk Partition Size in Mega bytes or GB or TB. Type the following command:
  3. Task: Display TOTAL Hard Disk Size.

What does du command do in Linux?

The du command is a standard Linux/Unix command that allows a user to gain disk usage information quickly. It is best applied to specific directories and allows many variations for customizing the output to meet your needs.