Regular personal computer or laptop uses one hard-disk storage. Desktop users do not have to worry about disk optimization or performance. The operating system does all it can to keep your disk optimized automatically. For advanced users understanding storage space is important. In this article you will learn the most important concepts about the file system.

Disk Partition

We can divide one disk into multiple regions named partitions. Each partition can be used to have one file system. One operating system can be installed on one or more partitions and can use one or several hard-disks. One hard-disk must be initialized using a partition table before it can be partitioned.

We have two ways to organizing disk partitions.

  1. Legacy DOS or MBR (Master Boot Record)
  2. New GPT (GUID Partition Table)

Master boot record (MBR) disks use the standard BIOS partition table. We can have minimum one and maximum 4 primary partitions. We can use maximum 3 primary partitions and one extended partition.

One primary partition can be used for operating system boot. This partition is the active partition. The extended partition can be split into up to 60 logical partitions. We install operating system on primary partition.

GUID partition table (GPT) disks use unified extensible firmware interface (UEFI). One advantage of GPT disks is that you can have more than four partitions on each disk. GPT is also required for disks larger than 2 terabytes.

Windows File System

A file system is a local database managed by the operating system to organize data into one partition. Each partition can have a different kind of file system that can have more or less features (options) and different performance parameters.

On Windows, there is only one option to use for the file system and this is NTFS. In the past (on Ms-dos), we have used FAT16 and FAT32 file systems. These can be still used today for UEFI partitions or flash memory cards.

To install Windows in UEFI mode you have to boot your PC in UEFI mode from a DVD-ROM then you can start installing Windows. It will format your disk as GPT and will create automatic the UEFI partition and NTFS partition for you.

Some new motherboards have UEFI activated as default option. Some other have Legacy BIOS mode active by default. You can use F2 or DEL or some other key to enter BIOS and change the default option to UEFI for DVD and UEFI for HDD, then you can re-start the computer and boot from DVD in UEFI mode.

Windows folders:

On windows after we install the operating system we have several standard folders that are usually located on primary hard-disk that is identified by letter C. This has nothing to do with C computer language. Letter A and B are reserved for external diskette or “floppy disk” that is missing from modern computers and was not reused for other purposes. The diskette is an obsolete device.

C:\
|-- inetpub
|-- Program Files
|-- Program Files (x86)
|-- ProgramData
|-- Users
|-- Windows
|-- <user_folders>

Disk C:\

  • represents the root of the operating system
  • note A:\ B:\ use to be FloppyDisks and are no longer used
  • some computers can have a secondary disk D:\ for backup.

1. inetpub:

  • is present if you install IIS service and has Internet web pages

2. Program Files:

  • contain all apps and programs user can install on 32 bit for Windows 32 bit edition and 64 bit for Windows 64 bit edition.

3. Program Files (x86)

  • has legacy programs or programs on 32 bit for Windows on 64 bit edition. This folder does not exist on windows on 32 bit edition.

4. ProgramData

  • contains data stored by programs

5. Users

  • contains user profile including Documents, Video, Pictures …

6. Windows

  • contain the operating system files

Moving content on disk D:

If you have a secondary disk you can move some of the content on disk D: but not very easy. It takes time and effort to do so.To use disk D: you create your own folders and you save what you wish into these folders. The Windows System folders are almost impossible to move.

You can move the content of each folder: Documents, Downloads, Video, Pictures, Music on different locations using Windows properties for each folder. On Windows 10 there is a small improvement but the main folders can’t be moved yet.

There are articles on Internet to teach you how to move the \user folder or some of its content on the D: disk. I do not recommend to use this technique you may have issues when you upgrade or refresh your OS.

Due to these issues we recommend to use a large disk C: when you install Windows operating system. Using a small SSD for the operating system and a secondary disk D: is not practical. If you have 2 disks use the second disk for backups.

Windows RAID:

If you have multiple disks you may create a RAID array to improve performance or reliability of your secondary disks. For example, if you are a passionate gamer you may use 2,3 or 4 disks to create RAID disk D: for games. This will improve load and save performance and data safety.

