While working with disks and operating systems after a certain level, there are several terms that we come across that we vaguely know about, and to many of us, they are not clearly understood. Well, in this article, we aim to cover everything about the Linux File Systems and those different terms related to it to leave no gaps.
Firmware is a specific low-level software that directly interacts with the hardware of the machine. It is generally designed and put in by the manufacturers themselves and is stored using non-volatile memory storage methods, such as ROM, flash memory, etc. Some firmware that we should know of is BIOS and UEFI.
BIOS stands for “Basic Input/Output System.” BIOS is the first software component that is executed when powering on a machine. It is the job of BIOS to test and initialize the hardware components and begin certain integral services for operating systems and software. What BIOS can be seen visually doing is that after the hardware and software initialization part, it loads a boot loader (in the case of most Linux based distributions, that is, GNU GRUB). Then it boots the operating system (or prompts a choice, in case of multiple booting).
One important thing to know about BIOS is that it is designed and flashed by the manufacturing company directly on to the motherboard of the system. Modern BIOS also has a setup utility, which provides many configurations and security options such as:
- Setting hardware time/date
- Configuring hardware components (like overclocking CPU, enabling/disabling ports or drives, changing operation modes for the hardware components that have such an option)
- Modifying the boot devices sequence
- Setting up passwords for entering BIOS or even simply booting the system at all
Damaging the BIOS usually results in a bricked device. Certain companies/models provide recovery methods, such as a recovery USB stick, jumper pins, etc. Recently, users have been trying to replace the stock BIOS with open-source firmware. One of such projects is coreboot. Coreboot supports specific ThinkPads (famously the X220) and is being adopted by Linux hardware companies such as System76, Purism, etc. Here‘s their own page about their users.
UEFI stands for “Unified Extensible Firmware Interface.” I know it sounds fancy, but what it means, is that it adds specific functionality to the already existing BIOS. Around the time of its inception, there were certain limitations around BIOS, which were fixed by UEFI. Some of the notable advantages are:
- The UEFI can be highly tweaked and configured to provide users with an intense level of configuration, that too, with a beautiful and an easier to navigate GUI.
- Ability to use large disk partitions (over 2TB) with GPT partitions
- CPU-independent architectures and drivers.
Naturally, it comes with some disadvantages as well. A more sophisticated booting sequence means slower boot times. Moreover, not all systems (and users, for that matter) require extra modules, and not many mainline OSes can take advantage of all the particular hardware improvements.
Booting from BIOS/UEFI
Now that we have it clear what BIOS and UEFI are, what is the difference between booting from either of them?
BIOS follows what is called the MBR to determine the software execution sequence while booting. MBR is the “Master Boot Record,” which is a unique boot sector situated at the beginning of the disk. MBR holds the information about how the partitions are structured on the disk. MBR also has the boot loader for the system.
In the case of UEFI, it requires the installed operating systems to provide certain rootkits that are digitally signed, which goes against the open-source spirit (this was a result of the involvement of large proprietaries oriented companies such as Intel and Microsoft). This was designed so that malicious rootkits can be avoided in the booting sequence itself. It can be overcome by using legacy/secure boot options.
A bootloader is a software that organizes the boot options available on the drive that you are using. It provides the choice among all the different OSes installed on the drive. The most popular one in the Linux world is GNU GRUB, and we are going to talk about that.
GNU GRUB is short for GNU GRand Unified Bootloader. If you have been working around Linux for some time, there is a high chance that you have already seen GRUB at least once. It is the menu that your system shows before booting that provides you the options of the various operating systems (or modes or operating systems) that you can boot into.
The look of the GRUB differs depending on the OS that you are using. It can be customized by the users themselves to add a custom wallpaper to their boot menu.
Partition and Partition Table
A partition is a part of the total storage space of the drive that has a specific size. Several such partitions make up the whole storage device (or just space, even). A partition table, on the other hand, describes the partitions on that storage device. Although that doesn’t sound very important, it does get significant because the type of partition table that you use puts certain limits on the formatting of the storage.
For example, if you use the MBR partition table format, you will find that you cannot create more than four primary partitions. On the other hand, you can make up to 128 partitions when using the GPT partition table.
The task of partitioning refers to creating and structuring partitions on a storage device. Whenever going through a fresh install, or even if installing another OS to your drive, it is always recommended to structure partitions in a clean and optimized way. While partitioning for a new install, keep in mind that most Linux based distributions require four major partitions:
- / (Root)
- /home (Home)
- Swap Partition (In-depth discussion later)
- EFI Boot Partition
Depending on your hardware and the OS in question, the EFI boot partition may instead be a BIOS GRUB partition. You will know when the operating system asks for it. But wait, these are four partitions already. What if I use MBR and need more partitions for something later on? There is a solution for that as well.
There is something called an extended partition. When you create an extended partition, you can divide it into as many logical partitions as you like. The limit of 4 partitions is for what are called primary partitions.
LVMs or Logical Volume Managers provide a way of formatting the partitions in a better way than traditional software offers. One clear benefit is that it combines several disks into a single large virtual partition.
We just talked about partitions, yes? Well, those partitions, too, are always of a specific format. For example, the most typical partition type that is used among Linux based systems as of now is EXT4 partitions. If you talk about Windows, the most common partition formats used are FAT and NTFS. The point being, there are several file system formats available.
What is the difference between file systems? A file system determines how data is stored and how it will be processed when asked for. A file system determines how a file will be stored by dividing the said file into pieces with each piece, knowing where the next one is located. Since it plays such an important role, several file systems have different structures, speed, security, flexibility, etc.
When you explore different file systems, you will find that some are marked as ‘journaling’ while others are not. This is an important property that you will require when you are making an installation. Journaling file systems are designed to prevent data corruption/loss whenever there is a sudden power cut.
Different Linux FSs
Ext2, Ext3, and Ext4
Ext is the first file system created specifically for the Linux kernel. It is short for the Extended File System, with its first version released in 1992 (The first version of Linux was released in 1991). Although it was initially designed also to overcome specific problems in the MINIX FS, it has since become the most commonly used FS when it comes to Linux. If you are not sure which one to choose, go for Ext4 for the best balance.
B-Tree File System was created to add more functionality to the already existing FSs. It was designed to address the lack of multi-device spanning, checksums, snapshots, etc. It is also supposed to focus on fault tolerance, repair, and easy administration.
You might have recently heard about this particular FS, as Ubuntu focused on it in its recent 20.04 release. Sun Microsystems initially developed it. ZFS is scalable, has added features for protection from data corruption, support for high storage capacities, data compression, etc. It is clear why Ubuntu focused on this FS. The main attraction, however, was spanning a single partition over multiple drives.
Swap is a rather essential and unique part of Linux systems. Whenever you make a fresh install, you will be asked to allocate space for a swap partition. The idea is simple and quite beautiful.
Linux kernel divides RAM into what is called ‘pages.’ If an application takes up a lot of RAM, you can say that it covers up several pages of the RAM. The swap space determined at the time of installation acts as RAM when required. What happens is that if the system runs out of physical RAM while being used, it shifts some of the lesser-used processes over to the swap space on the disk. While it does have an advantage that the desired programs will run pretty well, it also has a disadvantage because disks are much slower as compared to RAM.
How much area you wish to dedicate to swap is totally up to you, but it is recommended that you provide at least 20% of your RAM size as swap. Many distributions even recommend twice the size of RAM. But if you have a large RAM, chances are, you will never actually run out of it, meaning you will never even require the swap space.
FAT is an ancient file system. It was initially developed for floppy disks, but later on, it became widely used on Windows-based systems, and it is still quite popular when it comes to flash drives (FAT32).
NTFS was developed after the traditional FAT with certain technical advancements like improved support for metadata and improved performance, reliability, and disk space usage.
To ensure the safety of your data, it is recommended to use encryption. Several mainstream Linux distributions offer encryption of the home directory, which is a fantastic option. When it comes to full-disk encryption, the key of the encryption is stored on the boot partition so that it will decrypt the system while booting.
Several programs are provided on Linux for disk encryption, most commonly being used is perhaps the LUKS encryption. The guide to using it will be different for all distributions.
In this day and age, digital data theft is a real issue. Disk encryption minimizes that risk to a high level, at least on a physical basis. Cyber safety is in the hands of the users to the full extent.
We tried to cover the most common terminology used in the context of file systems. Some of these things are important to understanding, as they can help you optimize your system. We hope this was helpful to you. Cheers!