2

In my /etc/fstab I have the line

UUID=c99...04c4  /media/myExtDrive  ext4    defaults,user,nobootwait  0   0

for my external hard drive. But when I plug it in and try to mount it with the DeviceNotifier of my KDE Plasma 5, I get the message that the device cannot be mounted. This was no problem in my Kubuntu 14.04 with KDE 4. When I delete the above line in /etc/fstab, the DeviceNotifier is able to mount the hard drive - however to /media/user/myExtDriveName instead to /media/myExtDrive as I wish. How do I need to configure the line in /etc/fstab so that it will be mounted automatically if present, but still allows me to use the DeviceNotifier to mount to /media/myExtDrive?


EDIT 1: I just tried to mount the external hdd with sudo mount --all with the line in fstab, but that did not allow me to mount either. Not quite sure why.


EDIT 2: In Kubuntu 14.04, the folder /media/myExtDrive had to be created. Now, I also created /media/myExtDrive. If I don't I get the error message, did get the message that it is missing. But somehow I am not quite sure anymore in which situation and have trouble reproducing this.


EDIT 3: When trying to mount with sudo mount -va I get

Incorrect filesystem type, invalid options, /dev/sdd1 superblock is damaged, encoding page missing or some other error.

However, I do not have any issues mounting to /media/user/myExtDriveName if I remove the above line in /etc/fstab and mount via DeviceNotifier.

Whether I have the folder /media/myExtDrive created beforehand or not seems not to make any difference either way.

The command tail -f /var/log/messages just returns that the file /var/log/messages cannot be found and thus can't be opened.

6
  • 3
    Does /media/myExtDrive exist? Edit your question and include the errors you're getting. – Panki Dec 16 '20 at 17:13
  • I'm not a KDE user, so all of this is probably wrong, but here are some thoughts... Regarding sudo mount --all, check dmesg for errors and mount output, it might already be mounted... it's possible that disconnecting the device physically doesn't automatically remove the mtab entry... Have you tried a reboot? – rfmodulator Dec 16 '20 at 17:14
  • @Panki: I updated the question. Did that help? – Make42 Dec 16 '20 at 17:39
  • @rfmodulator: I am pretty sure it is not mounted and I did reboot. – Make42 Dec 16 '20 at 17:40
  • Run 'tail -f /var/log/messages while mounting the drive and mount -va and add the output of both to your question. – Nasir Riley Dec 16 '20 at 18:06
1

I had some problems with Plasma and fstab too. I couldn't mount it automatically, so I created an script to run in startup.

There are multiple ways of achieving it, I'd suggest to create a system service, to make the script to run as root when the computer starts:

First: Go to the systemd scripts folder:

$ cd /etc/systemd/system

Second: Create a script file

$ sudo touch Automount.sh

Third: List the storage devices you have connected and identify your desired disk to mount.

$ sudo fdisk -l

The output will be generated as follows (just illustrative example):

#######################---------Example output-----------#####################

Disk /dev/sda: 931,51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: XXXXXXXXXXXXXXXXXXXXXXXX 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Device     Start        End    Sectors   Size Type
/dev/sda1     34      32767      32734    16M mydisktoo
/dev/sda2  32768 1953521663 1953488896 931,5G mydisk

#######################---------Example output-----------#####################

Fourth: Edit the script to mount the file

$ sudo nano Automount.service

Write this inside the file:

[Unit]
Description=Here you detail what you want to detail about the created service

[Service]
ExecStart=/etc/systemd/system/Automount.sh

[Install]
WantedBy=multi-user.target

Example of the interface of the nano text editor.

And save it pressing [Ctrl] + [X], and then [Y]

Fifth: Edit the mounting script

$ sudo nano Automount.sh

and paste your favorite mount configuration.

#!/bin/bash
sudo mount /dev/YOURDRIVEIDENTIFIER /media/MYEXTERNALDRIVE 

Fifth: Make the script executable for all users

$ sudo chmod 777 Automount.sh Autorun.service

Sixth Test your script by starting your new service

$ systemctl start Automount.service

Finally: Enable autorun at system startup

$ systemctl enable Automount.service

Hope it helps

4
  • Sounds good. What do I do when I plug the external hard drive in during work (so, after system startup) and how do I unmount? – Make42 Dec 16 '20 at 19:28
  • It is a wonderful question. Let me think, maybe using awk to get the /dev/XXX identifier and making the script more sophisticated... But in my computer I used to mount the devices with problems like this one manually using sudo mount /dev/XXX /My/FAV/PATH – Joshua Salazar Dec 16 '20 at 20:06
  • Then you can simply unmount it using sudo umount /dev/XXX, first making sure no process is using it. – Joshua Salazar Dec 16 '20 at 20:07
  • How is this different to using fstab? It seems like it is pretty much the same in the sense as both use mount. Is it "only" that yours works? Possibly because your script runs much later in the booting process? Did I get this right? – Make42 Dec 16 '20 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.