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

Source: Internet
Author: User
Tags gparted

How to create a new file system/partition on a Linux 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.

  1. lsblk

Cfdisk-lsblk

When you runlsblk, 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 usesdb.

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

  1. sudo cfdisk /dev/sdb

Cfdisk-empty-layout

Note:lsblkThe disk you want to use to replace the command outputsdb.

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.

Cfdisk-create-root-partition

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.

Cfdisk-create-home-partition

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.

Cfdisk-specify-partition-type-swap

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.

Cfdisk-write-partition-table

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 usemkfsCommand.

Cfdisk-mkfs-list-partitions-lsblk

First, find the disk you want to use. EnterlsblkFind out. 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/dev/sdb1As the first partition. You can/dev/sdbUse mkfs (this will use the entire partition ).

Cfdisk-mkfs-make-file-system-ext4

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

  1. sudomkfs.ext4 /dev/sdb1

In the terminal. It should be noted that,mkfs.ext4You can switch to 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.

Do you prefer to use a terminal-based method to edit partitions in Linux? Whether or not, please let us know below.

Via: https://www.maketecheasier.com/create-file-systems-partitions-terminal-linux/

Author: Derrik Diener Translator: strugglingyouth Proofreader: wxy

This article was originally compiled by LCTT and launched with the honor of Linux in China

This article permanently updates the link address:

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.