0Pricing
Linux Server Deployment & SSH Mastery · Lesson

Mounting File Systems

Understand how to mount file systems manually and configure automatic mounting at boot using `/etc/fstab`.

Mounting File Systems is a free Linux Server Deployment & SSH Mastery lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Server Deployment & SSH Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Making Storage Accessible

Imagine you have a new hard drive, USB stick, or a network share. For your Linux server to use it, you need to mount its file system.

Mounting is like telling your server: "Hey, this storage device contains files, and I want to access them through this specific directory." Until mounted, the storage device is just raw hardware.

The `mount` Command Basics

The primary command to attach a file system to your server's directory tree is mount. It connects a specific device (like a partition) to a designated directory, called a mount point.

The basic syntax is:

  • mount [device] [mount_point]

You'll often need sudo for this command as it involves system-level changes.

Mounting a Device Manually

Let's say you have a new partition at /dev/sdb1 and you want to access its contents in a folder called /mnt/new_drive. First, ensure the mount point directory exists!

Try running this example. It simulates mounting and then listing its content.

sudo mkdir -p /mnt/new_drive
sudo mount /dev/sdb1 /mnt/new_drive
ls /mnt/new_drive
# Output would show contents if /dev/sdb1 existed and had files

Understanding Mount Points

A mount point is simply an empty directory on your existing file system where the contents of another file system will become accessible.

  • Common mount points are in /mnt (for temporary mounts) or /media (for removable media).
  • You must create the mount point directory before you can mount anything to it.
  • If the directory isn't empty, its existing contents will be hidden until the file system is unmounted.

Detaching with `umount`

Just as you mount a file system, you must also unmount it before physically disconnecting the device or if you no longer need it. This ensures all pending write operations are completed and data isn't corrupted.

The command for this is umount (note: no 'n' after 'u'!). You can unmount by specifying either the device or the mount point.

  • umount [device]
  • umount [mount_point]

`umount` in Action

If you try to unmount a file system that is currently in use (e.g., a user has opened a file or is in that directory), you'll get a "device is busy" error. You might need to close applications or navigate out of the directory.

Let's unmount our previous example. After unmounting, the mount point directory will appear empty again.

sudo umount /mnt/new_drive
ls /mnt/new_drive
# Output: (empty directory, or original contents if not empty before mount)

Persistent Mounts with `/etc/fstab`

Manually mounting devices is fine for temporary use, but what if you want a file system to be mounted automatically every time your server boots up?

That's where the /etc/fstab file comes in. It's a system configuration file that lists all the disks and partitions that should be mounted automatically at boot time, and how they should be mounted.

Anatomy of an `fstab` Entry

Each line in /etc/fstab represents a file system to be mounted and has six fields, separated by spaces or tabs:

  • 1. Device: The partition or device to mount (e.g., /dev/sdb1 or UUID=...).
  • 2. Mount Point: The directory where the device will be mounted (e.g., /data).
  • 3. File System Type: The type of file system (e.g., ext4, xfs, ntfs).
  • 4. Options: Mount options (e.g., defaults, noauto, ro).
  • 5. Dump: Used by the dump utility (0 to disable).
  • 6. Pass: Controls file system check order at boot (0 to disable, 1 for root, 2 for others).

Example `/etc/fstab` Entry

Using UUIDs (Universally Unique Identifiers) instead of device names (like /dev/sdb1) is highly recommended in /etc/fstab. UUIDs are unique and persistent, unlike device names which can change after a reboot or adding new hardware.

Here's an example entry for a data partition:

# /etc/fstab entry example
UUID=a1b2c3d4-e5f6-7890-1234-567890abcdef  /data  ext4  defaults,nofail  0  2

Mounting Knowledge Check

Which of the following statements about mounting file systems in Linux are TRUE?

Recap: File System Mounting

In this lesson, you learned the essentials of mounting file systems on Linux. We covered:

  • Using the mount command to make storage devices accessible.
  • The importance of mount points and how to create them.
  • Safely detaching file systems with the umount command.
  • Configuring automatic, persistent mounts using the /etc/fstab file.
  • Understanding the structure and fields of an /etc/fstab entry, including the use of UUIDs.

Mastering these concepts is crucial for managing storage on your Linux server!

Frequently asked questions

Is the “Mounting File Systems” lesson free?

Yes — the full text of “Mounting File Systems” is free to read here on the web, and the Linux Server Deployment & SSH Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Server Deployment & SSH Mastery course, upgrade to CoddyKit PRO.

What will I learn in “Mounting File Systems”?

Understand how to mount file systems manually and configure automatic mounting at boot using `/etc/fstab`. You practise Linux Server Deployment & SSH Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Server Deployment & SSH Mastery?

No prior experience is required. Linux Server Deployment & SSH Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Mounting File Systems” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Server Deployment & SSH Mastery lesson?

Yes. Every Linux Server Deployment & SSH Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Disk Partitioning and Formatting
  2. Mounting File Systems
  3. Monitoring Disk Usage
  4. Logical Volume Management (LVM)
← Back to Linux Server Deployment & SSH Mastery