← Back to Dashboard

Adding a Disk to /etc/fstab Using blkid in Vim

Mounting disks via UUID is the most reliable method for Linux. This guide demonstrates how to pull disk information directly into /etc/fstab using Vim to minimize typing errors.

1. Open the File

sudo vim /etc/fstab

2. Import Disk Information (The Vim Trick)

Instead of switching terminals, pull the blkid data directly into your current buffer:

:r !blkid /dev/sdb

Example output inserted into text:
/dev/sdb: UUID="a1b2c3d4-e5f6-7890-abcd-1234567890ef" TYPE="ext4" ...

3. Format the Entry

An fstab entry must follow this specific 6-field structure:

Field Description Example
UUID Unique ID (Remove quotes and prefix) UUID=a1b2c3d4...
Mount Point Target directory /data
Type Filesystem type ext4
Options Mount parameters defaults
Dump Backup trigger 0
Pass Filesystem check order 2

Final Formatted Example:

UUID=a1b2c3d4-e5f6-7890-abcd-1234567890ef  /data  ext4  defaults  0  2

4. Save and Exit

Press Esc, then type :wq to save changes.

5. Critical Safety Check

Never reboot without testing. An error in fstab can cause a boot failure (Emergency Mode).

sudo mount -a

Interpreting Results: