In this short note I will show you practical example, how to work with disks in Linux.

Disk activation in Linux

Suppose you connected a new disk that does not yet have a file system. The system does not see it and we need to run commands to connect it.

Let me say right away that all the actions described here can be performed in commands with a graphical interface. I will mark and format disks on the command line - this is a more universal method, as it allows you to configure disks and partitions even in operating systems ah, on which there is no graphical environment.

When connecting a new drive we need:

  • divide it into sections
  • format each partition to create a file system
  • mount the disk to be able to write and read data
  • configure automatic mounting when you turn on the computer

How to find out disk names, how to view all disks in the system

We need to start by finding out the name of the disk that we will change. In Linux it is completely different from Windows system disk designations. Instead of the usual drives C, D, E and so on, in Linux drives are devices in a folder /dev/. Everything in dev possible devices, even very exotic ones that do not exist in Windows.

To see available drives, run the command:

Sudo fdisk -l

As can be seen from the screenshot, there is a disk /dev/nvme0n1. Then two devices are listed /dev/nvme0n1p1 And /dev/nvme0n1p2. By matching part of the name nvme0n1 you can understand that these are the partitions into which the disk is divided /dev/nvme0n1.

There is also a disk /dev/sda, which is not divided into any sections - this is what I will connect.

Disk partitioning (partitioning) in Linux

In the console, the disk can be partitioned with the command cfdisk. After it, specify the name of the disk with which you want to perform actions:

Sudo cfdisk /dev/sda

The disk may be GPT or MBR(shown as dos). You can easily find a lot of information about these partition tables on the Internet. I’ll just note that GPT is more modern and has more features. Therefore, if you don’t need to work with old hardware that only understands MBR, then choose GPT.

To create a disc, select New:

Enter its size.

If necessary, change the partition type:

Then move down to the free space and repeat these steps to create partitions. When you're done, select Record.

Formatting Partitions

To format in ext4:

Sudo mkfs.ext4 /dev/partitionname

To format in ext3:

Sudo mkfs.ext3 /dev/partition_name

To format in ext2:

Sudo mkfs.ext2 /dev/partitionname

To format in FAT32:

Sudo mkfs.fat -F32 /dev/partitionname

My example (I did not partition the disk):

Sudo mkfs.ext4 /dev/sda

By the way, if you want to format a partition that you are already using, you must first unmount it (more on this later).

Mounting and unmounting disks

With disks in /dev/ You cannot work directly, that is, you cannot write files to them or copy files from them. To work with them they need to be mounted. This is done by the team mount.

The disk is connected to the mount point and in this folder you can work with the contents of the disk.

This concept may seem foreign to Windows users, but it's very convenient! The disk can be mounted in any folder. For example, the home folder can be on another drive - convenient when reinstalling the system - the data does not need to be copied to a safe place, since it is already on another drive.

To mount, use the following command:

Sudo mount /dev/partition_name /mount/mount point/

Let's say I want a new disk to be mounted (mounted) to a folder /mnt/disk_d. You can choose any name and the mount point does not have to be in the directory /mnt/– can be done in your home folder or in any other folder.

We start by creating the directory in which the disk will be mounted:

Sudo mkdir /mnt/disk_d

We mount:

Sudo mount /dev/sda /mnt/disk_d

We allow everyone access to this disk so that an ordinary user can also view and write files there:

Sudo chmod 0777 /mnt/disk_d

In fact, access rights can be configured more finely - without giving full permission to everyone.

To unmount a disk, use any of two commands:

Sudo umount /dev/partitionname

Sudo umount /mountpoint/

Automatically mount disk when Linux boots

Disks for mounting at starting Linux are registered in the file /etc/fstab.

Let's say I want to mount the disk at boot /dev/sda to the directory /mnt/disk_d/. At the same time, I want the disk to be readable and writable by the user. Then I create a directory - a mount point:

Sudo mkdir /mnt/disk_d

I open the file /etc/fstab:

Sudo gedit /etc/fstab

and add the following line there:

/dev/sda /mnt/disk_d ext4 rw,relatime 0 0

In this line you need to replace

  • /dev/sda- to the disk you want to mount
  • mial- in your username
  • /mnt/disk_d- to your mount point that you chose for your disk.
  • ext4- to the file system of your disk

If you are not sure about the file system or its designation, then run the command:

Lsblk -f

As a result, the disk will be automatically mounted every time the system starts.

To allow your user to access this folder without having to escalate their privileges, run the command:

