Hi I ran the command cryptsetup-reencrypt and it failed. I'll give the log as follows. I added some debug codes, and find it failed when write device. Then I modify the code when open device and it works well. I don't know whether it's right to modify by this way. Could you help me to check this? 139 /* Get path to device / file */ 140 const char *device_path(const struct device *device) 141 { 142 if (!device) 143 return NULL; 144 145 //if (device->file_path) 146 // return device->file_path; 147 148 //return device->path; 149 if (device->path) 150 return device->path; 151 152 return device->file_path; 153 154 } [root@storageqe-06 /]# ./cryptsetup-1.6.2/src/cryptsetup-reencrypt /dev/dm-10 --debug WARNING: this is experimental code, it can completely break your data. # cryptsetup 1.6.2 processing "/cryptsetup-1.6.2/src/.libs/lt-cryptsetup-reencrypt /dev/dm-10 --debug" # Initialising reencryption context. # Initialising UUID. # Allocating crypt device /dev/dm-10 context. # Trying to open and read device /dev/dm-10. # Initialising device-mapper backend library. # Trying to load LUKS1 crypt type from device /dev/dm-10. # Crypto backend (gcrypt 1.5.3) initialized. # Reading LUKS header of size 1024 from device /dev/dm-10 open device /dev/dm-10 # Key length 32, device size 10483712 sectors, header size 2050 sectors. # Releasing crypt device /dev/dm-10 context. # Releasing device-mapper backend. # Removing headers. # Allocating crypt device (null) context. # Initialising device-mapper backend library. # Deactivating volume LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.org. # Detected kernel Linux 3.10.0-41.el7.x86_64 x86_64. # dm version OF [16384] (*1) # dm versions OF [16384] (*1) # Detected dm-crypt version 1.12.1, dm-ioctl version 4.26.0. # Device-mapper backend running with UDEV support enabled. # dm status LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.org OF [16384] (*1) Device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.org is not active. # Deactivating volume LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new. # dm status LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new OF [16384] (*1) Device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new is not active. # Releasing crypt device (null) context. # Releasing device-mapper backend. # Created LUKS reencryption log file LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.log. # Log: direction = 0 # Log: offset = 0 # Log: shift = 0 # Running reencryption. # Passhrases initialization. # Allocating crypt device /dev/dm-10 context. # Trying to open and read device /dev/dm-10. # Initialising device-mapper backend library. # Trying to load LUKS1 crypt type from device /dev/dm-10. # Crypto backend (gcrypt 1.5.3) initialized. # Reading LUKS header of size 1024 from device /dev/dm-10 open device /dev/dm-10 # Key length 32, device size 10483712 sectors, header size 2050 sectors. # Setting ciphertext data device to /dev/dm-10. # Trying to open and read device /dev/dm-10. # Installing SIGINT/SIGTERM handler. # Unblocking interruption on signal. # Interactive passphrase entry requested. Enter passphrase for key slot 1: # Blocking interruption on signal. # Checking volume [keyslot 1] using passphrase. # Trying to open key slot 1 [ACTIVE_LAST]. # Reading key slot 1 area. # Calculated device size is 250 sectors (RW), offset 264. # DM-UUID is CRYPT-TEMP-temporary-cryptsetup-19880 # Udev cookie 0xd4d7ef6 (semid 7831552) created # Udev cookie 0xd4d7ef6 (semid 7831552) incremented to 1 # Udev cookie 0xd4d7ef6 (semid 7831552) incremented to 2 # Udev cookie 0xd4d7ef6 (semid 7831552) assigned to CREATE task(0) with flags DISABLE_SUBSYSTEM_RULES DISABLE_DISK_RULES DISABLE_OTHER_RULES (0xe) # dm create temporary-cryptsetup-19880 CRYPT-TEMP-temporary-cryptsetup-19880 OF [16384] (*1) # dm reload temporary-cryptsetup-19880 OFRW [16384] (*1) # dm resume temporary-cryptsetup-19880 OFRW [16384] (*1) # temporary-cryptsetup-19880: Stacking NODE_ADD (253,13) 0:6 0660 [verify_udev] # temporary-cryptsetup-19880: Stacking NODE_READ_AHEAD 256 (flags=1) # Udev cookie 0xd4d7ef6 (semid 7831552) decremented to 1 # Udev cookie 0xd4d7ef6 (semid 7831552) waiting for zero # Udev cookie 0xd4d7ef6 (semid 7831552) destroyed # temporary-cryptsetup-19880: Processing NODE_ADD (253,13) 0:6 0660 [verify_udev] # temporary-cryptsetup-19880: Processing NODE_READ_AHEAD 256 (flags=1) # temporary-cryptsetup-19880 (253:13): read ahead is 256 # temporary-cryptsetup-19880: retaining kernel read ahead of 256 (requested 256) # Udev cookie 0xd4dea15 (semid 7864320) created # Udev cookie 0xd4dea15 (semid 7864320) incremented to 1 # Udev cookie 0xd4dea15 (semid 7864320) incremented to 2 # Udev cookie 0xd4dea15 (semid 7864320) assigned to REMOVE task(2) with flags (0x0) # dm remove temporary-cryptsetup-19880 OFT [16384] (*1) # temporary-cryptsetup-19880: Stacking NODE_DEL [verify_udev] # Udev cookie 0xd4dea15 (semid 7864320) decremented to 1 # Udev cookie 0xd4dea15 (semid 7864320) waiting for zero # Udev cookie 0xd4dea15 (semid 7864320) destroyed # temporary-cryptsetup-19880: Processing NODE_DEL [verify_udev] Key slot 1 unlocked. # Releasing crypt device /dev/dm-10 context. # Releasing device-mapper backend. # Creating LUKS header backup for device /dev/dm-10. # Allocating crypt device /dev/dm-10 context. # Trying to open and read device /dev/dm-10. # Initialising device-mapper backend library. # Trying to load LUKS1 crypt type from device /dev/dm-10. # Crypto backend (gcrypt 1.5.3) initialized. # Reading LUKS header of size 1024 from device /dev/dm-10 open device /dev/dm-10 # Key length 32, device size 10483712 sectors, header size 2050 sectors. # Crypto backend (gcrypt 1.5.3) initialized. # Requested header backup of device /dev/dm-10 (LUKS1) to file LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.org. # Reading LUKS header of size 1024 from device /dev/dm-10 open device /dev/dm-10 # Key length 32, device size 10483712 sectors, header size 2050 sectors. # Storing backup of header (1024 bytes) and keyslot area (1045504 bytes). open device /dev/dm-10 LUKS header backup of device /dev/dm-10 created. # Creating empty file LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new of size 1049600. # Allocating crypt device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new context. # Trying to open and read device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new. # Iteration time set to 1000 miliseconds. # Formatting device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new as type LUKS1. # Crypto backend (gcrypt 1.5.3) initialized. # Trying to open and read device /dev/dm-10. # Generating LUKS header version 1 using hash sha1, aes, xts-plain64, MK 32 bytes # Crypto backend (gcrypt 1.5.3) initialized. # KDF pbkdf2, hash sha1: 285871 iterations per second. # Data offset 4096, UUID bfeb35f1-90b9-4bc6-ba43-a4302db7957b, digest iterations 34875 open device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new errno is 9 # Updating LUKS header of size 1024 on device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new # Key length 32, device size 2050 sectors, header size 2050 sectors. open device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new path is LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new file path is (null) errno is 9 # Reading LUKS header of size 1024 from device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new open device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new # Key length 32, device size 2050 sectors, header size 2050 sectors. New LUKS header for device /dev/dm-10 created. # Adding new keyslot 1 using volume key. # Calculating data for key slot 1 # Crypto backend (gcrypt 1.5.3) initialized. # KDF pbkdf2, hash sha1: 289023 iterations per second. # Key slot 1 use 141124 password iterations. # Using hash sha1 for AF in key slot 1, 4000 stripes # Updating key slot 1 [0x21000] area. # Allocating a free loop device. # Trying to open and read device /dev/loop0. # Calculated device size is 256 sectors (RW), offset 264. # DM-UUID is CRYPT-TEMP-temporary-cryptsetup-19880 # Udev cookie 0xd4d578a (semid 7897088) created # Udev cookie 0xd4d578a (semid 7897088) incremented to 1 # Udev cookie 0xd4d578a (semid 7897088) incremented to 2 # Udev cookie 0xd4d578a (semid 7897088) assigned to CREATE task(0) with flags DISABLE_SUBSYSTEM_RULES DISABLE_DISK_RULES DISABLE_OTHER_RULES (0xe) # dm create temporary-cryptsetup-19880 CRYPT-TEMP-temporary-cryptsetup-19880 OF [16384] (*1) # dm reload temporary-cryptsetup-19880 OFW [16384] (*1) # dm resume temporary-cryptsetup-19880 OFW [16384] (*1) # temporary-cryptsetup-19880: Stacking NODE_ADD (253,13) 0:6 0660 [verify_udev] # temporary-cryptsetup-19880: Stacking NODE_READ_AHEAD 256 (flags=1) # Udev cookie 0xd4d578a (semid 7897088) decremented to 1 # Udev cookie 0xd4d578a (semid 7897088) waiting for zero # Udev cookie 0xd4d578a (semid 7897088) destroyed # temporary-cryptsetup-19880: Processing NODE_ADD (253,13) 0:6 0660 [verify_udev] # temporary-cryptsetup-19880: Processing NODE_READ_AHEAD 256 (flags=1) # temporary-cryptsetup-19880 (253:13): read ahead is 256 # temporary-cryptsetup-19880: retaining kernel read ahead of 256 (requested 256) errno is 9 # Udev cookie 0xd4d5652 (semid 7929856) created # Udev cookie 0xd4d5652 (semid 7929856) incremented to 1 # Udev cookie 0xd4d5652 (semid 7929856) incremented to 2 # Udev cookie 0xd4d5652 (semid 7929856) assigned to REMOVE task(2) with flags (0x0) # dm remove temporary-cryptsetup-19880 OFT [16384] (*1) # temporary-cryptsetup-19880: Stacking NODE_DEL [verify_udev] # Udev cookie 0xd4d5652 (semid 7929856) decremented to 1 # Udev cookie 0xd4d5652 (semid 7929856) waiting for zero # Udev cookie 0xd4d5652 (semid 7929856) destroyed # temporary-cryptsetup-19880: Processing NODE_DEL [verify_udev] # Key slot 1 was enabled in LUKS header. # Updating LUKS header of size 1024 on device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new # Key length 32, device size 2050 sectors, header size 2050 sectors. open device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new //I thinks it should open /dev/loop0 path is /dev/loop0 file path is LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new errno is 22 r = -1, solid = 1024 ccccccccc Error during update of LUKS header on device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new. # Releasing crypt device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new context. # Closed loop /dev/loop0 (LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new). # Releasing crypt device /dev/dm-10 context. # Releasing device-mapper backend. Creation of LUKS backup headers failed. # Destroying reencryption context. # Closing LUKS reencryption log file LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.log. # Removing headers. # Allocating crypt device (null) context. # Initialising device-mapper backend library. # Deactivating volume LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.org. # dm status LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.org OF [16384] (*1) Device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.org is not active. # Deactivating volume LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new. # dm status LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new OF [16384] (*1) Device LUKS-bfeb35f1-90b9-4bc6-ba43-a4302db7957b.new is not active. # Releasing crypt device (null) context. # Releasing device-mapper backend. Best Regards Xiao Ni _______________________________________________ dm-crypt mailing list dm-crypt@xxxxxxxx http://www.saout.de/mailman/listinfo/dm-crypt