showmount --exports nas.example.internal
Export list for nas.example.internal:
/mnt/tank/share (everyone)
There is a directory where the share will be mounted:
ls -lA /mnt/
total 0
drwxr-xr-x. 1 user user 10 Jul 21 09:55 nas
I am able to mount the share:
sudo mount nas.example.internal:/mnt/tank/share /mnt/nas/share
Created symlink /run/systemd/system/remote-fs.target.wants/rpc-statd.service → /usr/lib/systemd/system/rpc-statd.service.
but then there is no way I could unmount it (not even after restarting the laptop):
sudo umount /mnt/nas/share
The test1 directory is still there:
ls -lA /mnt/nas/share
total 0
drwxr-xr-x. 1 user user 0 Jul 21 10:06 test1
It even shows in “Gnome Files”, and I can add / edit / remove files, just like it was still mounted.
Re-issuing:
sudo umount /mnt/nas/share
returns:
umount: /mnt/nas/share: not mounted..
Am I missing something?
The final goal is to automount this share when the computer boots up, by using a systemd mount unit.
I made this scriptbin for my nixos. perhaps create a alias to point to this script everytime u want to un mount
#!/bin/bash
# Tolga Erok
echo -e "\033[34m" # Set text color to blue
echo "Unmounting all mount points"
echo -e "\033[1;37m"
# unmount a directory
unmount_directory() {
local dir="$1"
# see if the directory is already unmounted
if ! mountpoint -q "$dir"; then
echo "$dir is already unmounted"
return 0
fi
# Unmount mnt share's
sudo umount -f /mnt/*
sudo umount -l /mnt/*
# Unmount media share
sudo umount -f /media/*
sudo umount -l /media/*
# Unmount the directory
sudo umount -lf "$dir"
# Wait until the directory is unmounted
while mountpoint -q "$dir"; do
sleep 1
done
# Check if unmounting was successful
if mountpoint -q "$dir"; then
echo "Unmounting $dir failed"
return 1
fi
return 0
}
# Unmount all directories listed in /etc/fstab under /mnt
while IFS= read -r mount_point; do
if [[ "$mount_point" =~ /mnt/ ]]; then
unmount_directory "$mount_point"
fi
done < <(awk '$2 ~ /^\/mnt/ {print $2}' /etc/fstab)
# Unmount all directories listed in /etc/fstab under /media
while IFS= read -r mount_point; do
if [[ "$mount_point" =~ /media/ ]]; then
unmount_directory "$mount_point"
fi
done < <(awk '$2 ~ /^\/media/ {print $2}' /etc/fstab)
# Check if any unmounts failed
failed_unmounts=false
if [[ $(mount | grep -E '^/mnt/|^/media/' | wc -l) -ne 0 ]]; then
echo "Unable to unmount all filesystems under /mnt and /media"
failed_unmounts=true
fi
if ! $failed_unmounts; then
echo -e "\033[1;33m"
echo "Unmounting done."
fi
exit 0