Sudo chown -R $USER /mnt/disk_d

You can fine-tune access rights - for example, by creating a group in which only members will have access to the disk.

Please note that if you did something wrong in the file /etc/fsta, then the system will not be able to boot into GUI and you will have to fix everything from the console. Link to additional instructions at the end of this article.

Connecting removable media (flash drive, external drive) in Linux

By the way, many Linux distributions at USB connection flash drives or external drives automatically mount them. Automounting is usually a feature of the desktop environment. That is, on the same Linux distribution, but with different desktops (versions Linux Mint as an example), auto-mounting may or may not be present.

If this does not happen, then you need to mount it manually. This process is no different from normal disk mounting: also create a mount point and use the command mount.

Removable media can be mounted via /etc/fstab, there is even a special option for this nofail— ignore errors if the disk is missing.

How to view all drives and mount points

To do this, use the command we are already familiar with:

How to delete disk partitions

If you want to delete the entire contents of a disk, including its partitioning, then this is done like this:

Open the drive in gdisk:

Gdisk /dev/disk

To switch to expert mode, enter

Then to remove GPT enter

Agree twice to completely clear the drive.

Remounting a drive with write permissions

Sometimes disks are mounted with read-only permissions. In this case, you can copy files from the disk, but you cannot write or delete anything to it. You can remount the disk for writing with one command:

Sudo mount -rw -o remount /dev/sdb1

In it /dev/sdb1 replace with the name of your section.

If you encounter an error:

Mount: /run/media/mial/New volume: /dev/sdb1 is write-protected but explicit read-write mode requested.

Then you need to run the command (replace /dev/sdb1 to your section):

Sudo hdparm -r0 /dev/sdb1

Example output:

/dev/sdb1: setting readonly to 0 (off) readonly = 0 (off)

After that, remount the disk.

note what if you mount a disk with a file NTFS system, then you must have the package installed ntfs-3g, otherwise, no matter what you do, the disk will be read-only.

Conclusion

If you still have questions, ask them in the comments.

A few more tips and problem cases are discussed in the article “Working with disks in BlackArch (mounting, solving problems)” - this article is suitable for all distributions, not just BlackArch.

For Windows installations Simply select a disk partition. The system itself will format it and install all the files there. But Linux allows you to customize the location of the system and its files much more flexibly. During installation, you can place different folders with system or user files on different partitions.

This is a very interesting feature that increases the reliability of the system, as well as the ease of use. Our article today is aimed at beginners; we will look at how to partition a disk to install Linux. Let's talk why this is needed, what sizes to choose for partitions, and so on.

Let's start with the fact that in Linux there are no disks as we know them in Windows. Everything is much more transparent here. There are disk partitions, and there is also one root file system.

The partition you have chosen for this is connected as the root file system, and other partitions are connected to it in subdirectories. Flash drives are also connected here, DVDs and other external media. For example, the bootloader partition is connected to /boot, virtual ones are connected as /sys, /proc, /dev file systems kernel, and RAM is attached as /tmp.

But to the user it all looks like a single file system. It seems that all the files are on the root partition, and not scattered across several. Generally speaking, you can install Linux on a single partition without splitting the file system, but this is not recommended; below we will look at why.

Why do this?

Each section has its own task. Partitioning a Linux disk between several partitions isolates them from one another. If one partition, for example, the home partition, runs out of space, the system will still be able to operate normally, because this does not affect the root partition in any way.

Removing the home partition is also very useful during reinstallations. This way you can reinstall the system but keep all your data. Or you can also use one user on multiple systems.

The bootloader is placed on a separate partition if the file system of your root partition is not supported by Grub, for example, if you use Btrfs, xfs, etc. Also, such partitioning of the disk into linux partitions is necessary if you use LVM technology or encryption. In addition, the bootloader will find its files faster if they are on a small partition at the beginning of the disk, and not somewhere in the wilds of a multi-gigabyte file system.

Servers sometimes have /var and /usr partitions. This is again necessary for isolation and security, for example, you can prevent the execution of files from the /var partition using the mount option.

Disk partitioning for Linux

The standard disk layout for Linux uses four partitions:

  • / - root, the main partition for the file system;
  • /boot- bootloader files;
  • /home- section for user files;
  • swap- swap partition, for unloading pages from random access memory if it is full.

All that is listed here except swap are mount points in the file system. This means that the specified partitions will be mounted to the corresponding folders in the file system.

