Prerequisites
-
Root or
sudoprivileges. -
The device name of your disk (e.g.,
/dev/sdb). -
A created mount point (e.g.,
/mnt/data).
Step 1: Open the File
Open the filesystem table configuration with vim:
Bash
sudo vim /etc/fstab
Step 2: Import Disk Information
Instead of switching terminals, you can pull the blkid data directly into your current buffer.
-
Ensure you are in NORMAL mode (press
Esc). -
Move the cursor to the bottom of the file.
-
Type the following command and press
Enter:Vim Script
:r !blkid /dev/sdbSubstitute
/dev/sdbwith your actual device name.
Example of the inserted raw text:
/dev/sdb: UUID="a1b2c3d4-e5f6-7890-abcd-1234567890ef" TYPE="ext4" PARTUUID="..."
Step 3: Format the Entry
The raw output needs to be cleaned up to match the fstab syntax. An fstab entry follows this specific structure:
Field | Description |
|---|---|
UUID | The unique ID (Remove quotes and the |
Mount Point | The directory where the disk will live (e.g., |
Type | The filesystem type (e.g., |
Options | Usually |
Dump | Set to |
Pass | Set to |
Final Formatted Example:
UUID=a1b2c3d4-e5f6-7890-abcd-1234567890ef /data ext4 defaults 0 2
Step 4: Save and Exit
Once the line is cleaned up and the unnecessary PARTUUID or device tags are deleted:
-
Press
Esc. -
Type
:wqand pressEnter.
Step 5: Critical Safety Check
Never reboot without testing your fstab file. An error in this file can prevent your system from booting.
Run the following command:
Bash
sudo mount -a
Interpreting Results:
-
No Output: Success! Your disk is mounted and the configuration is valid.
-
Error Message: Do not reboot. Re-open
/etc/fstaband check for typos, missing spaces, or incorrect UUIDs.