1

I am installing CentOS Linux distribution.

At the partition step, CentOS tells me that it has detected a sda HD in my machine and I should create partitions and assign mount points for this disk.

But I found the logic a little twisted. I understand that Linux treat everything as file and sda is usually the device file representing my first SATA hard disk. But since no Linux is installed yet, there should be no file system yet. So how could there be any device file like sda?

Someone tells me that “Linux installer is also a Linux OS and hence there's a in-memory file system. My hard drive is just one tiny element of the file system”. Why doing like this? Does Windows or other OS do the same thing?

  • The installer is a sort of LiveCD (or Live USB, or network boot or whatever) - just runs an installation program rather than a full desktop. – Mat Mar 17 '16 at 14:39
3

What /dev/sda means

There are four levels: raw disk, raw partition of that disk, formatted filesystem on a partition, and actual files stored within a filesystem.

/dev/sda means an entire disk, not a filesystem. Something with a number at the end is a partition of a disk: dev/sda1 is the first partition of the /dev/sda disk, and it's not even necessarily formatted yet! The filesystems each go on their own partitions by formatting each partition with its filesystem.

So, what will generally happen is that you'll partition /dev/sda, format /dev/sda1 with a filesystem, mount /dev/sda1's filesystem to somewhere, and then begin working with files on that filesystem.

Why have a unified filesystem

Linux (and UNIX in general) has the concept of the virtual filesystem. It combines all your real disks into one unified file system.

This can be quite useful. You might, for example, want to put your operating system and its programs on one really fast real disk and all the users' personal files on another fairly slow but huge disk because you want the OS to be fast but you want an affordable means of handling the files of thousands of users.

Unlike the usual method in Windows, which by default breaks each disk up into a separate letter and where using D:\Users might break some programs that hard code the path C:\Users, this can be done with ease and fluency. You format one partition in each disk, you mount the OS one to / and the user one to /home, and it acts like a system that put everything on one real disk, except you get that speed and affordability tradeoff you wanted.

  • Since /dev/sda and /dev/sda1 exist in file system, are they of some particular use? – smwikipedia Mar 18 '16 at 9:03
  • 1
    Yes, they're essentially files containing all the raw bytes of the disk or partition. You can use this, for example, to erase an entire disk or an entire partition by writing zero bytes to it. The partitioners and filesystem formatters also use them to write raw bytes to the right place on the disk or partition to accomplish their task. When a filesystem is mounted and you're dealing with files, the OS uses the partition device file behind the scenes to actually read raw bytes from and write raw bytes to the disk partition. – Olathe Mar 18 '16 at 20:21
1

/dev/sda designates the hard disk. That's the whole disk, no matter what's stored on the disk. If the disk is blank, coming straight from the factory, /dev/sda will exist. It had better, since this is how the system will access the disk to create partitions and filesystems on it.

A disk is usually divided into partitions. If there are partitions on the disk, they will appear as /dev/sda1, /dev/sda2, etc. Once again, the device files for the partitions exist as soon as the corresponding partition exists, no matter what the content of the partition is. If you want to create a filesystem on a partition, the first step is to create the partition, which will make the partition device appear, and then you tell the filesystem creation command to act on that partition.

Your last paragraph is only marginally related to the rest of the question. Note that the word “filesystem” can mean two different things:

  • All the files seen by a Unix system are presented in a single tree. This tree is called “the filesystem”.
  • The way the files in a partition (or served through a network protocol, etc.) are organized is called “a filesystem”.

“The filesystem” presents the individual “a filesystem”'s that are mounted.

Windows's filesystem is organized a little differently: it has a tree structure as well, but at the toplevel is a special format (drive letters c:, or host names \\hostname or other hierarchiess such as \\. and \\?) rather than a directory.

We have a number of threads that go into more depth about some of these topics:

0

Any OS installer you run is an executable, written in some sort of machine language, as there is no operating system at the time you power up your system. You have a BIOS (assuming we are talking about regular PC class machines) and BIOS is aware of your CPU type and how that CPU handles peripherals. Then you put your USB stick or CD/DVD ROM into the proper slot. BIOS goes and reads a very specific location on that device, called a "boot loader" for the lack of a better term. From that point on, a series of cascaded programs run. One of those programs is responsible for scanning your hardware, finding your disks among other things and assigning them proper names, such as sda or sdb.

You can fina a lot of information about how computers boot up and how OS installations go, by doing simple google searches. There are tons of how-to documents all around the web.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.