Linux+: Linux Install 05 – Disk Names and Layout

Discussion in 'Installation' started by Jarret W. Buse, Apr 27, 2014.

  1. Jarret W. Buse

    Jarret W. Buse Active Member Staff Writer

    Messages:
    152
    Likes Received:
    184
    Trophy Points:
    43
    Linux+: Linux Install 05 – Disk Names and Layout

    No matter which Operating System (OS) you may use, hard disks are a necessity to store the OS as well as applications and data. Understanding the hard disk naming scheme in Linux can be a little confusing at first.

    Naming

    For anyone who has used a Windows or DOS based system, you will recognize the drive letters as: C:, D:, etc. This disk naming scheme has been updated for some distros.

    Original naming schemes were as follows:
    • HD? - IDE
    • SD? - SCSI, USB, Firewire, SATA, etc.
    • FD# - Floppy Drive
    • SR# - CD/DVD Drives

    NOTE: The ‘?’ represents a letter and the ‘#’ a number.

    This meant that a system with an IDE drive would be named /dev/hda which would be noted as Drive C: in Windows. Note the following:

    • Primary Master – sda
    • Primary Slave – sdb
    • Secondary Master – sdc
    • Secondary Slave – sdd

    Within a disk each partition is numbered. For example, if the IDE Primary Master has two partitions, they would be named hda1 and hda2.

    NOTE: An exception to the partition numbers are that the Primary Partitions are numbered 1-4 and the logical partitions start at 5.

    The new method for naming drives is that all drives are sd?, except for the Floppy Drives which are still fd#.

    The new naming system is that all drives are referred to as sd?. The same exception for logical partitions exists for the numbering method.

    Remember that the main name without the partition number refers to the whole drive. For example, if the boot drive is sda and it has three partitions they would be sda1, sda2 and sda3. The drive itself as a whole is referred to as sda.

    CD/DVD/Blu-ray drives are named sr# where the first CD/DVD/Blu-ray drive is sr0. Some systems refer to the CD/DVD/Blu-ray device as scd#.

    Name assignments for IDE start with the Primary Master, Primary Slave, Secondary Master and then Secondary Slave.

    For example, we will assume a drive exists as Master on the Primary IDE controller. Two more drives exist as Secondary Master and Secondary Slave. The naming conventions would be as follows:

    • Primary Master – sda (hda)
    • Secondary Master – sdb (hdb)
    • Secondary Slave – sdc (hdc)

    Naming SCSI devices are based on the SCSI ID. Names are assigned starting with the lower SCSI IDs first as follows if no other drives exist in the system:

    • SCSI ID #1 – sda
    • SCSI ID #3 – sdb
    • SCSI ID #6 – sdc

    NOTE: If other SCSI IDs existed, then they would be named in the order of the SCSI ID numbers. You can check /bin/dmesg to check name assignment. The file can be viewed by typing 'dmesg' in a terminal.

    When multiple SCSI adapters exist, the naming scheme can begin with the SCSI adapter with the lowest SCSI ID first. It then check the SCSI chain of the higher ID number of the other SCSI adapter.

    NOTE: If a SCSI Adapter is removed, a hard disk moved or its ID changed, it is possible that some or all of the drive names can change at the next system boot.

    As USB storage devices, such as thumb drives, are attached they will be given the next available letter for sd?.

    NOTE: All drive names begin with the /dev/ which specifies the directory in which all drives are located. For example, sda would be /dev/sda.

    File System Hierarchy

    All Operating Systems require files to load and function as needed and each OS has its own directory structure. Linux is no exception and has a layout which is not too difficult once you understand what each folder is used for in the higher scheme of the OS.

    To start, there is the root. The root is denoted by the '/' which shows the top of the directory tree. Each folder is located in the root or within another folder in the root.

    NOTE: Keep in mind that even though the root is the main folder the other folders within root do not necessarily exist on the same partition. This will be discussed in more detail under Mount Points.


    • /bin/ – contains the system files necessary for OS functionality. These are the executable files of the basic commands needed by the users.
    • /boot/ – files need to boot Linux with very basic support. Also contains the kernel and boot files.
    • /cdrom/ – used as a mounting point for the CD-ROM, but is now mounted under /media.
    • /dev/ – contains the devices on the system recognized by Linux. Each device is a file, such as /dev/sda. Here, sda represents the first disk drive.
    • /etc/ – this is the folder containing all of the configuration files for the OS.
    • /home/ – contains a folder named for each user where their documents and settings are kept for that specific user.
    • /lib/ – used to store system files for the Linux OS which are .so files similar to Windows .dll files.
    • /lost+found/ – if a system crash occurs any recovered files are placed in this folder.
    • /media/ – used to list the mounted devices.
    • /mnt/ – contains the mounted devices. Most distros now use /media.
    • /opt/ – location for installed applications, but this is not used by all distros.
    • /proc/ – a virtual folder which contains the process information of the OS such as memory, devices, bus information and other items.
    • /root/ – home directory for root user.
    • /run/ – information about currently running services and current user.
    • /sbin/ – system files are stored here for use by the root user. These files require root privileges to be executed.
    • /srv/ – mostly unused in recent distros, it was used to keep site specific information for protocols such as FTP and other services.
    • /swap/ – used for swap files in distros which use swap files instead of swap partitions.
    • /sys/ – similar to /proc, but used for Plug and Play (PnP) device configuration
    • /tmp/ – storage for temporary files need by the OS or applications.
    • /usr/ – contains the application binaries for all users.
    • /var/ – has all files which change as the system is running such as cache, spools, logs and other items.

    When Linux is installed, you may have multiple drives and partitions in the system. Of course, partitions can be created during the install process. To access the whole file structure, you can start at root (/) and then go from there. For instance, in a Terminal you can change directory (cd) to root by typing “cd /” (without the quotes). Then, to move to the /dev directory you would type “cd dev”. Here, you can view a listing of the devices by typing “ls” for list.

    When installing Linux, you can specify where each folder is located on various partitions. You can also place them on the same partition. If the folders are on other partitions, these are Mount Points. For example, if Linux is placed on sda and the /usr/ folder is placed on sdb, then the user folder is a Mount Point for the /usr/ folder. The first disk, sda, is a Mount Point for the root (/).

    When viewing the folder structure, the structure is one unit no matter how many drives or partitions it covers. See Figure 1 for a Terminal listing of folders within the root.

    Figure 5.1.jpg
    FIGURE 1​

    NOTE: Unlike in a DOS/Windows system, you do not have to change drives to get to a folder within the directory structure. If we assume that the root is on sda and the /usr/ folder is on sdb, we can simply change directories from the root to /usr/ without having to specify the sdb drive.

    Attached Files:

    DevynCJohnson likes this.

Share This Page