Automounting Data Drives Using FSTAB

Write tutorials for Linux Mint here
More tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Don't add support questions to tutorials please; start your own topic in the appropriate sub-forum instead. Before you post please read forum rules
Post Reply
User avatar
Lady Fitzgerald
Level 12
Level 12
Posts: 4395
Joined: Tue Jan 07, 2020 3:12 pm
Location: AZ, SSA (Squabbling States of America)

Automounting Data Drives Using FSTAB

Post by Lady Fitzgerald »

While there are GUI methods of setting up an internal drive to automatically mount, I found this one to be best (at least, it was for me) because it will allow the computer to boot even if a drive has died or has been removed.

1. Go to the File System (click on Home in Menu, then click on File system in left panel).

2. Right click on Media, then click on Open as Root.

3. Create a new folder named with the drive label.

4. Copy the UUID for the drivedrive from Disks and paste into a temporary Writer document or similar.

5. Open terminal and type:

sudo nano /etc/fstab

Then hit ENTER.

5. In new screen that pops up, start a new line after the last existing line and type:

UUID=(paste UUID here without parentheses)(TAB)/media/(folder name)(TAB)ext4(TAB)defaults, nofail(TAB)0(TAB)0

Where you see (TAB) above, that means to press the TAB key (don't type the parentheses). This is an example of how an entry will look:

UUID=123ec4fd-54e2-4590-8a4b-da43630efd72 /media/Data1 ext4 defaults,nofail 0 0

6. Press CTRL+o

7. Press ENTER to save.

8. Press CTRL+x to exit.

9. Restart the machine.

It is important that nofail is included in the FSTAB entry. Otherwise, if the drive dies or is removed, the computer will be unable to boot.
Jeannie

One has to be proactive, not reactive, so, to ensure the safety of one's data, backup your data!

Money can't buy happiness but it can buy a computer

Linux Mint Cinnamon 19.3 Cinnamon 64 bit - System 76 Serval WS (serw11) 17" Laptop
linux-rox
Level 9
Level 9
Posts: 2612
Joined: Sun Jul 19, 2020 9:17 pm

Re: Automounting Data Drives Using FSTAB

Post by linux-rox »

Three tips you may find useful.

1. IMHO, three spaces works better than a tab in fstab. What tabs do depends on where the text is on the line. Three spaces always do the same thing.

2. Kind of surprised to see you using nano. If you want GUI, try EDITOR='xed -w' sudoedit /etc/fstab. Will prompt for password.

3. If you like that, can make permanent with echo "export SUDO_EDITOR='xed -w'" | tee -a .bashrc && echo "alias edit='sudoedit'" | tee -a .bashrc (adds two lines to your .bashrc file). Now the command becomes simply edit /etc/fstab. Once enter password, file opens in xed, easy-peasy.
User avatar
Lady Fitzgerald
Level 12
Level 12
Posts: 4395
Joined: Tue Jan 07, 2020 3:12 pm
Location: AZ, SSA (Squabbling States of America)

Re: Automounting Data Drives Using FSTAB

Post by Lady Fitzgerald »

linux-rox wrote: Sat May 27, 2023 10:58 pm Three tips you may find useful.

1. IMHO, three spaces works better than a tab in fstab. What tabs do depends on where the text is on the line. Three spaces always do the same thing.

2. Kind of surprised to see you using nano. If you want GUI, try EDITOR='xed -w' sudoedit /etc/fstab. Will prompt for password.

3. If you like that, can make permanent with echo "export SUDO_EDITOR='xed -w'" | tee -a .bashrc && echo "alias edit='sudoedit'" | tee -a .bashrc (adds two lines to your .bashrc file). Now the command becomes simply edit /etc/fstab. Once enter password, file opens in xed, easy-peasy.
Thanks for the suggestions. After a lot of research, I found that the method I described worked best for me. There is a GUI way using Disks but I've found this to be more reliable in the long run.
Jeannie

One has to be proactive, not reactive, so, to ensure the safety of one's data, backup your data!

Money can't buy happiness but it can buy a computer

Linux Mint Cinnamon 19.3 Cinnamon 64 bit - System 76 Serval WS (serw11) 17" Laptop
linux-rox
Level 9
Level 9
Posts: 2612
Joined: Sun Jul 19, 2020 9:17 pm

Re: Automounting Data Drives Using FSTAB

Post by linux-rox »

Oh, I don't like the Disks method at all.

By the way, if anyone is interested, I notice on review that I neglected to mention one important detail for item #3. The edit to .bashrc doesn't take effect until the next time Terminal is opened. Or, can get it to take immediate effect with a further command: source .bashrc.
Post Reply

Return to “Tutorials”