How to create a new file system/partition on a Linux Terminal

Source: Internet
Author: User
Tags gparted
Creating a partition or a new file system in Linux usually means one thing: installing the GnomeParted partition editor (GParted ). This is the only way for most Linux users. However, have you considered creating these partitions and file systems on the terminal?

Creating a partition or a new file system in Linux usually means one thing: installing the Gnome Parted partition editor (GParted ). This is the only way for most Linux users. However, have you considered creating these partitions and file systems on the terminal? Of course! Here is the method!


Use CFdisk to create a basic Linux partition

The following describes how to create a basic Linux partition in the command line. The first thing to do is to open your terminal first. If you have enabled the disk, you need to find the disk you want to create a partition. This can be found using a simple command.

lsblk

When you run lsblk, you should see a detailed list of each disk on the current system. Check the list and find the disk you want to use. In this article, I will use sdb for demonstration.

Enter this command on the terminal. It displays a powerful terminal-based partition editing program.

sudo cfdisk /dev/sdb

Note: replace sdb with the disk you want to use output by the lsblk command.

After entering this command, you will enter the partition editor and then access the disk you want to change.

Due to the differences in disk partitions, this depends on your needs. this part of guide will be used to establish a separate Linux home/root partition layout.

First, you must create a root partition. This must be split based on the number of bytes on the disk. The disk I tested is 32 GB.

In CFdisk, use the arrow keys on the keyboard to select the space to be allocated. After finding it, use the arrow keys to select [NEW] and press Enter.

This program requires you to enter the partition size. Once you specify the size, press Enter. This is called the root partition (or/dev/sdb1 ).

Next, create the home partition (/dev/sdb2. You need to select some idle partitions in CFdisk. Use the arrow to select the [NEW] option, and then press Enter. Enter the size of your home partition and press Enter to create it.

Finally, you need to create swap partitions. As in the previous two times, first find some idle partitions and use the arrow to select the [NEW] option. After that, calculate how much swap partition you want to use in Linux.

Note: swap partitions are usually about the same size as the computer's memory.

Now, a swap partition is created, which specifies its type. Use the up and down arrows to select it. Then, use the left and right arrows to select [TYPE]. Find the Linux swap option and press Enter.

After all partitions are created. Then write it to the disk. Use the right arrow key, select the [WRITE] option, and press Enter. This will directly write the newly created distribution to the disk.


Use mkfs to create a file system

Sometimes, you don't need a whole re-partition. you just want to create a file system. You can directly use the mkfs command on the terminal.

First, find the disk you want to use. Enter lsblk on the terminal to find it. It prints out the list and then finds the partition or drive letter of the file system you want to create.

In this example, I will use the/dev/sdb1 of the second hard disk as the first partition. You can use mkfs for/dev/sdb (this will use the entire partition ).

To create a new file system in a specific partition, you only need to enter

sudo mkfs.ext4 /dev/sdb1

In the terminal. It should be noted that mkfs. ext4 can be replaced with any file system you want to use.


Conclusion

Although it is easier to use graphical tools to edit file systems and partitions, terminals are more effective. The loading speed of the terminal is faster. just click a few buttons. Like other tools, GParted is also a complete tool. I hope that with the help of this tutorial, you will understand how to efficiently edit the file system on the terminal.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.