Gentoo Archives: gentoo-user

From: Ramon Fischer <Ramon_Fischer@×××××××.de>
To: Dale <rdalek1967@×××××.com>, Gentoo User <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] cryptsetup close and device in use when it is not
Date: Mon, 09 Aug 2021 13:32:20
Message-Id: AM6PR10MB2440A2245501F594C7EA4443EFF69@AM6PR10MB2440.EURPRD10.PROD.OUTLOOK.COM
In Reply to: Re: [gentoo-user] cryptsetup close and device in use when it is not by Dale
1 Hi Dale,
2
3 > So, something says it is busy but eventually
4 > releases it if left alone for a while.  I'd like to know what it is and
5 > if it is really in use or not.  Thing is, I can't find a way to know
6 > what it is that is using it.  The dmsetup command shows it is in use but
7 > no way to know what is using it.
8 I could reproduce this issue by killing my desktop process, unmounting
9 the home partition and playing some "kill process" bingo. I could
10 backtrace it to one unkillable process "kcryptd":
11
12 1. Kill "awesomewm": <CTRL + ALT> + Backspace
13 2. Kill other processes accessing "/home/"
14 3. umount /home
15 4. cryptsetup close crypthome
16 Device crypthome is still in use
17 5. dmsetup info /dev/mapper/crypthome
18 Name:              crypthome
19 State:             ACTIVE
20 Read Ahead:        256
21 Tables present:    LIVE
22 Open count:        1
23 Event number:      0
24 Major, minor:      253, 1
25 Number of targets: 1
26 UUID: CRYPT-LUKS2-<some_uuid>-crypthome
27 6. Kill any unnecessary process and try "cryptsetup close crypthome"
28 7. Search for major, minor: ps aux | grep "253:1"
29 root       150  0.2  0.0      0     0 ?        I    15:21   0:02
30 [kworker/u16:5-kcryptd/253:1]
31 8. Does not work: kill 150
32 9. Does not work and could be dangerous: kill -9 150
33
34 So, there was still one "kcryptd" process left, accessing the hard
35 drive, but I found no way to kill it.
36
37 Maybe this could be helpful?
38
39 -Ramon
40
41
42 On 02/08/2021 15:33, Dale wrote:
43 > Ramon Fischer wrote:
44 >> OK, if it could be "udev", you might want to try to check the following:
45 >>
46 >>    $ grep -rF "<part_of_uuid>" /etc/udev/rules.d/
47 >>    $ grep -rF "<part_of_uuid>" /lib/udev/rules.d/
48 >>    $ grep -rF "<part_of_uuid>" /etc
49 >>
50 >> You could also try to search for the partition device, maybe there
51 >> will be some interesting configuration files.
52 >>
53 >> If you are using "systemd", you might want to check every service unit
54 >> file as well:
55 >>
56 >>    $ systemctl
57 >>
58 >> Recently, I had a similar issue with "cryptsetup" on Raspbian, where
59 >> the "/etc/crypttab" was faulty, which may be applicable here. It had
60 >> the following entry:
61 >>
62 >>    # <accident_paste_with_uuid> # <target name> <source device> [...]
63 >>    <entry1>
64 >>    <entry2>
65 >>
66 >> Therefore, the systemd service unit
67 >> "systemd-cryptsetup@dev-disk-by\x2duuid-#<accident_paste_with_uuid> #
68 >> <target name> <source device> [...]" - if I remember correctly - failed.
69 >> It seems, that "systemd-cryptsetup-generator" only searches for
70 >> matching UUIDs in "/etc/crypttab", even, if they are commented and
71 >> creates service units for each match in "/run/systemd/generator/".
72 >> I remember, that I had issues to access the hard drive. Nevertheless,
73 >> I was able to mount it normally, due to the other correct entry(?).
74 >>
75 >> By removing the accidentally pasted UUID from "/etc/crypttab" and
76 >> rebooting, I was able to use the hard drive without issues again.
77 >>
78 >> Maybe this is something, where you could poke around? :)
79 >>
80 >> -Ramon
81 > I'm running openrc here.  I don't recall making any udev rules
82 > recently.  This is a list of what I have.
83 >
84 >
85 > root@fireball / # ls -al /etc/udev/rules.d/
86 > total 20
87 > drwxr-xr-x 2 root root 4096 Apr 27 15:07 .
88 > drwxr-xr-x 3 root root 4096 Jul 27 03:17 ..
89 > -rw-r--r-- 1 root root 2064 Apr 27 15:07 69-libmtp.rules
90 > -rw-r--r-- 1 root root 1903 Apr  4  2012 70-persistent-cd.rules
91 > -rw-r--r-- 1 root root  814 Jan  1  2008 70-persistent-net.rules
92 > -rw-r--r-- 1 root root    0 Mar 22  2015 80-net-name-slot.rules
93 > root@fireball / #
94 >
95 >
96 > One is for CD/DVD stuff.  I wonder if I can remove that now.  Two is for
97 > network cards and top one is something to do with my old Motorola cell
98 > phone, rest in peace.
99 >
100 > All this said, it did it again last night.  I tried a few things and
101 > went to bed while my updates were compiling.  When I got up a bit ago,
102 > it closed just fine.  So, something says it is busy but eventually
103 > releases it if left alone for a while.  I'd like to know what it is and
104 > if it is really in use or not.  Thing is, I can't find a way to know
105 > what it is that is using it.  The dmsetup command shows it is in use but
106 > no way to know what is using it.
107 >
108 > Dale
109 >
110 > :-)  :-)
111
112 --
113 GPG public key: 5983 98DA 5F4D A464 38FD CF87 155B E264 13E6 99BF

Attachments

File name MIME type
OpenPGP_signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] cryptsetup close and device in use when it is not Dale <rdalek1967@×××××.com>