[dm-crypt] Encrypted partitions with sectors to zero?

Thomas Martin tmartincpp at gmail.com
Wed Oct 23 16:24:56 CEST 2013


Hi everyone.

I was trying to verify that discard (TRIM) was disabled on my system
(new fresh install on a SSD) when I found some weird things.

Indeed it seems I have many sectors to zero; example:
root at o9020:~# hdparm --read-sector 54003000 /dev/sda
/dev/sda:
reading sector 54003000: succeeded
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
...
0000 0000 0000 0000 0000 0000 0000 0000


According to me, only my /boot partition should have zero (as this is
the only one unencrypted):
root at o9020:~# parted /dev/sda "unit s print"
Model: ATA LITEONIT LCS-128 (scsi)
Disk /dev/sda: 250069680s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start     End         Size        Type      File system  Flags
 1      2048s     1953791s    1951744s    primary   ext4         boot
 2      1955838s  250068991s  248113154s  extended
 5      1955840s  250068991s  248113152s  logical

root at o9020:~# lsblk /dev/sda -f
NAME                              FSTYPE      LABEL MOUNTPOINT
sda
├─sda1                            ext4              /boot
├─sda2
└─sda5                            crypto_LUKS
  └─sda5_crypt (dm-0)             LVM2_member
    ├─VolumeGroup1-root (dm-1)    ext4              /
    ├─VolumeGroup1-swap (dm-2)    swap              [SWAP]
    ├─VolumeGroup1-usr (dm-3)     ext4              /usr
    ├─VolumeGroup1-tmp (dm-4)     ext4              /tmp
    ├─VolumeGroup1-opt (dm-5)     ext4              /opt
    ├─VolumeGroup1-var (dm-6)     ext4              /var
    ├─VolumeGroup1-home (dm-7)    ext4              /home
    └─VolumeGroup1-backups (dm-8) ext4              /backups

root at o9020:~# dmsetup table
VolumeGroup1-home: 0 97648640 linear 254:0 83978240
VolumeGroup1-usr: 0 19529728 linear 254:0 25389056
VolumeGroup1-var: 0 19529728 linear 254:0 64448512
VolumeGroup1-swap: 0 15622144 linear 254:0 9766912
VolumeGroup1-root: 0 9764864 linear 254:0 2048
VolumeGroup1-backups: 0 39059456 linear 254:0 181626880
sda5_crypt: 0 248109056 crypt aes-xts-plain64
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0 8:5 4096
VolumeGroup1-opt: 0 9764864 linear 254:0 54683648
VolumeGroup1-tmp: 0 9764864 linear 254:0 44918784


Is it expected?
Does I have to fully fill the encrypted partition (at least once) to
hide my datas?


FYI I verified TRIM and it seems really disabled:
root at o9020:/tmp# fstrim -v /tmp/
fstrim: /tmp/: FITRIM ioctl failed: Operation not supported


Thanks a lot for your help.


NB: I'm using Debian (Wheezy/Stable):
root at o9020:~# dpkg -l cryptsetup lvm2 dmsetup|tail -3
ii  cryptsetup                                 2:1.4.3-4
          amd64        disk encryption support - startup scripts
ii  dmsetup                                    2:1.02.74-8
          amd64        Linux Kernel Device Mapper userspace library
ii  lvm2                                       2.02.95-8
          amd64        Linux Logical Volume Manager


More information about the dm-crypt mailing list