Bug 25891

Summary: When deleting an encrypted partition, diskdrake forgets to remove the corresponding line from /etc/crypttab
Product: Mageia Reporter: Omnio Torr <storage>
Component: RPM PackagesAssignee: Mageia tools maintainers <mageiatools>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: davidwhodgins, fri, mageia, mageia, storage, thierry.vignaud
Version: 8   
Target Milestone: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Source RPM: drakxtools-18.21-1.mga7.src.rpm CVE:
Status comment:

Description Omnio Torr 2019-12-18 14:15:02 CET
Description of problem:
After deleting an encrypted partition (previously created with diskdrake too), diskdrake only removes the corresponding line from /etc/fstab and forgets to remove the corresponding line from /etc/crypttab. This will cause "yet another complaint from systemd" at boot. The error systemd shows looks like "A start job is running for /dev/disk/by-uuid/SOME-UUID-HERE (.../1min 30s)".


Version-Release number of selected component (if applicable):
drakxtools-18.21-1.mga7

How reproducible:
Always

Steps to Reproduce:
1. Start diskdrake and create a partition (check "Encrypt partition", set the "Encryption key" and set a mountpoint like "/mnt/test").
2. Exit diskdrake and choose YES when asked to save /etc/fstab modifications. A line for the new partition will be added BOTH to /etc/fstab and /etc/crypttab.
3. Start diskdrake again, delete the encrypted partition.
4. Exit diskdrake and choose YES when asked to save /etc/fstab modifications. 
The line for the deleted partition will be removed ONLY from /etc/fstab. The remaining line in /etc/crypttab (which now corresponds to an unexisting encrypted partition) will cause systemd to whine at every boot from now on.
Omnio Torr 2019-12-18 14:17:09 CET

CC: (none) => storage

Comment 1 Lewis Smith 2019-12-18 20:46:30 CET
Thank you for this clearly expressed report.

A 'diskdrake' program I could not find anywhere. Ah! It lives as 'drakdisk' in the drakxtools-curses pkg, SRPM drakxtools as noted.

Assigning to the Mageia tools group, CC Thierry as the registered maintainer.
Various committers include daviddavid & akien (not CC'd).

CC: (none) => thierry.vignaud
Assignee: bugsquad => mageiatools

Comment 2 Morgan Leijström 2020-01-01 22:57:27 CET
Confirming.

I performed a fresh install and in partitioning stage i configured the new larger disk with encrypted partition, and also the old one with encrypted partition.  (in both cases partitions are pv for each one LVM vg, containing /, /home, swap)

Now after system is up and i am done with the old drive i removed it using diskdrake, and then removed it physically.

At boot system no longer asks for keyword for that partition when system boots up - OK so far.

But i see in journal now and then passages like:

jan 01 22:22:32 svarten.tribun systemd[1]: dev-disk-by\x2duuid-1683a090\x2d76a1\x2d4a2a\x2d99c6\x2d82821bbe2ab8.device: Job dev-disk-by\x2duuid-1683a090\x2d76a1\x2d4a2a\x2d99c6\x2d82821bbe2ab8.device/start timed out.
jan 01 22:22:32 svarten.tribun systemd[1]: Timed out waiting for device /dev/disk/by-uuid/1683a090-76a1-4a2a-99c6-82821bbe2ab8.
jan 01 22:22:32 svarten.tribun systemd[1]: Dependency failed for Cryptography Setup for crypt_sdb6.
jan 01 22:22:32 svarten.tribun systemd[1]: systemd-cryptsetup@crypt_sdb6.service: Job systemd-cryptsetup@crypt_sdb6.service/start failed with result 'dependency'.
jan 01 22:22:32 svarten.tribun systemd[1]: dev-disk-by\x2duuid-1683a090\x2d76a1\x2d4a2a\x2d99c6\x2d82821bbe2ab8.device: Job dev-disk-by\x2duuid-1683a090\x2d76a1\x2d4a2a\x2d99c6\x2d82821bbe2ab8.device/start failed with result 'timeout'.

In /etc/crypttab i have now manually removed the line
crypt_sdb6 UUID=1683a090-76a1-4a2a-99c6-82821bbe2ab8

CC: (none) => fri

Comment 3 Omnio Torr 2020-01-16 22:30:56 CET
Better remove systemd from Mageia and make everyone happy. Here, I said it.
Nicolas Lécureuil 2020-05-19 15:55:56 CEST

CC: (none) => mageia, mageia

Comment 4 Martin Whitaker 2020-06-10 12:29:56 CEST
Fixed in git.
Comment 5 Morgan Leijström 2021-02-04 23:56:12 CET
Hah! sometimes i think Diskdrake creators enjoys pulling our legs.

Testing drakxtools 18.21-1 on Mageia 7-64:

Plugged in a USB stick, let Diskdrake create an encrypted ext4, mount at /mnt/ext, said yes to write fstab, reboot.

Boot fail: Diskdrake had correctly added lines in fstab and crypttab, but at the same time * removed all three lines in fstab about the LVM LV /, /home, swap. *

Old bug, i know i reported several years sgo, but i used to trig it another way, forgot how, think it was about nfs shares...
Of course i always have fstab and crypttab backups, I am used to this clown :)

