LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-24-2006, 08:19 PM   #1
carcassonne
Member
 
Registered: Jul 2005
Distribution: Fedora6 x86_64
Posts: 118

Rep: Reputation: 15
dm-crypt, USB and umount/mount


Folks,

I've been using dm-crypt in such a way with USB keys and it works fine:

[insert USB key]
cryptosetup create /dev/mapper/sda1 /dev/sda1
mount /dev/mapper/sda1 /mnt/usb

When I'm done copying files to the USB key, I do, to take the USB key out:

umount /mnt/usb

This effectively unmounts the device (eg. df does not show it anymore).

Problem is, if I re-insert the USB key and try to mount it again, it does not work. cryptosetup reports that the device already exists.

Fair enough. I do: cryptosetup remove sda1

But then I try to re-create and it issues an error:

cryptosetup create /dev/mapper/sda1 /dev/sda1
"Command failed: Block device required"

If the computer is rebooted, then I can start from top and it works again.

What is the proper procedure to unmount an encrypted USB key so it can be mounted again later without rebooting the computer (this isn't Windows after all !! ;-)

Thanks.
 
Old 07-24-2006, 08:58 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I believe you need to do cryptosetup remove, then umount. Always do things symmetrically, like matching parentheses. mount -> cryptosetup -> cryptosetup remove -> umount.
 
Old 07-24-2006, 09:51 PM   #3
carcassonne
Member
 
Registered: Jul 2005
Distribution: Fedora6 x86_64
Posts: 118

Original Poster
Rep: Reputation: 15
That's it. So simple after all. I tried it and it works. Here it is:

Start:

[insert USB key]
cryptosetup create /dev/mapper/sda1 /dev/sda1
mount /dev/mapper/sda1 /mnt/usb

[do stuff with USB key]

umount /mnt/usb
cryptosetup remove sda1

[disconnect USB key]

goto Start
 
Old 07-24-2006, 11:35 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Oops, yeah, I had mine backwards, thinking of a loopback mounted file. But you definitely have it there.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount usb drive, umount and mount another drive arubin Linux - Hardware 9 01-17-2007 04:46 AM
how to mount and umount USB on redhat 9 pak_abdul Linux - Hardware 3 08-04-2005 07:02 AM
mount/umount usb stick - PQI Intelligent Stick 2.0 sandbag Linux - Software 5 05-06-2005 12:12 PM
mount/umount usb pen - woody 2.4.21 rohr Debian 5 02-10-2005 08:06 AM
mount/umount devit Linux - General 4 02-19-2004 01:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:16 PM.

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