File system fundamentals in Linux | Part 2

File system fundamentals in Linux | Part 2

This article introduces some basic concepts related to file systems. Enjoy reading :)

Partitioning

Any disk has to be partitioned.. why?

  1. This enables us to have different file systems on each partition. We can specify the type of file system as needed. Sometimes we need to use read only file systems, enable data encryption, compression and much more features.
  2. Data isolation. Corruption can occur, so if we have only one partition on the disk and this partition is corrupted, the whole disk is now corrupted.

    In /var directory log files are generated, which means that this directory expands quickly. So it's recommended to have this directory in a separate partition to avoid affecting the system.

Partition types

  1. Primary partition: It can be bootable, which means we can install Operating systems in here.
  2. Logical partition: It Can't be bootable so we can put data on them. Ex: It's common in windows that C partition carries the os but other partitions like D carries data.
  3. Swap partition: System uses this type to extend physical memory, so you can't use it.

Best practices:

  • Set more than one swap partition so the system can use them in parallel besides the memory. This will make accessing data faster.
  • Make Swap partition size double size of RAM.

File systems mounting

Root file system

  • Root file system contains all necessary files needed to start the system
  • Its mounting point is "/"
  • Cannot be unmounted.. but wait! what mounting means??

Mounting

Mounting means associate device with a directory. As we said before that everything in Linux represented by a file. Devices and device drivers are also represented by files. So mounting means is to specify the path of the file that represents that device in the Linux file system hierarchy.

linux-filesystem.png

Use man page to see all options and arguments.

  • To make a disk partition:

man fdisk

  • To mount a device to specific path:

man mount