Normally we use one disk storage for a personal computer. Average users do not have to worry about disk optimization or performance. The operating system does all it can to keep your disk optimized.

More advanced users understanding of storage space is important. Therefore in this article I will cover the most important concepts tips and tricks about the file system.

Disk Partition

We can divide one disk into multiple regions using partitions. Thi can be used to have multiple file systems on a single storage disks. One operating system can be installed on one or more partitions and can use one or more disks. We have two ways to organize 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

On Windows OS, there is only one option to use for the file system and this is NTFS. In the past, we also use to have FAT16 and FAT32 file systems. These can be used today for UEFI partition.

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:

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.

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 for C:\ when you install Windows operating system. Using a small SSD for the operating system and a secondary D:\ disk is not practical. If you have 2 disks use the second disk for backup.

Windows RAID:

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

To learn more about RAID Arry pease read this article: http://sagecode.net/redundant-storage-array/

Windows Professional edition allows you to create software RAID1 or mirror disk but Home edition allows only RAID0. When you use RAID1 you have to set-up the disk in IDE compatibility mode or have very good SATA disk (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.

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 if you use 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 multiple disks do not having a letter like in Windows A: B: or C: instead the disks are identified using several letters: hda, hdb, hdc or 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 disk or not.

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.

Linux folders:

/
|---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.

My favorite file systems and most reliable are EXT4 and XFS. I use EXT3 for /boot for {root, /boot, /tmp } EXT4, and for { /srv, /home, /var, /opt } use XFS.

I do not use BTRFS due to memory requirement. My disks are small and do not need BTRFS. This File System is used on Enterprise class servers.

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.