Now we will not consider how disk partitioning for installing Linux is done in practice. All this is done in the installer in a couple of clicks. But let’s take a closer look at file systems and their sizes so that you know exactly what values ​​to choose.

/boot partition

Breakdown hard drive Linux starts with the creation of this partition. Everything is very simple here. This section contains configuration files and bootloader modules that are read when Grub starts, as well as the kernel and initrd image. These files do not take up much space, about 100 Megabytes, but some distributions may also host Grub themes here, and older versions of kernels will accumulate over time, so it is better to reserve space and allocate 300 Megabytes. This will be quite enough.

As for the file system, we need the fastest and simplest one. The purpose of this section is to provide files as quickly as possible during loading. Journaling is not needed here as it will only slow down loading and files change very rarely. Therefore, our choice is ext2.

Chapter /

This main section your system. It will contain all system files, and other partitions will be connected to it. This is where we will install all our programs and games.

Considering all this, you need to allocate a sufficient amount of space. Minimum Requirements so that all files from installation disk- 8 Gigabytes. But when you install all the programs you need, the system will begin to take up about 20 Gigabytes (this is without games). With each update, the system size will further increase by 200-500 megabytes. Now add games here. If you take 50 Gigabytes as root, you won’t go wrong.

The file system must be stable, because otherwise you risk losing the entire system if the computer fails to shut down. And that's why we need a journaling file system. You can use ext4, resierfs or btrfs. Now the latter has become noticeably more stable. But it is strictly not recommended to take something like XFS because it is very sensitive to failures.

But you can't use ntfs or fat. The fact is that the kernel uses some features of file systems to proper operation, for example, hard links to configuration files or the inotify system to notify about changes to the file system. But these file systems do not support such functions.

swap section

This is the swap partition where unused memory pages will be sent if it is full. Also, all the contents of memory are recorded here when the computer goes into sleep or hibernation mode. Of course, the swap partition can be placed as a file on the disk, just like in WIndows, but this will work faster. The size is calculated very simply, it should be equal to the amount of RAM. The file system is special - swap.

Home partition - /home

This is the section for your files. Your downloads, documents, videos, music, as well as program settings will be here. There can't be enough space here, so we take everything that's left. The file system, just like the root, needs to be stable and fast. You can take the same ext4 or btrfs, or even xfs, if you are sure that there should be no unexpected failures and power outages. Disk partitioning for Linux for this partition is done last.

Dynamically resizing partitions

It often happens that the disk partitioning for installing Linux has already been done, the system is installed and working normally, and after a while we realize that there is not enough space allocated for a particular partition. In such cases, we are faced with a long re-partitioning or even complete removal sections, if you did not immediately foresee this option.

Firstly, you can create a backup partition, after the one that may require a lot of space in the future, leaving 10 GB in reserve so that there are no problems later is not such a bad idea.

Secondly, you can use . This is a virtual layer for working with disks in Linux, allowing you to dynamically resize partitions regardless of the free space before and after them.

conclusions

Now you know how to partition a Linux disk and can handle this task. Correct breakdown will save you a lot of time later. If you have any questions, ask in the comments!

Before installing the operating system, it is necessary to partition the hard drive, during which the disk is divided into partitions and formatted. Installers of modern operating systems can perform this operation automatically, but they usually do this not in the most optimal way. In certain cases it makes sense to carry out this operation manually using special programs. The need for manual disk partitioning arises if:

  • It is planned to install several operating systems on the computer, for example, Windows and Linux;
  • The operating or file system has restrictions on the maximum volume size, so a large disk must be divided into several small logical drives.

There are also some benefits that can be achieved by using proper disk partitioning. When performing a backup, you can archive not the entire disk, but only part of it, with important data. For example, you can create separate archives for the user and system sections. At the same time, in the event of a system crash, user data may remain intact. And the time required for archiving and recovery will be reduced. You can also use different file systems and different cluster sizes. For example, small size cluster will significantly save space on a partition where many small files are stored.

File systems

File system defines the way information is organized and stored on disks. IN journaled The file system, in the so-called “log”, records file changes that are planned to be made, so in the event of failures, the likelihood of data loss is significantly reduced.

Ext- the first file system in Linux. Currently practically not used.

Ext2- non-journaling file system. Can be used for data that rarely changes. For example, for boot sectors of disks, for working with SSDs and flash cards that have a limited resource of write cycles. Characterized by high speed, however, the read speed is lower than that of the more modern journaled system - ext4.

Ext3- is a journaled version of ext2. Widely used before the advent of ext4.