Enjoying one of our Live sticks, i found that error and created a fstab with both the new crypt, and the old LVM partitions.

Booting: yes it works, including the new partition on stick.

Launch diskdrake from Konsole, select the partition, unmount, remove.
Then in Konsole: 
modprobe: FATAL: Module aes_i586 not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module aes_i586 not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module aes_x86_64 not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module aes_x86_64 not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module amd768_rng not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module amd768_rng not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module amd7xx_tco not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module amd7xx_tco not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module hw_random not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module hw_random not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module i810_rng not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module i810_rng not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module leedslite not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module leedslite not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module padlock not found in directory /lib/modules/5.10.12-desktop-3.mga7
modprobe: FATAL: Module padlock not found in directory /lib/modules/5.10.12-desktop-3.mga7

No error reported graphically.
In journal it reports
 diskdrake[24469]: moved file /etc/fstab to /etc/fstab.old
 diskdrake[24469]: created file /etc/fstab
 diskdrake[24469]: modified file /etc/crypttab

Correct line removed from fstab - no more no less, OK.
In crypttab, the line crypt_sdc1 UUID=bf4ef51e-17ad-43b5-8302-967c92dbe568 is still there: FAIL

Sidenote: good it did backup fstab
Suggestion: it should back up crypttab too


To verify eventual fix attempts, we now have a reproducer:
Good to always start diskdrake from command line, and also watch journalctl -f
0. backup crypttab and fstab
1. Plug in a USB stick
2. Let diskdrake create an encrypted partition (I used a small ext4), let it save fstab
 2b. view fstab and crypttab
3. Reboot and verify the partition works
4. use diskdrake to unmount and remove the partiiton
 4b. view fstab and crypttab

Maybe step 3 can be omitted.
Comment 6 Morgan Leijström 2021-02-05 00:14:01 CET
** Slight investigation of the other bug: removing all LVM from fstab **

Output from journal when it did that: 

