Creating and formatting hard disk sections in Linux

Anonim

The purpose of the article is to consider the creation of hard drives and creating various file systems on the sections in Linux. Disc controls MBR and GPT will be considered.

Using the MKFS utility.

Basic utilities for working with hard disk sections and creating file systems: fdisk, gdisk, parted, gparted, mkfs, mkswap.

To work with hard drives, operations such as changing the size of logical partitions, partitioning hard drives, creating file tables on hard disk sections require superuser rights. Switch in the data Mode from the normal user mode, you can command Sudo -S and entering the password.

The FDISK utility allows us to conduct various manipulations with the hard disk sections.

FDISK -L command, we can see which sections we have on your hard disk.

And so enter the FDISK -L command and we see on 3 physical hard disk / dev / sda, / dev / sdb, / dev / sdc of the corresponding dimensions. We are interested in the / dev / sdc / on 10 GB with which we will produce manipulation.

Creating and formatting hard disk sections in Linux 19641_1

Next, we will make a breakdown and create logical sections.

FDISK / DEV / SDC

Immediately we obtain a warning that the section does not contain a single identified partition.

Creating and formatting hard disk sections in Linux 19641_2

Create new sections. We divide into 2 parts. We will have the following.

Creating and formatting hard disk sections in Linux 19641_3

How can we see 2 sections created and have ID 83, i.e. Linux default section.

Now let's change the type of section. It is possible to make it simply in the menu, select T - Change Section. Select the number, for example, 2 and click L to view HEX codes corresponding to different types. Change the type of Linux section on the swap section of the paging.

Creating and formatting hard disk sections in Linux 19641_4

And now we can see entering the P command.

Creating and formatting hard disk sections in Linux 19641_5

We have changed the type of partition to the paging section. Typically, the data section is used when there is not enough RAM for the machine. Now you need to record the changes made by the W command. After entering this command, the discs are synchronized and the partition table is changed. After that, entering the FDISK -L command, we can make sure that the sections really appeared. In order for this section to really work, like a paging section, it must be formatted as the swap section. For this there is a special MKSWAP / DEV / SDC2 command. Specify the command and partition that should be posted. After the MKSWAP command, the section is placed and now it must be enabled Swapon / dev / SDC2.

In order to see which paging sections are used using the Swapon -S command.

You can use the Swapoff / Dev / SDC2 feed command to turn off the swap section.

In fact, how we were convinced by the paging sections simply simply. If there is not enough RAM, it was rejuvenated, formatted and turned on.

Now he will work with the first partition. We will use the MKFS command.

Man MKFS

Creating and formatting hard disk sections in Linux 19641_6

In the description of the utility it is said that this utility builds a Linux file system. This utility has a very large number of keys. I use this utility we can format the logical partition into the old EXT2 file system using the MKFS -T EXT2 / DEV / SDC1 command. And then reformat in a newer ext3. File systems differ in that a new file system is journalable. Those. A log of changes occurring on this file system and in case of something we can restore or roll back changes. Even a new EXT4 file system. The differences between this file system from the previous one is that it can work with large sizes of hard drives, can store large sizes of files, much less fragmentation. If we want to use some more exotic file systems, then we need to download the appropriate utility. For example, if we want to use the XFS file system.

If we try formatting MKFS -T XFS / DEV / SDC1, then we will get a mistake. Let's try to search for the cache required APT-Cache Search XFS.

Creating and formatting hard disk sections in Linux 19641_7

Find the desired package. How we can see this utility to control the XFS file system. Therefore, it is necessary to install this package, and we will be able to format the file system in the XFS. Install APT-Get Install XFSprogs. After installation, we try to format in XFS. Considering the fact that we have already formatted into the EXT4 file system, we need to format a command to start with the -f key. We get in the following form:

MKFS -T XFS -F / DEV / SDC1

Creating and formatting hard disk sections in Linux 19641_8

Now I think it will be interesting to see how to make this section work under Windows operating system.

We return back to editing the logical partitions fdisk / dev / sdc and say that we go to change the type of our first section using the T command. Next, select the label that Windows operating system understands, it is FAT / FAT16 / FAT32 / NTFS. For example, NTFS ID 86. changed. In this, you can make sure that the table can be displayed using the P command.

Creating and formatting hard disk sections in Linux 19641_9

After changing the type of logical partition, do not forget to write changes using the w command. Next, you need to format MKFS -T NTFS / DEV / SDC1.

Therefore, as we see the MKFS utility, it is perfectly formatting logical partitions into different file systems, and if a specific file system is needed, you can always deliver missing components and everything will work.

If you look at the fdisk, we will see that he does not know how to work with GPT disks and can not work with large sections, only with MBR. As is known in modern PCs, UEFI is already used, which works with GPT. And as a result, we can conclude that FDisk will not be able to work with discs of which more than 2 TB. You can use another GDISK program to work with large disks.

Man Gdisk.

Creating and formatting hard disk sections in Linux 19641_10

As you can read in the description of GDISK - this is an interactive manipulator for working with GPT. It works almost as well as FDISK, only for a start it is necessary to project a hard drive from the MBR in GPT.

GDisk / Dev / SDC

Creating and formatting hard disk sections in Linux 19641_11

By clicking on the question mark we get a small tip.

Creating and formatting hard disk sections in Linux 19641_12

And click the O command to create a new empty GPT.

We get this warning.

Which says that a new GPT will be created and create a small new protected MBR for compatibility with old systems, otherwise the old systems will rub GPT.

Using the P command, you can see a list of logical partitions, and with the help of the W command. Sections in this program are created similarly to FDISK.

Let's see another parted utility.

Man Parted

Creating and formatting hard disk sections in Linux 19641_13

An interesting program has a greater functionality than fdisk and gdisk. It knows how to work with disks more than 2 TB, knows how to change the sections on the hot, can create partitions immediately with the file system, search and restore partitions on the hard disk.

The PARTED -L command will show information on connected hard disks, sections and logical sections.

Creating and formatting hard disk sections in Linux 19641_14

We go into editing the hard disk parted / dev / sdc and score the word Help. We get enough help with options.

Creating and formatting hard disk sections in Linux 19641_15

This utility has a graphical interface if you work with the GUI. You can install via APT-Get Install Gparted.

Read more