You are not logged in.

#1 2021-08-10 21:32:48

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

How to run fsck on attaching an external drive

I have different external backup drives all formatted with ext4. I'd like advise on how to run fsck everytime I plugin any of these drives. I use KDE which automatically mounts these drives on attach and so obviously fsck must be run before KDE mounts them. Wondering if a udev rule, a KDE tweak or a script would be best. Also advise on which fsck flag would be appropriate.

Offline

#2 2021-08-10 22:08:30

mpan
Member
Registered: 2012-08-01
Posts: 1,597
Website

Re: How to run fsck on attaching an external drive

Not a KDE user here, but I suspect what mounts the drives is udisks2. If yes, you may try setting the UDISKS_AUTO for the device to 0 in a udev rule, similar to how UDISKS_IGNORE is set in this example. That should make it not attempt an automount. Then you can start fsck, also from a udev rule with RUN key. Just be aware that, whatever is executed in an udev rule, should end quickly. Therefore you may consider for example a script that starts it asynchronously.


Paperclips in avatars? | Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#3 2021-08-11 05:39:52

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,687

Re: How to run fsck on attaching an external drive

Thanks mpan. I'll look into this and thanks for pointing me to udisks2 which I haven't taken into consideration.

Offline

Board footer

Powered by FluxBB