Ext4- developed on the basis of ext3, has higher performance, allows you to work with very large disks and files. This is the most popular file system for Linux today, which is used for system files and user data.

ReiserFS- the first journaling file system for Linux. It can pack files into one block, which improves performance and saves disk space when working with small files. Reiser4 is the fourth version of ReiserFS, which improves performance and reliability of data processing. Added the ability to use plugins that can, for example, compress or encrypt data on the fly. Recommended for working with small files.

XFS- a journaled system with high performance can be recommended for working with large files.

JFS is another journaling file system developed by IBM. The developers sought to achieve high reliability, performance and scalability for running on multiprocessor computers.

Tmpfs- designed to place temporary files in the computer's RAM. This is especially relevant when working with an SSD and having free RAM.

FAT And NTFS- file MS-DOS systems and Windows, which are also supported by Linux. A Linux user can have access to FAT and NTFS partitions. Used for installing appropriate systems, for transferring and sharing data.

Swap- can be either a separate disk partition or a regular file. Used exclusively to create virtual memory. Virtual memory is necessary when there is insufficient main memory (RAM), but the speed of operation when using such memory is significantly reduced. Swap is necessary for computers with a small amount of memory; in this case, it is recommended to create a swap partition or file 2-4 times larger than the computer's RAM. Swap is also necessary to go into sleep mode; in this case, you need to allocate a memory amount equal to the computer's RAM or a little more. If the computer has sufficient memory and does not require sleep mode, then swap can be disabled altogether. Modern personal computer Usually 4 GB of RAM is enough. But when processing large amounts of data, servers with many users may require significantly larger amounts of memory.

Disk structure in Linux

The disk can be divided into four physical partitions. One of these sections may be extended. An extended partition can be divided into an unlimited number of logical partitions. Disks in Linux are designated by the letters sd?, where instead of a question mark, letters of the Latin alphabet are used, starting with “a”. That is, the first disk in the system is called sda, the second is sdb, the third is sdc, etc. On older computers, with IDE drives names may be used: hda, hdb, hdc, etc. In turn, disk partitions are indicated by numbers: sda1, sdb5, sdc7. The first four digits are reserved for physical partitions: sda1, sda2, sda3, sda4. Even if the disk has fewer than four physical partitions, the first logical partition will be called sda5.

Directory structure

Here we will consider only those directories that make sense to be placed on a separate section.

/ - the root of the disk. Created anyway. Recommended file systems: ext4, JFS, ReiserFS.

/boot- serves to boot the system. The recommended file system is ext2.

/home- contains user files. Recommended file systems: ext4, ReiserFS, XFS (for large files).

/tmp- used to store temporary files. Recommended file systems: ReiserFS, ext4, tmpfs.

/var- often used for storage modified files. Recommended file system: ReiserFS, ext4.

/usr- contains files of programs and libraries installed by the user. The recommended file system is ext4.

Disk partitioning using fdisk

Fdisk is a utility for partitioning hard drives with a text interface. All devices in Linux are located in the /dev directory. You can view a list of disks using the command:

ls /dev | grep sd

If the sda ​​disk is already partitioned, then information about the partitions can be found using the command:

sudo fdisk -l /dev/sda

You can also get information about partitions using the command:

Let's say we want to get the following disk structure:

1 (sda1) partition for Windows with a capacity of 100 GB.

2 (sda5) partition for booting Linux - /boot 100 MB

3 (sda6) swap partition - 4 GB.

4 (sda7) root partition - / 20 GB.

5 (sda8) partition /home - the entire remaining disk.

Launch fdisk:

sudo fdisk /dev/sda

If you need to partition the second or third disk, instead of sda we write sdb or sdc.

After starting the program, press “m” to view the list of commands.

We look at the partition table by pressing “p”.

If the disk is not empty, delete old partitions with the “d” command, after which we indicate the partition number. If there are several partitions, you will have to run the command several times.

We create new section physical Windows by pressing the “n” key and then “p”. Next, indicate the section number - “1”. The first sector is the default - press “Enter”. And at the end, enter the disk size “+100G”.

In the terminal it will look like this:

Command (m for reference): n

e extended

Select (default p): p

Section number (1-4, default 1): 1

First sector (2048-976773167, default 2048):

Default value 2048 is used

Last sector, +sectors or +size(K,M,G) (2048-976773167, default 976773167): +100G

Command (m for reference): n

e extended

Select (default p): e

Section number (1-4, default 2): 2

