What is dev directory in linux

Understanding the Role of /dev/sda in Linux

When a Windows user encounters a Linux system for the first time, their first thought is: where are the “C:/“, “D:/“, or “E:/” drives?

So, my innocent Linux newbies, you must know that Linux doesn’t have any concept of local disk like in Windows; here, each and everything represents a file.

Before you understand exactly what “/dev/sda” is (primary objective of this article), you must first know about what files are and the different types of files in Linux.

What are Files in Linux?

In Linux, each device, like a network adapter, mounted disk, partition, etc., is a file that usually lives somewhere in your “/” root directory (we will discuss them later).

Primarily, there are three types of files in Linux, followed by:

  • General/Ordinary Files: These are the simple files that contain the data.
  • Directory Files: These are the files that contain the ordinary files as well as the directory files.
  • Device Files: These are the device files that represent all the hardware devices connected to your system on boot.

The focus of this article is mostly on the device files, as the primary objective of this article is to explain what “/dev/sda” is.

Now, as you understand, each device is represented as a file in Linux, and these files usually reside in your “/” root directory. Let’s see

What is the “/” Root Directory in Linux?

In simple terms, the root directory is the top directory in your Linux filesystem hierarchy, where all the other files and directories (including “/bin“, “/home“, “/mnt“, or “/var“) reside.

Execute the following command to get a complete list of all files and directories inside your “/” root directory.

Listing the root directory

As you can see, all the files in your system are categorized and stored in different directories based on their relationship in your parent “/” root directory, for example:

  • The “/bin” directory contains the executable files.
  • The “/home” directory contains user related information.
  • The “/mnt” directory contains information related to mounted files and directories.
  • The “/var” directory is used to store the variable data files.
Читайте также:  Файрвол на линукс минт

Similarly to this directory, the “/dev” directory also resides in your “/” root directory.

What is /dev in Linux

As we discussed earlier, there are three types of files in Linux; one of them are device files, which represent all the hardware devices connected to your system on boot.

The “/dev” directory contains all these files with their respective names like “ fd “, “ loop “, “ tty “, “ sda “, etc. Each of these files represents a single hardware component connected to your system.

Execute the following command to get a complete list of all device files in your “/dev” directory.

Listing the

As you can see, there is more information to consume for now, so we will primarily focus on our main topic, which is “sda” files.

What is /dev/sda in Linux

In “/dev/sda“, the “sd” portion of “sda” refers to an SCSI (Small Computer System Interface) disk, which is nothing but a block device and resides in the “/dev” directory.

Before we go any further, let’s find out how many “/dev/sda” device files I have in my “/dev” directory by running the following command:

$ ls -l /dev/sda*

Listing the sda device files

Now, before I go further and explain more about this, let’s check out how many partitions I have in my Linux system by issuing the fdisk command.

$ sudo fdisk -l

Listing the partition in Linux

From the above picture, in the device columns, you can clearly see that in my system I have three partitions that represent “BIOS boot“, “EFI System“, and “Linux filesystem“.

So, let’s properly understand what exactly the “sda” is and what it’s referring to in my system.

Whenever you install your Linux operating system, at the time of partition creation, your Linux takes each disk and assigns a decimal number in alphabetical order depending on the number of the disk it found, naming it “sda1“, “sda2“, “sda3“, etc.

Now, each of these SDAs represents a SCSI disk drive (a.k.a. partition) in your system. For me,

  • The “/dev/sda1” represents the BIOS boot partition.
  • The “/dev/sda2” represents the EFI system.
  • The “/dev/sda3” represents the Linux filesystem (where the “/” root directory resides).
Читайте также:  Разработка модулей ядра линукс

Now, don’t get caught up in the idea that you will also have the same number of SDAs in your system pointing towards the same SCSI disk drive; it all depends upon the number of partitions you have in your system.

Final Note to Window Users

Linux users are already familiar with the meaning of “sda“, but if you are a long-time Windows user who has recently transitioned to the Linux environment, you may not be. Then you still might have doubts about where exactly the local disks are that I will click to see my files.

So, for that, you (the Windows user) should note that the Windows filesystem is totally different from Linux; whereas in Linux you don’t have any local disk for each partition, here you have to store and access your files from your “/home/ ” directory.

And the role of the “sda” is not to provide you with separation partitions (although they are files) like Windows; they are mostly used by the applications or your Linux system to find the separate partitions and utilize them based on their role.

So, that’s it for now. If you have any doubts or questions related to this topic, feel free to ask them in the comment section.

Источник

What is /dev/sda in Linux File System?

If you are transitioning from other operating system environments to Linux, the first puzzle you are most likely to face is understanding the Linux file system. To be more specific, you have to understand how Linux labels its hard disk drives (whether internal or external).

On a Windows operating system, this step is straightforward as all the disk drives connected to the operating system environment are identified by relatable labels like C: , D: , F: etc. In most cases, it is the disk drive labeled C: that hosts the installed copy of the Windows operating system.

Understanding Linux Files

A Linux operating system perceives each and every device-based connection linked to its OS environment as a file. Therefore, Directory Files, Ordinary Files, and Device Files are all categorized as file types.

  • General/Ordinary Files – These are the document files that primarily contain data.
  • Directory Files – These are files that contain both Ordinary files and Directories which are defined to host some Ordinary files if need be.
  • Device Files – These files are a representation of hardware devices as device files on the system.
Читайте также:  Язык скриптов для linux

What is /dev in Linux

Before we get to /dev/sda ; which is the primary objective of this article, we must go through /dev . We have already stated that the Linux operating system perceives hardware devices connected to it as device files.

The hierarchy of the Linux operating system begins from the root file (/) .

Linux File System

It is the starting point of understanding the Linux operating system architecture. From the above screen capture, we have listed the content under this root (/) file directory. From this view and based on this article guide’s objective, we are more interested in what the directory dev has to offer.

/dev can be fully translated as root device since we are moving from the root (/) directory to this directory file within it. Viewing the content of this dev directory should reveal/list device files that translate to hardware components connected to our computer.

List Linux Dev Files

As you can see, there is more than enough information to chew inside this directory listing. We are however more interested in what the highlighted sda device file has to offer.

What is /dev/sda in Linux

From /dev/sda , the sd portion of sda can be translated to SCSI (Small Computer System Interface) disk.

Therefore, sda in full can be translated as the first SCSI hard disk. Under the /dev directory; from the screenshot above, we can note the device files sda, sda1, sda2, and sda5. The device files sda1, sda2, and sda5 exist as partitions of the first SCSI hard disk sda.

We can now fully refer to this device file as the root device’s first SCSI hard disk. To view some basic information about this device file, we can run the following fdisk command as a sudoer/root user.

List Linux Partitions

On my end, /dev/sda is partitioned into three device files. /dev/sda1 is the boot partition that makes the Linux OS easily restart, /dev/sda2 is the extended partition primarily used for user files storage, and /dev/sda5 is the Linux partition where your Linux OS installed files reside.

The concept of /dev/sda is now at our fingertips.

Источник

Оцените статью
Adblock
detector