All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-crypt] cryptsetup luksClose
@ 2012-01-16 14:48 Marc Schwarzschild
  2012-01-17  8:50 ` Milan Broz
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Schwarzschild @ 2012-01-16 14:48 UTC (permalink / raw)
  To: dm-crypt


Hi,

I am setting up an external USB encrypted drive. I can mount it
manually after I boot the computer. I understand that I must
issue the 'cryptsetup luksClose' after I umount the disk. How do
I arrange for this as part of the Debian halt process so it
happens automatically when the server is shutdown? What happens
if there is a power failure and 'cryptsetup luksClose' was not
executed?

Thank you,
Marc

-- 

_________________________________________________________
Marc Schwarzschild 212-580-1175 The Brookhaven Group, LLC

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dm-crypt] cryptsetup luksClose
  2012-01-16 14:48 [dm-crypt] cryptsetup luksClose Marc Schwarzschild
@ 2012-01-17  8:50 ` Milan Broz
  2012-01-17 21:31   ` Marc Schwarzschild
  0 siblings, 1 reply; 5+ messages in thread
From: Milan Broz @ 2012-01-17  8:50 UTC (permalink / raw)
  To: Marc Schwarzschild; +Cc: dm-crypt

On 01/16/2012 03:48 PM, Marc Schwarzschild wrote:
> I am setting up an external USB encrypted drive. I can mount it
> manually after I boot the computer. I understand that I must
> issue the 'cryptsetup luksClose' after I umount the disk. How do
> I arrange for this as part of the Debian halt process so it
> happens automatically when the server is shutdown?

It is not cryptsetup job, it should be part of initscripts/systemd
to correctly unmap active devices on shutdown.
(Usually it tries to unmap all crypto disks except device
with root fs which is just remounted read-only. Recent systemd is able
to unmouteven root device properly.)

For hot-plugged disks it is usually handled by some GUI service,
usually based on udisks.

> What happens
> if there is a power failure and 'cryptsetup luksClose' was not
> executed?

For LUKS, no need to worry after power failure - luksClose
just remove kernel mapping (kernel state) it doesn't touch
on-disk metadata at all.
(Of course there can be some filesystem damage after power failure,
but that's not LUKS related, it can happen even for unencrypted fs.)

Milan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dm-crypt] cryptsetup luksClose
  2012-01-17  8:50 ` Milan Broz
@ 2012-01-17 21:31   ` Marc Schwarzschild
  2012-01-18  8:10     ` Milan Broz
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Schwarzschild @ 2012-01-17 21:31 UTC (permalink / raw)
  To: Milan Broz; +Cc: dm-crypt


Thank you.  I gather from this that I can safely halt or reboot
while a disk is mounted, right?