First sector (209717248-976773167, default 209717248):

Uses default value 209717248 Last sector, +sectors or +size(K,M,G) (209717248-976773167, default 976773167):

The default value is used 976773167

The next partition is swap, with a capacity of 4 Gigabytes. Sequentially “n”, “l”, “Enter” and at the end we enter +4G.

In the same way, create a root partition of 20 Gigabytes by pressing “n”, “l”, “Enter” and +20G.

And the /home partition, which will take up all the remaining disk space: “n”, “l”, “Enter”, “Enter”.

After which, pressing “p”, we will see something like the following:

/dev/sda1 2048 209717247 104857600 83 Linux

/dev/sda6 209926144 218314751 4194304 83 Linux

Since we plan to install Windows on the sda1 partition, we will change the file system type. Press “l” and see that NTFS corresponds to id=7. To change the type, press “t”, then the section number “1” and the code “7”, in the terminal it will look like this:

Command (m for reference): t

Section number (1-8): 1

Hexadecimal code (enter L for a list of codes): 7

System partition type 1 changed to 7 (HPFS/NTFS/exFAT)

In the same way, change the id of the paging file for the sda6 partition: press “l”, “6” and enter code 82.

Let's see what happened with the "p" command:

Device Load Start End Blocks Id System

/dev/sda1 2048 209717247 104857600 7 HPFS/NTFS/exFAT

/dev/sda2 209717248 976773167 383527960 5 Extended

/dev/sda5 209719296 209924095 102400 83 Linux

/dev/sda6 209926144 218314751 4194304 82 Linux swap / Solaris

/dev/sda7 218316800 260259839 20971520 83 Linux

/dev/sda8 260261888 976773167 358255640 83 Linux

If everything is in order, then to write partitions to the disk, press “w”. Until we enter the “w” command, only preliminary operations are performed and no data is written to the disk. After recording the partitions, we reboot and install the systems.

Disk partitioning using GParted

GParted or GNOME Partition Editor is a program for editing disk partitions with a graphical interface. It is essentially a wrapper around the GNU Parted text utility. GParted has a simple and intuitive interface. It allows you not only to create and delete partitions, but also to resize, copy and move them. The program supports working with many popular file systems.

Attention: subsequent actions may lead to complete loss of information from computer disks. Before using GParted, be sure to make copies important information. It is also advisable to charge the laptop battery using a UPS. Some operations may take a long time and data may be lost if the power is turned off.

We launch the program with the command:

You need to run it as a privileged user; to do this, first run the command su, or sudo:

sudo gparted

If the command does not work, then you need to install this program, although many distributions include it by default.

If the disk is already partitioned, we will see something like this:

Rice. 1. GParted program

There is a text menu at the top. Below are buttons to perform basic actions. WITH right side from the icons the disk selection window. The partitions of the selected disk are shown below in the form of rectangles. Even lower, the same disk partitions are in table form, with more detailed description. If you right-click on any of the sections, a menu will appear with a list of operations that can be performed with the selected section. You can also select a disk partition with the left mouse button, and then select an operation in the top text menu or by clicking on the icon.

If the disk is unpartitioned, you can immediately begin creating partitions. Otherwise, delete unnecessary partitions - right-click (RMB) on the partition name and select “Delete” from the menu.

If the partition is used by the system (mounted), then before performing operations you need to unmount it - right-click on the partition and select “Unmount” from the menu.

If the disk has the partitions you want, you can resize them to make room for new partitions. Let's say there is a Windows partition that occupies the entire disk. You must leave Windows and install Linux. To do this, right-click on the Windows partition and select “Resize/Move” from the menu. Then we indicate the new size of the Windows partition, or the free space before or after the partition. After that, click the “Resize or Move” button.

Rice. 2. Resizing the partition

Naturally, for this operation the Windows partition must have sufficient free space. After resizing the partition, there will be unallocated space that can be used to create Linux partitions.

To create a new partition, you need to right-click on the unallocated space and select “New” from the menu. Next, in the “New size” field, indicate the size of the partition. We indicate the partition type (primary, extended, logical) and file system, as well as the disk label, for example “home”.

Rice. 3. Create a new partition

We create all the necessary partitions (see above for the description of working with fdisk).

At the very end, to perform all selected operations, you need to top menu“Edit”, select “Perform all operations”, or click the corresponding button in the form of a green checkmark on the toolbar. You just have to wait a while while the program partitions the disk.