To learn more about RAID Array read this article: Redundant Storage Array

Windows Professional allows you to create software RAID-1 (mirror) but Windows Home allows only RAID-0 (striped). When you use RAID-1 you have to set-up the disk in IDE compatibility mode or have very good SATA disks (Enterprise Class). Some WD disks (Green Edition, Red Edition) have issues when used in RAID1. Do not use these disks in RAID.

Some motherboards provide a Bios feature to create RAID. This is not necessarily faster than software RAID but can be used with any Windows edition and sometimes is the only choice to use advantages of multiple disks.

Linux File System

On Linux, there is a totally different story. You have multiple options to select a file system or to use a combination of file systems using multiple partitions. To understand the optimization you can do you have to be fully aware of all options and structure of the UNIX or Linux folders and content purpose.

On Linux disks are not identified using a single letter like in Windows A: B: C: D: Instead the disks are identified using several letters starting with (hd): hda, hdb, hdc or (sd): sda, sdb, sdc … These are “mounted” to folders and not visible in operating system as disks but as folders into a single tree that start from the root. The root is “\” and is an abstract concept that can be mapped directly to a primary disk partition.

Linux operating system can use several File Systems for different folders optimized for different purposes. The following File Systems are available and most popular: EXT3, EXT4, XFS, BtrFS, ZFS.

Linux folders:

Linux file system has more predefined folders than Windows. Here is the list of folders you can have after you install Linux. You must be familiar with these folders to properly use Linux or Unix OS.

/
|---bin
|---sbin
|---etc
|---dev
|---proc
|---var
|---tmp
|---usr
|---home
|---boot
|---lib
|---opt
|---mnt
|---media
|---srv

1. /  – The root of the tree

  • Every single file and directory starts from the root directory.
  • Only root user has written privilege under this directory.
  • Please note that /root is root user’s home directory, which is not same as /.

2. /bin – User Binaries

  • Contains binary executable.
  • Common Linux commands you need to use in single-user modes are located under this directory.
  • Commands used by all the users of the system are located here.
  • For example: ps, ls, ping, grep, cp.

3. /sbin – System Binaries

  • Just like /bin, /sbin also contains binary executable.
  • But, the linux commands located under this directory are used typically by system administrator, for system maintenance purpose.
  • For example: iptables, reboot, fdisk, ifconfig, swapon

4. /etc – Configuration Files

  • Contains configuration files required by all programs.
  • This also has startup and shutdown shell scripts used to start/stop each program.
  • For example: /etc/resolv.conf, /etc/logrotate.conf

5. /dev – Device Files

  • Contains device files.
  • These include terminal devices, usb, or any device attached to the system.
  • For example: /dev/tty1, /dev/usbmon0

6. /proc – Process Information

  • Contains information about system process.
  • This is a pseudo filesystem contains information about running process. For example: /proc/{pid} directory has information about the process with that particular pid.
  • This is a virtual filesystem with text information about system resources. For example: /proc/uptime

7. /var – Variable Files

  • var stands for variable files.
  • Content of the files that are expected to grow can be found under this directory.
  • This includes — system log files (/var/log); packages and database files (/var/lib); emails (/var/mail); print queues (/var/spool); lock files (/var/lock); temp files needed across reboots (/var/tmp);

8. /tmp – Temporary Files

  • Directory that has temporary files created by system and users.
  • Files under this directory are deleted when system is rebooted.

9. /usr – User Programs

  • Contains binaries, libraries, documentation, and source-code for second level programs.
  • /usr/bin contains binary files for user programs. If you can’t find a user binary under /bin, look under /usr/bin. For example: at, awk, cc, less, scp
  • /usr/sbin contains binary files for system administrators. If you can’t find a system binary under /sbin, look under /usr/sbin. For example: atd, cron, sshd, useradd, userdel
  • /usr/lib contains libraries for /usr/bin and /usr/sbin
  • /usr/local has users programs that you install from source. For example, when you install apache from source, it goes under /usr/local/apache2

