У меня есть ноутбук (Asus Zenbook UX31A) с твердотельным накопителем 124 ГБ. Я установил Ubuntu на зашифрованный раздел и начал сталкиваться с моментами временной или постоянной неактивности. Я подозревал I / O и сделал несколько тестов.
Запись на диск кажется очень медленной:
➜ ~ dd if=/dev/zero of=tempfile bs=1M count=200 conv=fdatasync,notrunc
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 8.2222 s, 25.5 MB/s
Чтения выглядят нормально
➜ ~ echo 3 > /proc/sys/vm/drop_caches
➜ ~ dd if=tempfile of=/dev/null bs=1M count=200
200+0 records in
200+0 records out
209715200 bytes (210 MB) copied, 0.9317 s, 225 MB/s
Я проверял htop и iotop во время выполнения записи и не заметил значительного увеличения загрузки процессора. «Actual DISK WRITE» iotop показывал ~ 200 МБ / с в течение короткого промежутка времени и сразу возвращался к 0 (запись dd продолжалась еще несколько секунд после этого).
У меня есть процессор Intel i7-3517U, который поддерживает AES-NI, который также включен в BIOS. Модули ядра AES-NI, кажется, включены:
➜ ~ lsmod | grep aes
aesni_intel 55624 376
aes_x86_64 17131 1 aesni_intel
lrw 13286 5 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64,twofish_x86_64_3way
glue_helper 13990 5 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64,twofish_x86_64_3way
ablk_helper 13597 4 serpent_sse2_x86_64,aesni_intel,serpent_avx_x86_64,twofish_avx_x86_64
cryptd 20359 190 ghash_clmulni_intel,aesni_intel,ablk_helper
тесты cryptsetup также выглядят хорошо:
➜ ~ ./workspace/cryptsetup-1.6.1/src/cryptsetup benchmark
# Tests are approximate using memory only (no storage IO).
PBKDF2-sha1 433295 iterations per second
PBKDF2-sha256 254508 iterations per second
PBKDF2-sha512 154021 iterations per second
PBKDF2-ripemd160 347671 iterations per second
PBKDF2-whirlpool 184608 iterations per second
# Algorithm | Key | Encryption | Decryption
aes-cbc 128b 516.9 MiB/s 1894.4 MiB/s
serpent-cbc 128b 72.8 MiB/s 251.0 MiB/s
twofish-cbc 128b 156.1 MiB/s 284.7 MiB/s
aes-cbc 256b 368.2 MiB/s 1379.8 MiB/s
serpent-cbc 256b 75.3 MiB/s 243.3 MiB/s
twofish-cbc 256b 157.7 MiB/s 292.7 MiB/s
aes-xts 256b 2376.0 MiB/s 3503.0 MiB/s
serpent-xts 256b 307.7 MiB/s 264.2 MiB/s
twofish-xts 256b 340.7 MiB/s 345.7 MiB/s
aes-xts 512b 4548.0 MiB/s 4527.0 MiB/s
serpent-xts 512b 315.1 MiB/s 265.0 MiB/s
twofish-xts 512b 327.7 MiB/s 328.7 MiB/s
Состояние Cryptsetup:
➜ ~ sudo cryptsetup status sda3_crypt
/dev/mapper/sda3_crypt is active and is in use.
type: LUKS1
cipher: aes-xts-plain64
keysize: 512 bits
device: /dev/sda3
offset: 4096 sectors
size: 241291264 sectors
mode: read/write
SSD - это SanDisk U100 :
➜ ~ sudo lshw
...
*-scsi:0
physical id: 1
logical name: scsi0
capabilities: emulated
*-disk
description: ATA Disk
product: SanDisk SSD U100
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: 10.5
serial: 122300414449
size: 115GiB (124GB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: ansiversion=5 guid=462c7bc0-c895-4486-a0de-9911664bdbf8 sectorsize=512
*-volume:0
description: Windows FAT volume
vendor: mkdosfs
physical id: 1
bus info: scsi@0:0.0.0,1
logical name: /dev/sda1
logical name: /boot/efi
version: FAT32
serial: f767-aca8
size: 189MiB
capacity: 189MiB
capabilities: boot fat initialized
configuration: FATs=2 filesystem=fat mount.fstype=vfat mount.options=rw,noatime,nodiratime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro state=mounted
*-volume:1
description: data partition
vendor: Linux
physical id: 2
bus info: scsi@0:0.0.0,2
logical name: /dev/sda2
logical name: /boot
version: 1.0
serial: 196c3925-113a-465a-b73e-b3506bf86401
size: 244MiB
capabilities: ext2 initialized
configuration: filesystem=ext2 modified=2014-01-28 00:30:04 mount.fstype=ext2 mount.options=rw,noatime,nodiratime,errors=continue state=mounted
*-volume:2
description: data partition
vendor: Windows
physical id: 3
bus info: scsi@0:0.0.0,3
logical name: /dev/sda3
serial: 4e2be2b7-d729-4e1f-912a-319533fa4e4b
size: 115GiB
capacity: 115GiB
width: 512 bits
capabilities: encrypted luks initialized
configuration: bits=512 cipher=aes filesystem=luks hash=sha1 mode=xts-plain64 version=1
Спасибо!
Оказалось, что проблема вообще не связана с шифрованием. Мне нужно было использовать команду fstrim
на разделах SSD и добавить опцию discard
для моих подключений SSD. Теперь все работает как положено.