feb 04 21:07:44 svarten.tribun diskdrake[24891]: running: udevadm settle
feb 04 21:07:44 svarten.tribun diskdrake[24891]: running: dmsetup table crypt_sdc1
feb 04 21:07:44 svarten.tribun diskdrake[24891]: running: blkid -o udev -p /dev/mapper/crypt_sdc1
feb 04 21:07:44 svarten.tribun diskdrake[24891]: dmcrypt: found mapper/crypt_sdc1 type ext4 with rootDevice sdc1
feb 04 21:07:44 svarten.tribun diskdrake[24891]: modified file /tmp/crypttab._xPkKw0
feb 04 21:07:44 svarten.tribun diskdrake[24891]: running: lvm2 vgscan
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 vgchange -a y
feb 04 21:07:45 svarten.tribun diskdrake[24891]: looking for vgs in mapper/crypt_sda3
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 pvs --noheadings --nosuffix -o vg_name /dev/dm-0
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 vgs --noheadings --nosuffix --units s -o vg_extent_size vg-mag
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 vgs --noheadings --nosuffix --units s -o vg_size vg-mag
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 lvs --noheadings --nosuffix --units s -o lv_name vg-mag
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 lvs --noheadings --nosuffix --units s -o lv_size /dev/vg-mag/lv_home
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: blkid -o udev -p /dev/vg-mag/lv_home
feb 04 21:07:45 svarten.tribun diskdrake[24891]: blkid gave: ext4 021bab04-4450-453d-8fc6-0aa3fcd0909e
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 lvs --noheadings --nosuffix --units s -o lv_size /dev/vg-mag/lv_root
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: blkid -o udev -p /dev/vg-mag/lv_root
feb 04 21:07:45 svarten.tribun diskdrake[24891]: blkid gave: ext4 5a7166ca-67b8-4792-816e-b58dba1e5f27
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: lvm2 lvs --noheadings --nosuffix --units s -o lv_size /dev/vg-mag/lv_swap
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: blkid -o udev -p /dev/vg-mag/lv_swap
feb 04 21:07:45 svarten.tribun diskdrake[24891]: blkid gave: swap ea63a918-357d-41d2-a114-29911095efbe
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: dmsetup table crypt_sda3
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: blkid -o udev -p /dev/mapper/crypt_sda3
feb 04 21:07:45 svarten.tribun diskdrake[24891]: blkid gave:  Kin6Fs-DJDO-iVWu-iUBF-s6db-pzcJ-M8CTDq
feb 04 21:07:45 svarten.tribun diskdrake[24891]: dmcrypt: found mapper/crypt_sda3 type  with rootDevice sda3
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: dmsetup table crypt_sdc1
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: blkid -o udev -p /dev/mapper/crypt_sdc1
feb 04 21:07:45 svarten.tribun diskdrake[24891]: dmcrypt: found mapper/crypt_sdc1 type ext4 with rootDevice sdc1
feb 04 21:07:45 svarten.tribun diskdrake[24891]: removed files/directories (recursively) /tmp/crypttab._xPkKw0
feb 04 21:07:45 svarten.tribun diskdrake[24891]: formatting device mapper/crypt_sdc1 (type ext4)
feb 04 21:07:45 svarten.tribun diskdrake[24891]: running: mkfs.ext4 -F /dev/mapper/crypt_sdc1
feb 04 21:07:47 svarten.tribun diskdrake[24891]: running: tune2fs -c0 -i0 /dev/mapper/crypt_sdc1
feb 04 21:07:47 svarten.tribun diskdrake[24891]: running: blkid -o udev -p /dev/mapper/crypt_sdc1
feb 04 21:07:47 svarten.tribun diskdrake[24891]: blkid gave: ext4 38b2a07f-cb4b-419c-ad35-47fb38af7b71
feb 04 21:07:57 svarten.tribun diskdrake[24891]: created directory /boot (and parents if necessary)
feb 04 21:07:57 svarten.tribun diskdrake[24891]: created directory /boot/EFI (and parents if necessary)
feb 04 21:07:57 svarten.tribun diskdrake[24891]: created directory /mnt/WDred (and parents if necessary)
feb 04 21:07:57 svarten.tribun diskdrake[24891]: created directory /mnt/ext (and parents if necessary)
feb 04 21:07:57 svarten.tribun diskdrake[24891]: created directory /proc (and parents if necessary)
feb 04 21:07:57 svarten.tribun diskdrake[24891]: created directory /proc (and parents if necessary)
feb 04 21:08:00 svarten.tribun diskdrake[24891]: writing /etc/fstab
feb 04 21:08:00 svarten.tribun diskdrake[24891]: created directory /boot (and parents if necessary)
feb 04 21:08:00 svarten.tribun diskdrake[24891]: created directory /boot/EFI (and parents if necessary)
feb 04 21:08:00 svarten.tribun diskdrake[24891]: created directory /mnt/WDred (and parents if necessary)
feb 04 21:08:00 svarten.tribun diskdrake[24891]: created directory /mnt/ext (and parents if necessary)
feb 04 21:08:00 svarten.tribun diskdrake[24891]: created directory /proc (and parents if necessary)
feb 04 21:08:00 svarten.tribun diskdrake[24891]: created directory /proc (and parents if necessary)
feb 04 21:08:00 svarten.tribun diskdrake[24891]: moved file /etc/fstab to /etc/fstab.old
feb 04 21:08:00 svarten.tribun diskdrake[24891]: created file /etc/fstab
feb 04 21:08:00 svarten.tribun diskdrake[24891]: modified file /etc/crypttab
feb 04 21:08:00 svarten.tribun diskdrake[24891]: ### Program is exiting ###

Yes! - this program is very exiting ;)
Note that the last lines containing "created directory" miss the lines for /, /home, swap.
Despite that diskdrake did find the /dev/vg-mag/lv_home, etc close to the beginning of this excerpt.

In another run when it behaves it look like:
feb 04 23:38:52 svarten.tribun diskdrake[24469]: created directory /boot (and parents if necessary)
feb 04 23:38:52 svarten.tribun diskdrake[24469]: created directory /boot/EFI (and parents if necessary)
feb 04 23:38:52 svarten.tribun diskdrake[24469]: created directory /mnt/WDred (and parents if necessary)
feb 04 23:38:52 svarten.tribun diskdrake[24469]: created directory /home (and parents if necessary)
feb 04 23:38:52 svarten.tribun diskdrake[24469]: created directory / (and parents if necessary)
feb 04 23:38:52 svarten.tribun diskdrake[24469]: created directory /proc (and parents if necessary)
feb 04 23:38:52 svarten.tribun diskdrake[24469]: created directory /proc (and parents if necessary)

Why there are double lines for /proc and missing the line for swap i have no idea.
It wrote fstab correctly that time:

[morgan@svarten ~]$ cat /etc/fstab
/dev/vg-mag/lv_root / ext4 noatime,acl 1 1
# Entry for /dev/sda1 :
UUID=5c4862e6-7d53-4a04-b45b-8aa52b2037e9 /boot ext4 noatime,acl 1 2
# Entry for /dev/sda2 :
UUID=2664-ADD0 /boot/EFI vfat umask=000,iocharset=utf8 0 0
/dev/vg-mag/lv_home /home ext4 noatime,acl 1 2
# Entry for /dev/sdb1 :
UUID=dba7ddb0-b770-4971-b6bb-4bbdfd1cee3b /mnt/WDred ext4 noatime,acl 1 2
none /proc proc defaults 0 0
/dev/vg-mag/lv_swap swap swap defaults 0 0
Comment 7 Martin Whitaker 2021-02-05 00:41:09 CET
(In reply to Morgan Leijström from comment #5)
> To verify eventual fix attempts, we now have a reproducer:
> Good to always start diskdrake from command line, and also watch journalctl
> -f
> 0. backup crypttab and fstab
> 1. Plug in a USB stick
> 2. Let diskdrake create an encrypted partition (I used a small ext4), let it
> save fstab
>  2b. view fstab and crypttab
> 3. Reboot and verify the partition works
> 4. use diskdrake to unmount and remove the partiiton
>  4b. view fstab and crypttab
> 
> Maybe step 3 can be omitted.

I just tested this exact procedure on my Mageia 8 system, and the entries in both fstab and crypttab were removed correctly.
Comment 8 Morgan Leijström 2021-02-05 01:20:24 CET
Sometimes I wonder if diskdrake is allergic to something in my house...

Hmm maybe encrypted LVM is needed as ingredient?
Comment 9 Dave Hodgins 2021-02-05 02:12:41 CET
May also be a factor as to whether encrypted file systems are being used
within lvm logical volumes or the lvm is used within an encrypted physical
volume/partition.

CC: (none) => davidwhodgins

Comment 10 Morgan Leijström 2021-02-05 02:20:52 CET
In my case:

sda is SSD
 ext4 /boot
 vfat /boot/EFI
 LUKS encrypted  mapper/crypt_sda3
    Physical partiiton for LVM containing
        /dev/vg-mag/lv_home  ext4 /home
        /dev/vg-mag/lv_root  ext4 /
        /dev/vg-mag/lv_swap  swap swap
        
sdb is spinner
 One large plain ext4 at /mnt/WDred

sdc is the USB stick added in comment 5
  mapper/crypt_sdc1 ext4 with rootDevice sdc1
Comment 11 Aurelien Oudelet 2021-07-06 13:16:15 CEST
Mageia 7 is EOL since July 1st 2021.
There will not have any further bugfix for this release.

You are encouraged to upgrade to Mageia 8 as soon as possible.

@reporter, if this bug still apply with Mageia 8, please let us know it.

@packager, if you work on the Mageia 7 version of your package, please check the Mageia 8 package if issue is also present. In this case, please fix the Mageia 8 version instead.

This bug report will be closed OLD if there is no further notice within 1st September 2021.
Comment 12 Omnio Torr 2021-07-15 14:23:14 CEST
Hi, I'm the reporter of this bug.

Unfortunatelly, I have to agree with Morgan Leijström: the line from /etc/crypttab doesn't get removed (and nothing changes in the behaviour I described). I reproduced the bug following the exact steps I wrote in the description of the bug.

- drakxtools-18.21-1.mga7
- the partition used for testing was a logical partition (not LVM) on my hard drive (spinner)
- I tested only with Mageia 7, I haven't upgraded yet on any of my machines.


Best wishes,
Omnio
Comment 13 Marja Van Waes 2021-09-07 14:11:26 CEST
Hi bug reporter and hi assignee and others involved,

Please reopen this bug report if it is still valid for Mageia 8 or 9(cauldron), and change "Version:" in the upper left of this report accordingly.

This report is being closed as OLD because it was filed against Mageia 7, for which  support ended on June 30th 2021.

Thanks,
Marja

Status: NEW => RESOLVED
Resolution: (none) => OLD

Comment 14 Morgan Leijström 2021-09-07 17:19:30 CEST
Reporter reproduced recently on mga7 in c#12 and i doubt it have changed to mga8.

Version: 7 => 8
Status: RESOLVED => REOPENED
Resolution: OLD => (none)

Comment 15 Martin Whitaker 2021-09-07 17:45:32 CEST
(In reply to Morgan Leijström from comment #14)
> Reporter reproduced recently on mga7 in c#12 and i doubt it have changed to
> mga8.

See comment 4 and comment 7. Feel free to reopen if you can still reproduce it in Mageia 8.

Status: REOPENED => RESOLVED
Resolution: (none) => FIXED