LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-23-2023, 07:28 AM   #1
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Rep: Reputation: 25
Safely remove external encrypted disk via file manager (xfce)?


Hey, a bit of a long shot here.

I have an external usb disk that is fully encrypted by Veracrypt. I would like this disk to decrypt and mount when plugged in. Yes, I already know how to do this by using a udev rule to trigger a systemd service that calls cryptsetup to unlock the drive once plugged in (and unmount/lock it back once the service exits). But this approach requires me to manually stop the service via root shell to trigger unmounting and closing of the dm-crypt device before I can safely remove the disk. Is there an easier way to perform this action via the desktop or file manager?

For example, Thunar file manager normally shows a list of external devices that, when right-clicked, offer an option to "unmount" or "eject" the device. Is there a way to have my disk added to this list, so that whenever "eject" is selected it will run some custom command in background? It would be sufficient to have the systemd services stopped, as they will perform the necessary cleanup.

Ideas? I'm using Xubuntu 22.04.
 
Old 02-23-2023, 03:12 PM   #2
Brains
Senior Member
 
Registered: Apr 2009
Distribution: All OS except Apple
Posts: 1,591

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
Quote:
Originally Posted by displace View Post
But this approach requires me to manually stop the service via root shell to trigger unmounting and closing of the dm-crypt device before I can safely remove the disk.
I typically have a ~/Documents/Scripts directory. Sometimes I upgrade multiple installed Operating Systems from one on a multi-boot by clicking on the menu item.

I create a "updater.desktop" and put it in ~/.local/share/applications. For KDE it kicks off a up.sh script that launches Konsole asking for root password, then executes the updater.sh script after the password. up.sh:
Code:
#!/bin/sh
konsole -e su root /home/ME/Documents/Scripts/updater.sh
The updater mounts other OS partitions, chroot in and apply updates, unmount etc. All by clicking on a menu item with a snazzy icon of my choosing.

EDIT: I usually browse the /usr/share/applications directory to find an existing .desktop that suits my needs, make a copy and edit it's name, point to my script, change the icon etc,

Last edited by Brains; 02-23-2023 at 03:26 PM.
 
Old 02-24-2023, 03:41 AM   #3
displace
Member
 
Registered: Jan 2013
Location: EU
Distribution: Debian
Posts: 268

Original Poster
Rep: Reputation: 25
Yeah, using shortcuts could work, but my question was more in the integration direction.
What program does xfce use to handle mounts in the /media folder?
And can custom devices from /dev/mapper/ be added to the list in some way?
The system seems to detect external usb block devices, but not the device mapper devices.
 
Old 02-24-2023, 09:39 AM   #4
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,660

Rep: Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584
Quote:
Originally Posted by displace View Post
What program does xfce use to handle mounts in the /media folder?
And can custom devices from /dev/mapper/ be added to the list in some way?
Those seem like the sort of questions you might do better with asking on Xfce forums.

(If you do, please come back and update this thread.)

 
  


Reply

Tags
cryptsetup, systemd, udev, veracrypt, xfce



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot safely remove USB memory and USB DISK kujirasan Linux - Hardware 4 09-26-2011 06:39 PM
Safely Remove USB External Hard Drive Toods Slackware 12 02-10-2009 02:57 AM
safely remove external hard-drive vashsna Linux - Hardware 4 11-16-2008 04:01 PM
How safely encrypted are my files? make Linux - Security 4 11-04-2006 05:02 AM
can you apply 2.6.x kernel config to 2.4.x safely/somewhat safely? silex_88 Linux - Software 3 12-09-2005 11:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration