【Linux partitions】What are they? + Types + How to Create One ▷ 2022

Dividing one into several units has its advantages. To cite a case, if the software were to present a failure and there are two partitions, one for the operating system and one for your filesyour documents will not be lost or suffer any damage, because being isolated will keep them safe.

In many cases, They bring by default the creation of partitions to divide the sector where the operating system goes and the rest of the information that is stored on the computer. And it is not a single division that can be done, it only takes organization and knowledge to have your documents protected.

The course we are starting will show us the different types of partitions that exist as well as a basic way to do this job on our PC.

What are partitions in Linux and how are they different from those we have in Windows?

Linux partitions are segmentations that are made to the hard drive to distribute the space in different functions and they are divided into two: primary and logical. When installing the distribution, a minimum of two divisions must be established, one for the file system and one for the swap or also called exchange area.

According to the needs and the use that is going to be given to the computer, additional ones can be created, which will be assigned a certain space on the physical drive. In the case of Windows, can also be make other divisions to the hard disk defined by letterswith the difference that only the operating system can be installed on one of the primary partitions.

What are the main types of partitions that we can find in Linux?

There are those who do not stop to think about the importance of partitions in Linux. But if at some point you want to change distribution and the operating system along with the rest of the documents are in the same sector, it is most likely that when installing a new distro you lose everything you have stored.

For this reason we want to review the two main partitions that exist in Linux:

Data Partition

In this segment they go all the installation files of the Linux distribution that you have installed. With them, the operating system starts up once you turn on the computer. according to use and the distro will be allocated the hard drive space.

See also  【+101 Spotify Podcast in Spanish and English】2022 List

Combination of partitions

This partition is used for increase computer virtual memory. It can simulate that there is more RAM than it actually has and, when it needs to be used, the system itself passes processes to the extension.

These are the most used partitions by Linux users that you should know about right now

Now we will detail some of the directories used by Linux users, which are part of the root that is represented by the slash that we see before the name of the partition. There are some that are compatible with various computers and others that only fulfill their functions on the computer they are installed on.

Let’s review 19 of them:

  • /bin – This directory holds the binaries that allow basic user functions to work seamlessly.
  • /boot: This is where all the executable files used in the boot process of the operating system are located.
  • /dev: with this combination, the devices connected to the operating system are represented, such as hard drives or USB memories, among others.
  • /etc: contains no binaries and is solely in charge of configuration files for the database and the system in general.
  • /home: stores all the general files of a user, music, videos, documents and images, among others.
  • /lib – Contains the essential libraries for the binaries to run correctly along with the drivers for the devices.
  • /lib64: In this case it is the point libraries and drivers for the devices that work in 64 bits.
  • /media: mount points for removable disks, hard drive partitions, media players, or network shares are generated here.
  • /mnt: Its functions are similar to those of the media directory, also containing mount points.
  • /opt – Large packages or programs such as antivirus, web browsers, and other third-party executables. Larger files are installed in this directory instead of the users directory.
  • /proc: They are virtual files that are not saved and that show the applications that are running on the system at a certain moment.
  • /sbin – Stores the binaries with which you boot the system or perform restore or maintenance tasks. To activate it, you must have superuser credentials.
  • /root: is the root directory of the first partition that was made to the hard disk that has special superuser privileges.
  • /srv: refers to files related to web servers, FTP or any other system data.
  • /sys: also refers to virtual files related to the installed distribution.
  • /tmp: As its name suggests, it deals with temporary files such as cache or history of web browsers.
  • /usr: This is where files and programs visible to all users are stored.
  • /var – This is a directory that displays files that change in size, such as details of installed applications or databases.
  • /swap: it is the exchange that virtual memory does when it is occupied almost in its entirety with a partition of the hard disk. This is how the RAM is simulated to execute the processes.
See also  【 Turn Computer On and Off on Android 】 Step by Step Guide ▷ 2022

What is a partition scheme in Linux and what is the most basic one that users usually create?

When we talk about a partition scheme, we mean the allocation of space that we will give to each directory so that it can execute its function without problems.

And although there are many schemes, we are going to present the most basic one used by Linux users:

  • /home: here will be all the free space after we make the rest of the partitions.
  • /usr: you must allocate a space of at least 20 GB.
  • /var: you must place at least 2 GB.
  • /boot, /etc, /sbin, /bin, and /dev:: must have 250 MB of space for each.
  • /srv: must be at least 100 MB.
  • /opt: at least 500 MB.
  • /lib: 5 GB would be enough.
  • /tmp: Allocate space to them according to what is allocated to “/swap”.
  • /swap: at least double the RAM available to your computer and depending on the capacity of the hard drive.
  • /media and /mnt: just 8 Kb is enough.

Learn step by step how to create a partition on your computer with Linux like an expert

The idea of ​​disk partition is isolate sectors to use them for different purposeseither the installation of more than one operating system or to give it a structure that allows to better organize the files.

Let’s go with the basic steps that must be executed to be an expert when it comes to partitioning the hard drive on your computer:

Choose the type of partition

The two most commonly used types of partitions are GPT that uses modern standards or MBR, It is compatible with various operating systems.

See also  【 FACEBOOK 】How does the great Social Network work? ▷ 2022

If you opt for GPT, type the following command:

  • $ sudo parted /dev/xvdb mklabel gpt.

If you prefer MBR, run the following code:

  • $ sudo parted /dev/sda mklabel msdos.

Create a new partition

In this step we are going to format the partition taking into account the file system that is required.

The space for the new partition has already been allocated and the file system needs to be created:

  • Run the following command: $ sudo parted -a opt /dev/xvdb mkpart primary ext4 0% 100%
  • There you should see the option “lsbkl” showing a new partition called /dev/xvdb1

If you want to specify or modify the size of the partition, run this command:

  • (parted) mkpart primary ext4 0 1024MB
  • (parted) prints

If you want to list the information of the partitions, enter this code:

  • $ sudo parted /dev/xvdb print

Start a file system

In linux there is, What we are looking for now is to format it “Ext4” to the partition we created earlier.

To do so, we must take the following route:

  • Insert the following command: $ sudo mkfs.ext4 -L databackup /dev/xvdb1
  • To put a new partition labeluse this command: $ sudo e2label /dev/xvdb2 storagedata
  • To record the informationuse this code: lsblk –fs

Mount the file system

In this step we are going to write the data to the mount pointfor this we must have configured and updated all the entries correctly.

We add this command to temporarily mount the files:

  • $ sudo mount -t auto defaults /dev/xvdb1 /mnt/data.

The key is that the fstab file is updated, for this we use this command:

  • LABEL=databackup /mnt/data ext4 defaults 0 2.

Finally, we verify that it is available and list it with this command:

  • $ df -h -x tmpfs -x devtmpfs -x squashfs.
Loading Facebook Comments ...
Loading Disqus Comments ...