Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #236778

Re: Whole Disk Encryption + SSD

From David Christensen <dpchrist@holgerdanske.com>
Newsgroups linux.debian.user
Subject Re: Whole Disk Encryption + SSD
Date 2021-07-02 20:40 +0200
Message-ID <CwweZ-7QN-5@gated-at.bofh.it> (permalink)
References <Cv0TT-1C0-3@gated-at.bofh.it> <Cv6cV-4QX-1@gated-at.bofh.it> <Cwhzj-715-1@gated-at.bofh.it> <CwilH-7y5-1@gated-at.bofh.it> <CwsXL-60r-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 7/2/21 8:02 AM, David Wright wrote:
> On Thu 01 Jul 2021 at 20:43:09 (-0700), David Christensen wrote:
>> On 7/1/21 7:55 PM, David Wright wrote:
>>> On Mon 28 Jun 2021 at 13:36:35 (-0700), David Christensen wrote:
>>>
>>>> I do not set the 'discard' (trim) option in fstab(5).  If and when I
>>>> want to erase unused blocks (such as before taking an image), I use
>>>> fstrim(8).

>>> What improvement does erasing unused blocks achieve?
>>
>> Zero blocks are readily compressed, reducing the size of the image file.
> 
> Ah, I see. So a spinning rust analogy might be:
> 
> . Take an old conventional disk, sdz, where df shows 10% uasge,
> . cp /dev/zero a-file-on-sdz
> . rm a-file-on-sdz
> . dd if=/dev/sdz … and compressing it, saving ~90% space.
> 
> But can I tweak my question a little—
> 
> Say that /dev/sdz contained one partition, sdz1, which filled the disk
> and was a LUKS encrypted /home. In this case, the above would fail to
> save space because the raw device sdz would be full of "random" data.
> 
> But what happens with an SSD? If, after the rm step above, you
> # fstrim /home
> the mountpoint, where /etc/fstab has the line
>    /dev/mapper/luks-fedcba98-7654-3210-… LABEL1 ext4 /home
> then what gets zeroed, the container or the contained?
> I can't put my finger on any documentation that spells it out.


AIUI userland programs such as fstrim(8) interact with the kernel via an 
application programming interface (API).  Device drivers interact with 
the kernel and/or each other via device driver interfaces (DDI).  Some 
device drivers are designed to interact with hardware.  Other device 
drivers are designed to fit in between the kernel and/or device drivers 
-- for example, LVM, md, and dm-crypt.  So, you can layer ext4 on top of 
LVM on top of dm-crypt (LUKS) on top of md on top of several SSD's.


Given a file system driver that supports trim, fstrim makes an API call 
to the file system driver telling the file system driver to erase unused 
blocks.  The file system driver knows what blocks are unused and makes 
DDI calls to trim those blocks.  If everything between the file system 
driver and the SSD(s) supports trim commands, eventually the trim 
commands reach the SSD(s) and blocks are erased.  Similarly, the 
response codes must be passed upwards from the SSD(s) to the file system 
driver, which then responds to fstrim.


David

Back to linux.debian.user | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Whole Disk Encryption + SSD piorunz <piorunz@gmx.com> - 2021-06-28 17:00 +0200
  Re: Whole Disk Encryption + SSD Jochen Spieker <ml@well-adjusted.de> - 2021-06-28 18:00 +0200
  Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-28 22:40 +0200
    Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-29 00:00 +0200
    Re: Whole Disk Encryption + SSD Stefan Monnier <monnier@iro.umontreal.ca> - 2021-06-29 02:00 +0200
      Re: Whole Disk Encryption + SSD <tomas@tuxteam.de> - 2021-06-29 09:50 +0200
        Re: Whole Disk Encryption + SSD Stefan Monnier <monnier@iro.umontreal.ca> - 2021-06-30 00:50 +0200
        Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-30 01:00 +0200
    Re: Whole Disk Encryption + SSD Jonathan Dowland <jon+debian-user@dow.land> - 2021-06-29 11:30 +0200
    Re: Whole Disk Encryption + SSD piorunz <piorunz@gmx.com> - 2021-06-29 14:10 +0200
      Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-06-30 02:20 +0200
    Re: Whole Disk Encryption + SSD David Wright <deblis@lionunicorn.co.uk> - 2021-07-02 05:00 +0200
      Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 05:50 +0200
        Useless use of "dd" Teemu Likonen <tlikonen@iki.fi> - 2021-07-02 07:50 +0200
          Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 09:50 +0200
            Re: Useful use of dd [was: Useless use of "dd"] Teemu Likonen <tlikonen@iki.fi> - 2021-07-02 12:30 +0200
              Re: Useful use of dd "Thomas Schmitt" <scdbackup@gmx.net> - 2021-07-02 13:00 +0200
                Re: Useful use of dd <tomas@tuxteam.de> - 2021-07-02 13:20 +0200
                Re: Useful use of dd Teemu Likonen <tlikonen@iki.fi> - 2021-07-02 13:30 +0200
                Re: Useful use of dd David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 23:50 +0200
              Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 13:20 +0200
              Re: Useful use of dd Michael Stone <mstone@debian.org> - 2021-07-02 14:50 +0200
              Re: Useful use of dd [was: Useless use of "dd"] Kushal Kumaran <kushal@locationd.net> - 2021-07-02 21:10 +0200
                Creation of empty files [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 23:40 +0200
                Re: Creation of empty files [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-03 00:00 +0200
                Re: Creation of empty files [was: Useful use of dd] Michael Stone <mstone@debian.org> - 2021-07-03 15:50 +0200
                Re: Creation of empty files [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-03 23:40 +0200
                Re: Creation of empty files [was: Useful use of dd] Michael Stone <mstone@debian.org> - 2021-07-04 06:00 +0200
            Re: Useful use of dd [was: Useless use of "dd"] Greg Wooledge <greg@wooledge.org> - 2021-07-02 13:40 +0200
              Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 13:40 +0200
                Re: Useful use of dd [was: Useless use of "dd"] David Wright <deblis@lionunicorn.co.uk> - 2021-07-02 17:10 +0200
                Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-02 17:40 +0200
                Re: Useful use of dd [was: Useless use of "dd"] Gunnar Gervin <dofeelok@gmail.com> - 2021-07-03 09:20 +0200
                Re: Useful use of dd [was: Useless use of "dd"] <tomas@tuxteam.de> - 2021-07-03 09:30 +0200
            Useless use of shell pipelines [was: Useful use of dd] David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 23:40 +0200
              Re: Useless use of shell pipelines [was: Useful use of dd] l0f4r0@tuta.io - 2021-07-03 10:30 +0200
                Re: Useless use of shell pipelines [was: Useful use of dd] Greg Wooledge <greg@wooledge.org> - 2021-07-03 15:40 +0200
          Re: Useless use of "dd" David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 21:40 +0200
        Re: Whole Disk Encryption + SSD David Wright <deblis@lionunicorn.co.uk> - 2021-07-02 17:10 +0200
          Re: Whole Disk Encryption + SSD Michael Stone <mstone@debian.org> - 2021-07-02 17:30 +0200
          Re: Whole Disk Encryption + SSD David Christensen <dpchrist@holgerdanske.com> - 2021-07-02 20:40 +0200

csiph-web