In Linux there is only one file system; so storage devices are not a root in itself, as is the case in Windows systems.
However each storage hardware device corresponds to an object in the/dev directory; However, we cannot access the data that it contains from there. Hardware devices are identified by two names: first, the generic designation of the disk (in the case of a SATA, SDA, SDB,…, sdX disk based on the number of disks installed), and secondly, its UUID.
In the previous example, there are two hardware disks (SDA and SDB), and SDA includes 3 partitions (1, 2 and 5). The fdisk-l command gives more information about these partitions:
This example shows that the SDA disk is divided into two (sda1 and sda2), sda1 is larger than sda2, and sda2 contains sda5. Indeed, when you want to have more than one partition on a disk, you can create up to 4 primary partitions, but it is also possible to create a primary (or Elementary) partition smaller than the entire disk, create an extended partition in the rest of the disk, and then create in it all the other partitions you want. The fdisk command can be used to format a disk, but cfdisk is preferable; for example, to create a primary partition occupying all the space on/dev/sdb, we will proceed as follows:
The console interface gives you some information about the device and allows you to change its partitioning. Choose in order: new, primary, and then the suggested size (which is the maximum available size). The partition must be bootable.
You will see the result by launching fdisk-l.
Your disk is now formatted, but the file system structure is not created. To do this we use the command mkfs. The syntax is as follows:
mkfs -t TYPEPARTITION
So run the following command:
mkfs -t ext4 /dev/sdb1
To be able to read the data on a hardware device, it must first be formatted in a Linux-readable file system type, and also be “mounted”.
The mount command (without arguments) is used to see which devices are associated with which branches of the file system. Each row displayed contains one of these associations, according to the following syntax:
DEVICE on Path type TYPEOPTIONS
To mount a disk, you must first find a directory. By Convention, you put the mount points in the /mnt or /media directories, and each device must have its own directory. To mount the /dev/sdb1 (ext4 format) device in the /mnt/disk directory (which must exist beforehand), the following command will be launched:
mount -t ext4 /dev/sdb1 /mnt/disk
To ensure that the files are automatically mounted at the time of Linux startup, The information normally passed to mount in the file /etc/fstab.
The mount-a command automatically mounts all the devices listed in /etc/fstab
Note that the device is identified by its UUID in /etc/fstab. To find out which disk this UUID matches, run the blkid command