Today we will learn on our own create disk partitions in Linux Ubuntu in the process of installing the distribution on a computer, in other words, manually create hard disk partitions in Ubuntu that are necessary for the normal functioning of the operating system on a home computer, and we’ll also talk a little about which partition is needed for what.

So, as an example, we will use the current one on this moment version of Linux Ubuntu 17.04, i.e. let's imagine that you are installing Ubuntu 17.04 ( or any other derivative distribution, such as Kubuntu, Lubuntu, Ubuntu MATE and others) and reached the step where you need to select “ type of instalation", i.e. disk partition type, for example: automatic - this is the first item " Erase disk and install Ubuntu", or " Another variant" - this is exactly the type in which we can mark up the disk ourselves; we will now consider it.

Note! In this article we will look at the initial layout of a blank disk, i.e. on which there are no partitions and data yet.

Creating disk partitions during Linux Ubuntu installation

To create a disk partition yourself during the installation of Linux Ubuntu, you must select the installation type " Another variant" and press " Continue».

If you have several physical disks ( I have one) select the one you need and press “ New partition table».


We are then warned that a new empty partition table will be created, we click " Continue", i.e. confirm your action.


The first thing we must create is the root partition, i.e. basic ( systemic) section for installing the system. For this we indicate:

  • Size– for the root partition, a minimum of 15 gigabytes; in the future, of course, it is better to specify more, for example, 50 gigabytes. I have a small disk for testing, so I specify 15 gigabytes;
  • New partition type– indicate “ Primary", because this type must be on disk;
  • – indicate “ The beginning of this space»;
  • Use as– here we need to select the file system type, leave the default Ext4 file system - this is a journaled file system for operating systems Linux systems, which is currently most suitable for the file system of the root partition ( yes and for user data);
  • Mount point– we indicate “/”, since this is our root partition.

Click " OK».


Then, in almost the same way, we create a section for user data, i.e. home section. Creating such a section will allow you to store your data ( documents, music, photos and so on) in a separate place that will not need to be copied in any special way ( reserve) during reinstallation ( updates) distribution or even its change.

In this case, we need to specify:

  • Size– maximum possible, i.e. all the remaining space, as I already said, my test disk is small, so there is little space left;
  • New partition type– indicate “ Logical»;
  • Location of the new section– indicate “ The beginning of this space»;
  • Use as– also select the Ext4 file system;
  • Mount point– specify “/home”.

Click " OK».


Swap partition (swap) we will not create, since in Ubuntu, starting from version 17.04, a swap file is used instead of a swap partition ( like in Windows). By default, its size is 5% of the free disk space, but not more than 2 gigabytes. After installation, the paging file size can be changed at any time.

This is the disk layout that is suitable for home computer, finished, press " Install now».


Confirm making changes to the disk, click “ Continue" and continue installing the distribution.


That's all for me, I hope the material was useful to you, bye!

Marking Linux disk breaks it down logically into smaller parts that will be used different programs. On solid-state devices, the word "partition" refers to space. Typically Linux is installed on the first one. This arrangement on a PC can be represented in a simplified form as a library. The operating system is a librarian that provides a tree of directories as available files.

On computers, each OS has its own type of file system, which is not accessible to others because they cannot read it. This has nothing to do with Linux, which is universal and understands files used in Windows 95/98, as well as many other modern operating systems.

Each distribution's installation guide contains a section on Linux disk partitioning. The KISS principle (Keep It Simple Stupid) is used for beginners. Desktop systems for personal use do not have the same complexity, requiring many partitions to be installed. For proper placement of Linux, three mandatory ones are recommended: swap, root and home. These are logical rather than physical separations, so they can be edited and manipulated for different purposes.

Despite the many types of file systems, only 3 are used: basic, extended and logical. There is a limitation for Linux disk partitioning - it must have no more than four parts. This requirement is related to the capabilities that tell the PC the boot location and main partitions for the OS. But if you still need more, then perform extended Linux disk partitioning.

It will serve as a hollow container for any number of smaller logic elements. You can create as many as you need, and also execute it as a non-OS part. However, despite this positive, extended partitions have not received widespread use, because the user cannot boot directly from this disk. There are ways around this requirement, but it is better to coordinate the underlying system properly.

Linux mount points

It's common to partition the disk when installing Linux, which works by putting everything into a tree. The next partition is mounted as a branch in a specific folder, usually media or mnt. The directory in which to mount is called the mount point. This method works better with a tree system, but you can create folders anywhere you like.