--- January 17, 2012 Milan Broz sent: ---

  On 01/16/2012 03:48 PM, Marc Schwarzschild wrote:
  > I am setting up an external USB encrypted drive. I can mount it
  > manually after I boot the computer. I understand that I must
  > issue the 'cryptsetup luksClose' after I umount the disk. How do
  > I arrange for this as part of the Debian halt process so it
  > happens automatically when the server is shutdown?
  
  It is not cryptsetup job, it should be part of initscripts/systemd
  to correctly unmap active devices on shutdown.
  (Usually it tries to unmap all crypto disks except device
  with root fs which is just remounted read-only. Recent systemd is able
  to unmouteven root device properly.)
  
  For hot-plugged disks it is usually handled by some GUI service,
  usually based on udisks.
  
  > What happens
  > if there is a power failure and 'cryptsetup luksClose' was not
  > executed?
  
  For LUKS, no need to worry after power failure - luksClose
  just remove kernel mapping (kernel state) it doesn't touch
  on-disk metadata at all.
  (Of course there can be some filesystem damage after power failure,
  but that's not LUKS related, it can happen even for unencrypted fs.)
  
  Milan

-- 

_________________________________________________________
Marc Schwarzschild 212-580-1175 The Brookhaven Group, LLC

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dm-crypt] cryptsetup luksClose
  2012-01-17 21:31   ` Marc Schwarzschild
@ 2012-01-18  8:10     ` Milan Broz
  2012-01-19 15:30       ` Marc Schwarzschild
  0 siblings, 1 reply; 5+ messages in thread
From: Milan Broz @ 2012-01-18  8:10 UTC (permalink / raw)
  To: Marc Schwarzschild; +Cc: dm-crypt

On 01/17/2012 10:31 PM, Marc Schwarzschild wrote:
>
> Thank you.  I gather from this that I can safely halt or reboot
> while a disk is mounted, right?

 From the LUKS metadata point of view yes (there will be still
encryption key in memory but that's different problem).

 From the filesystem POV above LUKS - it depends. If it is remounted
read-only, there should be no data loss on [un]expected reboot.
(If you reboot while some write IOs are in-flight, of course you get
some corruption.)

Anyway, distro initscripts should handle this during controlled
shutdown for all mounted devices.

Milan

>
> --- January 17, 2012 Milan Broz sent: ---
>
>    On 01/16/2012 03:48 PM, Marc Schwarzschild wrote:
>    >  I am setting up an external USB encrypted drive. I can mount it
>    >  manually after I boot the computer. I understand that I must
>    >  issue the 'cryptsetup luksClose' after I umount the disk. How do
>    >  I arrange for this as part of the Debian halt process so it
>    >  happens automatically when the server is shutdown?
>
>    It is not cryptsetup job, it should be part of initscripts/systemd
>    to correctly unmap active devices on shutdown.
>    (Usually it tries to unmap all crypto disks except device
>    with root fs which is just remounted read-only. Recent systemd is able
>    to unmouteven root device properly.)
>
>    For hot-plugged disks it is usually handled by some GUI service,
>    usually based on udisks.
>
>    >  What happens
>    >  if there is a power failure and 'cryptsetup luksClose' was not
>    >  executed?
>
>    For LUKS, no need to worry after power failure - luksClose
>    just remove kernel mapping (kernel state) it doesn't touch
>    on-disk metadata at all.
>    (Of course there can be some filesystem damage after power failure,
>    but that's not LUKS related, it can happen even for unencrypted fs.)
>
>    Milan
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dm-crypt] cryptsetup luksClose
  2012-01-18  8:10     ` Milan Broz
@ 2012-01-19 15:30       ` Marc Schwarzschild
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Schwarzschild @ 2012-01-19 15:30 UTC (permalink / raw)
  To: Milan Broz; +Cc: dm-crypt


Thank you.


--- January 18, 2012 Milan Broz sent: ---

  On 01/17/2012 10:31 PM, Marc Schwarzschild wrote:
  >
  > Thank you.  I gather from this that I can safely halt or reboot
  > while a disk is mounted, right?
  
   From the LUKS metadata point of view yes (there will be still
  encryption key in memory but that's different problem).
  
   From the filesystem POV above LUKS - it depends. If it is remounted
  read-only, there should be no data loss on [un]expected reboot.
  (If you reboot while some write IOs are in-flight, of course you get
  some corruption.)
  
  Anyway, distro initscripts should handle this during controlled
  shutdown for all mounted devices.
  
  Milan
  
  >
  > --- January 17, 2012 Milan Broz sent: ---
  >
  >    On 01/16/2012 03:48 PM, Marc Schwarzschild wrote:
  >    >  I am setting up an external USB encrypted drive. I can mount it
  >    >  manually after I boot the computer. I understand that I must
  >    >  issue the 'cryptsetup luksClose' after I umount the disk. How do
  >    >  I arrange for this as part of the Debian halt process so it
  >    >  happens automatically when the server is shutdown?
  >
  >    It is not cryptsetup job, it should be part of initscripts/systemd
  >    to correctly unmap active devices on shutdown.
  >    (Usually it tries to unmap all crypto disks except device
  >    with root fs which is just remounted read-only. Recent systemd is able
  >    to unmouteven root device properly.)
  >
  >    For hot-plugged disks it is usually handled by some GUI service,
  >    usually based on udisks.
  >
  >    >  What happens
  >    >  if there is a power failure and 'cryptsetup luksClose' was not
  >    >  executed?
  >
  >    For LUKS, no need to worry after power failure - luksClose
  >    just remove kernel mapping (kernel state) it doesn't touch
  >    on-disk metadata at all.
  >    (Of course there can be some filesystem damage after power failure,
  >    but that's not LUKS related, it can happen even for unencrypted fs.)
  >
  >    Milan
  >

-- 

_________________________________________________________
Marc Schwarzschild 212-580-1175 The Brookhaven Group, LLC

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-01-19 15:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16 14:48 [dm-crypt] cryptsetup luksClose Marc Schwarzschild
2012-01-17  8:50 ` Milan Broz
2012-01-17 21:31   ` Marc Schwarzschild
2012-01-18  8:10     ` Milan Broz
2012-01-19 15:30       ` Marc Schwarzschild

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.