10. /home – Home Directories

  • Home directories for all users to store their personal files.
  • For example: /home/john, /home/nikita

11. /boot – Boot Loader Files

  • Contains boot loader related files.
  • Kernel initrd, vmlinux, grub files are located under /boot
  • For example: initrd.img-2.6.32-24-generic, vmlinuz-2.6.32-24-generic

12. /lib – System Libraries

  • Contains library files that supports the binaries located under /bin and /sbin
  • Library file names are either ld* or lib*.so.*
  • For example: ld-2.11.1.so, libncurses.so.5.7

13. /opt – Optional add-on Applications

  • opt stands for optional.
  • Contains add-on applications from each vendor.
  • add-on applications should be installed under either /opt/ or /opt/ sub-directory.

14. /mnt – Mount Directory

  • Temporary mount directory where sysadmins can mount file systems.

15. /media – Removable Media Devices

  • Temporary mount directory for removable devices.
  • For examples, /media/cdrom for CD-ROM; /media/floppy for floppy drives; /media/cdrecorder for CD writer

16. /srv – Service Data

  • srv stands for service.
  • Contains server specific services related data.
  • For example, /srv/cvs contains CVS related data.

Linux RAID

To create RAID you can have a hardware RAID card inside your computer. You can have one or more RAID channels on a single card or you can have multiple cards. New PC cards can emulate RAID channel. You have to select in BIOS the mode RAID or AHCI for your storage. Once you select RAID in BIOS you reboot and you can enter the RAID setup usink a shortcut key.

On Linux you can create software RAID if you do not have hardware RAID. You can use one of these methods:

  1. MD RAID
  2. LVM RAID
  3. BtrFS RAID

The oldest method MD RAID is the most established and feature complete method. LVM RAID and BTRFS RAID are new and not very well established so you will find not so many Linux professionals are using it.

I’m not very fun of command line but these systems are designed to be used from command line. So I have searched for a Linux distribution that allows me to install on RAID easy in visual mode and I found Open Suse does this.

I have done multiple experiments to install Linux on RAID combination and I will write my next article about the experience I have learned doing so. For now is good to know that every folder of Linux can be installed on a different RAID so you can have multiple RAID Channels in your system to optimize the future content for performance and reliability.

Multiple RAID Channels

The most important folders can be installed on different channels. The root folder \ can be installed on RAID but the \boot folder is problematic to install on RAID disk.

The most simple install for Linux with RAID is to use a small /boot disk (1 GB) on a boot card then install the root “/” into RAID. This is the most simple and easy to create.

More advanced Linux installations usually have a single small and fast disk for the root to install the operating system and will use RAID array to map some of the following folders:

  • \home
  • \var
  • \srv
  • \opt
  • \tmp

This is depending on the server purpose. If you have a multi-user server then probably \home folder is very important and will be stored on RAID1, RAID6 or RAID10 array.

For an Internet server, the \srv folder and \var folder will contain Internet pages and data. So probably \srv will be stored on RAID6 and \var will be stored on RAID10.

For an Oracle database server, \opt can be installed on RAID10. We know that RAID5 and RAID6 are no good for a database performance. Therefore a single disk is better than RAID. However, do not forget Oracle can use the disks in its own way so you do not have to use RAID Array at all to optimize Oracle storage.

Using SSD

This is a fast disk (solid state disk) that can be used to install operating system to have faster load time when the computer starts. This kind of disk was initially designed for laptops to consume less power then the normal disks. However desktop computers can use a mechanical adapter to install the small SSD instead of normal HDD.

On Linux the file BtrFS and ZFS are aware of SSD and can take advantage of it’s fantastic sequential speed and reduced access time. Older SSD used to have some issues reading and writing data very frequent. Therefore journal based file systems are not recommended for these disks (EXT4, XFS, JFS).

SSD is not recommended for temporary folders. It is best to map /tmp folder on a normal HDD. Also folder /var contains temporary files and databases. Do not use SSD for this folder. It is best to use RAID to store this folder on it.