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

Linux Bash Shell Command to Download and Install an App

# Set file path variable vagrantFile=https://releases.hashicorp.com/vagrant/2.2.14/vagrant_2.2.14_x86_64.deb # Download and install a Debian based file fileName="${vagrantFile##*/}"…

Ubuntu 20.04: Setting Static IP Address on an Interface

Short Version # Configure networking sudo vim /etc/netplan/*.yaml ### Sample content ### network: version: 2…

Linux: How to Display the SSL Certificate of a Remote Server URL

Command: server=test.kimconnect.comecho | openssl s_client -showcerts -servername $server -connect $server:443 2>/dev/null | openssl x509 -inform…