Posted On March 11, 2023

Linux: how to make automounts persistent

kimconnect 0 comments
blog.KimConnect.com >> Linux >> Linux: how to make automounts persistent
# Step 1: discover the device using its current mount path

mountPath=/media/kim/Data
findmnt | grep $mountPath

$ findmnt | grep $mountPath
├─/media/kim/Data                             /dev/sdb1                                        fuseblk                              rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096

# Step 2: show partition file system type

fsck -N /dev/sdb1

$ fsck -N /dev/sdb1
fsck from util-linux 2.37.2
[/usr/sbin/fsck.ext2 (1) -- /dev/sdb1] fsck.ext2 /dev/sdb1 

# Step 3: Mount the new partition if required
mountPath=/media/kim/Data
partition=/dev/sdb1
sudo mkdir -p $mountPath # create new mount point if it doesn't exist
sudo mount $partition $mountPath # mounting partition toward new target mount point

$ sudo mount $partition $mountPath
Mount is denied because the NTFS volume is already exclusively opened.
The volume may be already mounted, or another software may use it which
could be identified for example by the help of the 'fuser' command.

# Step 4: find disk UUID

partition=sdb1
ls -l /dev/disk/by-uuid/ | grep $partition

$ ls -l /dev/disk/by-uuid/ | grep $partition
lrwxrwxrwx 1 root root 10 Mar 11 11:58 7806E98D06E94D26 -> ../../sdb1

# Step 5: Add this line to /etc/fstab (assuming disk has been formatted as NTFS)
UUID=7806E98D06E94D26 /media/kim/Data ntfs-3g rw 0 0
 
# Reload mounts or reboot
sudo mount -a # or sudo reboot

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Unix / Linux File Permissions Cheat Sheet

General Permissions Overview: Permissions (base) 1 – execute2 – write4 – read Permissions (octal) 3…

Redhat 7.5 Installation

Standard Default Installation Instructions At the initial loading screen, press the UP arrow to select…

Linux: How to Use Tar and Gunzip

Tar is an archival system. It helps bundling many directories and files into a single…