Bug 1661160
| Summary: | libblockdev can't resize LUKS 2 encrypted devices on RHEL 7.6 | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Vojtech Trefny <vtrefny> |
| Component: | libblockdev | Assignee: | Vojtech Trefny <vtrefny> |
| Status: | CLOSED ERRATA | QA Contact: | guazhang <guazhang> |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 7.6 | CC: | guazhang, rhandlin, xhe |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | libblockdev-2.18-4.el7 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2019-08-06 12:59:43 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Hello Sorry, I need reproduces for the bug, Could you please share some test code for it ?
```
import gi
gi.require_version('BlockDev', '2.0')
from gi.repository import BlockDev
BlockDev.switch_init_checks(False)
BlockDev.init(BlockDev.plugin_specs_from_names(["crypto"]))
BlockDev.crypto_luks_resize("/dev/mapper/test", 0, "passphrase")
```
Where "/dev/mapper/test" is an unlocked LUKS2 device and "passphrase" is passphrase for unlocking it.
Hello
Please have a look my failed.
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 15G 0 loop
loop1 7:1 0 15G 0 loop
loop2 7:2 0 15G 0 loop
loop3 7:3 0 15G 0 loop
loop4 7:4 0 15G 0 loop
loop5 7:5 0 15G 0 loop
loop6 7:6 0 15G 0 loop
└─vg01-lv01 253:7 0 10G 0 lvm
└─mapper 253:8 0 10G 0 crypt
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 930.5G 0 part
├─rhel_storageqe--05-root 253:0 0 50G 0 lvm /
├─rhel_storageqe--05-swap 253:1 0 7.9G 0 lvm [SWAP]
└─rhel_storageqe--05-home 253:2 0 872.6G 0 lvm /home
# cat runtest.py
#!/bin/env/python
import gi
gi.require_version('BlockDev', '2.0')
from gi.repository import BlockDev
BlockDev.switch_init_checks(False)
BlockDev.init(BlockDev.plugin_specs_from_names(["crypto"]))
BlockDev.crypto_luks_resize("/dev/mapper/mapper",10, "redhat redhat")
# python3 runtest.py
Traceback (most recent call last):
File "runtest.py", line 13, in <module>
BlockDev.crypto_luks_resize("/dev/mapper/mapper",10, "redhat redhat")
File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 235, in crypto_luks_resize
return _crypto_luks_resize(luks_device, size, passphrase, key_file)
GLib.Error: g-bd-crypto-error-quark: Failed to resize device: Invalid argument (4)
# cat runtest.py
# echo "redhat redhat > key_file"
#!/bin/env/python
import gi
gi.require_version('BlockDev', '2.0')
from gi.repository import BlockDev
BlockDev.switch_init_checks(False)
BlockDev.init(BlockDev.plugin_specs_from_names(["crypto"]))
BlockDev.crypto_luks_resize("/dev/mapper/mapper",10, "redhat redhat","key_file")
# python3 runtest.py
Traceback (most recent call last):
File "runtest.py", line 13, in <module>
BlockDev.crypto_luks_resize("/dev/mapper/mapper",10, "redhat redhat","key_file")
File "/usr/lib64/python3.6/site-packages/gi/overrides/BlockDev.py", line 235, in crypto_luks_resize
return _crypto_luks_resize(luks_device, size, passphrase, key_file)
GLib.Error: g-bd-crypto-error-quark: Failed to activate device: Operation not permitted (0)
I've tested this with a fresh 7.7 installation and it works for me.
Can you please try this again with this script:
```
from __future__ import print_function
import gi
gi.require_version('BlockDev', '2.0')
from gi.repository import BlockDev
BlockDev.switch_init_checks(False)
BlockDev.utils_init_logging(lambda level, msg: print(msg))
BlockDev.init(BlockDev.plugin_specs_from_names(["crypto"]))
BlockDev.crypto_luks_resize("/dev/mapper/test", 0, "passphrase")
```
(The added line enables extra logging and prints cryptsetup log to stdout.)
Also please check libblockdev version and if it's linked against cryptsetup 2.
$ rpm -qa | grep blockdev
libblockdev-2.18-4.el7.x86_64
libblockdev-crypto-2.18-4.el7.x86_64
libblockdev-utils-2.18-4.el7.x86_64
python2-blockdev-2.18-4.el7.x86_64
$ ldd /usr/lib64/libbd_crypto.so.2 | grep cryptsetup
libcryptsetup.so.12 => /lib64/libcryptsetup.so.12 (0x00007fef516ef000)
Hello test passed, so move to verified thanks Guazhang Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2019:2153 |
Description of problem: Resize attempt of a LUKS 2 devices fails with "Failed to activate device: Invalid argument" >>> BlockDev.crypto_luks_resize("/dev/mapper/test", 1024, "verysecretpassphrase") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.7/site-packages/gi/overrides/BlockDev.py", line 235, in crypto_luks_resize return _crypto_luks_resize(luks_device, size, passphrase, key_file) GLib.Error: g-bd-crypto-error-quark: Failed to activate device: Invalid argument (0) Version-Release number of selected component (if applicable): How reproducible: Name : libblockdev-crypto Arch : x86_64 Version : 2.18 Release : 3.el7