The standard disk partitioning scheme when installing Linux looks like this:

  1. The 12-20 GB partition for the OS is called root.
  2. A small partition for increasing RAM, called swap.
  3. Great for personal use - home.

The exact size requirements of Linux disk partitioning depend on your needs. If the user edits a lot of multimedia or has little RAM, he should use a larger swap volume. The rule of thumb is to choose twice the amount of RAM as space and place it in the location quick access, for example, at the beginning or end of the disc.

Even if the user installs a “ton” of software for the root partition, when partitioning the disk for Linux, a maximum of 20 GB is enough. Distributions use ext 3/4 as a file system that has an independent self-cleaning mechanism and does not require defragmentation. However, for this there must be a free space of 25-35% of the volume. Home stores personal documents and programs. It is functionally equivalent to the Users directory in Windows. It's useful to have it in separate element, because during an update or reinstallation of the OS, the data in this directory will not be changed.

"Swap" is the partitioning of a Linux hard drive to provide a swap function, which exists as a logical area on the disk or simply in a file. Instead of using physical space in RAM, it grabs disk space to store temporary files, thereby reducing RAM usage. The combined set of RAM and swap creates virtual memory larger than the default on the computer. This way, the Linux kernel can run processes that require more memory than is physically available.

The swappiness function represents the kernel's preference to use swap. The permutation can have a value from 0 to 100, but the default value is 60. To be clear, this value may not be equally effective in all cases as it will depend on individual usage. technical characteristics equipment and user needs.

The user needs one gpt-partitioned Linux disk, used as virtual swap space. For simplicity, create a file with a size of 50% to 100% of the physical memory in the OS. If the PC has little RAM and a large amount of disk space, then increase the volume.

Represented as a forward slash (/). This top of the directory tree contains Linux and everything installed on the system and is equivalent to the DOS or Windows "C:" drive. The user creating the partition for root directory, should not be confused with account root, which is a system administrator function.

The layout of Kali Linux disks and the size of the root element will depend on what is being installed or planned to be placed. Pre-read the documentation for the distribution and reserve enough space for maximum installation, as well as at least 100 MB for temporary space.

If the user plans to download and try a lot software, leave more space. If your PC is small HDD, you can trim installed packages to save space. In general, if the PC has a root partition between 2 GB and 8 GB, then this is quite enough for operational work systems.

The third and final step that is performed when partitioning a disk for installing Linux is creating a home directory. This is the place where they are stored user files, in other words, data. This is equivalent to the My Documents folder on the MS Windows desktop if MS Office is installed.

In a multi-user system, each user has his own home directory. The contents of the home directory are protected by file permissions and are accessible to all authenticated subscribers. Any user with administrative privileges has the right to access the protected file, including other users' home directories.

Separating user data from system-wide data avoids redundancy and greatly simplifies backup important documents. Malicious programs and viruses running under the user's name and with his privileges can only change files in the home directory and workgroup files of which the user is a part, but not actual system files.

Strictly speaking, there is no need to create a separate place for home. If this is not done, it will be located in the root partition, like all other system directories. If you don't have enough space, you may need to configure your computer to create a separate storage, which will later allow you to reinstall Linux without losing personal data.

Typically, a program is used to create partitions and sections Partition Magic, which can be found on the BOOTABLE CD. Launch BootCD and the first option - Disk Partition Tools.

Algorithm of actions:

  1. Select a hard drive and press an additional button in the form of a “menu”, where you assign a GB volume for Linux.
  2. Next, a section will appear that you will have to create Unallow.
  3. Click the button on it and select “Create”.
  4. The setup menu appears. The Linux partition must be primary and formatted in Ext3 or Ext2.
  5. The LABEL is labeled Ubuntu, because the distribution will be installed.
  6. The cluster size is left as “Default”.
  7. Once it is configured, confirm with the “OK” button on the screen.

To create a disk layout layout for Linux Mint, change the installer page to "something different" and then they will be shown on the hard drive.

The process of creating new partitions:

  1. Click the "+" button to add a new one and adjust the size in which you want to create Linux Mint.
  2. Set the mount point to root and leave the file system as ext4.
  3. Create a swap and select a “swap area”.
  4. Open a terminal application and enter the following: sudo su.
  5. Enter your current password to receive root rights. The command will change from the ~ symbol to #.
  6. Activate the swap file, open the file with the Nano editor: # nano / etc / fstab.
  7. Write the following text: /swapfile none swap defaults 0 0.
  8. Pressing Ctrl + O together confirms saving the /etc/fstab file.
  9. Pressing the Ctrl + X keys together confirms exit from Nano.
  10. After reboot, the operating system will use /swapfile as the swap file.
  11. To check this, enter the following command in the terminal: $ cat / proc / swaps.
  12. The user will see which device, partition or file is being used for sharing purposes and how it is being used.

Similarly, you can create any Linux Mint partition.

Stages Ubuntu settings 14.04:

  1. In the LiveCD assistant, select the installation; in the fourth paragraph, check the “Advanced options” option to create a separation. A 500 GB hard drive will appear.
  2. Click “Create Table” and a warning will appear indicating that all content will be lost.
  3. Click “Continue”, an empty configuration table will open.
  4. Select free space and click on the “+” icon to add a partition, for example: Size: 1024 MB (1 GB) > Type: Primary > File system: ext4 > Mount point: boot.
  5. Create a partition for SWAP: Size: 8192 MB (8 GB) > Doubles the computer's 4 GB RAM > Type: Logic > File system: Swap area > Attachment point.
  6. Create for OS and work programs: Size: 51,200 MB (50 GB) > Type: Logic > File system: ext4 > Attachment point.
  7. Create home where users usually save torrent downloads, movies, music, thousands of photos: Size: 476,454 MB (more or less what's left of the disk) > Type: Logic > File system: ext4 > Mounting point: home.

Sometimes you need to install Linux on a Windows PC. To do this, you need to allocate disk space. It is recommended to use the GParted partitioning tool to resize Windows and create new partitions for Linux.

In general, Linux distributions have good hardware support. But precautions are necessary. Whenever the correct Linux disk partitioning is not applied, there is a risk of data loss, regardless of what OS is installed. It is important to ensure that critical data is stored on external media So what backups not damaged and can be restored.

Ubuntu, like many other Linux distributions, comes as a bootable LiveCD. This means you can download it and check your hardware compatibility without making any changes to your existing installations.

Process for planning hard drive layout for Linux installation:

  1. After clicking the Install button it will start Linux installation. You should not use a small system Windows partition, but you can resize the NTFS partition to free up space.
  2. The default installation choice is to install Win and Linux side by side.
  3. Linux requires three partitions (root, swap, home). Windows already uses two. Only four main ones are allowed on a disk. This means that you will need to enable the extra space gained from shrinking Windows 7, otherwise you will have to forego using a separate swap or home partition on Linux.
  4. Change occupied Windows size(sda2). Create an extended one - it will be called sda3.
  5. Create logical root, swap, home inside Extended - will be called sda5, sda6 and sda7.
  6. Change the section.
  7. Use GParted to create the layout. GParted comes with Ubuntu. It can be found in System > Administration > Editor.
  8. Next step is to create an extended partition that will take up all the free space, including the new 2 GB freed up by Windows.
  9. GParted is quite friendly and will start working. The compression task will be run first, then a simulation will be run to ensure that the marker can perform the desired task. It will then check NTFS consistency and fix errors if it finds them. Afterwards it will resize and copy all the data.

There are many programs that can help you manage disk partitions in Linux. But often such a huge number of alternatives becomes a problem for beginners in the field and makes them doubt which one to choose.

Managing hard drive partitions is a high-risk practice because if the user doesn't know exactly what he's doing, he can render the system inoperable. Beginners are advised to start with the graphical options of the tools and forget about the command line.

  1. Fdisk is a powerful tool command line with a text mode interface that allows you to manage partitions. Help makes it easier to work with it, each command of its interactive menu can be called by one letter, such as m - for help, n - for creating new ones, p - for displaying a table, t - for formatting, w - for writing.
  2. Parted is a text-mode tool, the main difference from the previous one is that all actions of sent commands will be applied immediately. Therefore, it must be handled even more carefully than the previous one.

The three most relevant GUI tools are:

  1. GParted is recommended for all users because its GUI is simple and intuitive, allowing you to perform many operations from creating new, formatting, creating tables, resizing.
  2. GNOME - by default, its own disk tool is installed, its interface is simple, but, to be honest, many still recommend GParted.
  3. KDE - provided its Plasma desktop environments with another tool for creating default partitions. In this case the interface is more similar to GParted and simple, so it can become another good option by power.

Some distributions, such as Ubuntu, offer GParted as a LiveCD utility. Therefore, if the user learns how to use the program, he will be able to properly partition the disks in order to have two or more operating systems on the PC, while the information on it will be better organized.