{"id":304649,"date":"2020-06-01T15:00:41","date_gmt":"2020-06-01T15:00:41","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304649"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304649","title":{"rendered":"dracut + systemd + LUKS + usbflash = \u0430\u0432\u0442\u043e\u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504800\/\">\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u0434\u0430\u0432\u043d\u043e, \u0435\u0449\u0435 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 Centos 7 (RHEL 7). \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0434\u0438\u0441\u043a\u0430\u0445 \u0441 Centos 6, \u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u0434\u0438\u0441\u043a\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 USB \u0444\u043b\u0435\u0448\u043a\u0438 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 7-\u043a\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0432\u0441\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u0432\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0435 dracut \u043a sysvinit \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435: echo &#8216;omit_dracutmodules+=&quot; systemd &quot;&#8217; &gt; \/etc\/dracut.conf.d\/luks-workaround.conf<br \/>  \u0427\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043b\u0438\u0448\u0430\u043b\u043e \u043d\u0430\u0441 \u0432\u0441\u0435\u0439 \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u0438 systemd \u2014 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0441\u043b\u0443\u0436\u0431, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<br \/>  \u0412\u043e\u0437 \u0438 \u043d\u044b\u043d\u0435 \u0442\u0430\u043c: <a href=\"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=905683\" rel=\"nofollow\">905683<\/a><br \/>  \u041d\u0435 \u0434\u043e\u0436\u0434\u0430\u0432\u0448\u0438\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0441\u0430\u043c, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u044e\u0441\u044c \u0438 \u0441 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u043b\u044c\u0448\u0435.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cr\/tt\/ao\/crttaomzbycjgrqscdpfeoejnuw.png\"><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>  Systemd, \u043a\u043e\u0433\u0434\u0430 \u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0447\u0430\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 Centos 7 \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u043b \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u044d\u043c\u043e\u0446\u0438\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u0440\u043e\u043c\u0435 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0436\u0431\u0430\u043c\u0438, \u044f \u043d\u0435 \u043f\u043e\u0447\u0443\u0432\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b. \u0412\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 systemd \u043c\u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0441\u044f, \u043d\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u043e\u0440\u0447\u0435\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 dracut \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0443\u0434\u0435\u043b\u044f\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e systemd \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0434\u0438\u0441\u043a\u043e\u0432. \u0412 \u0446\u0435\u043b\u043e\u043c \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043d\u043e \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u043e\u0442 \u0434\u0438\u0441\u043a\u0430 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u0443\u0441\u043a\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u2014 \u043d\u0435 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u0437\u0430\u043d\u044f\u0442\u0438\u0435.<br \/>  \u041e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0432 \u043a\u0443\u0447\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0439 \u0438 \u0443\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u0441\u044c \u043c\u0430\u043d\u0443\u0430\u043b\u043e\u043c \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 systemd \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0441 USB, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0440\u0443\u0447\u043d\u043e\u0439 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430 \u0441 \u043a\u043b\u044e\u0447\u0435\u043c \u043d\u0430 USB \u0434\u0438\u0441\u043a\u0435, \u043f\u0440\u0438\u0447\u0435\u043c \u0441\u0430\u043c USB \u0434\u0438\u0441\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0435\u0433\u043e UUID, LABEL \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0443 \u0441\u0435\u0431\u044f \u0431\u044b\u043b\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0438\u0442\u043e\u0433\u0435 \u044f \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f \u0432 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 \u0438, \u043f\u0440\u043e\u0436\u0434\u0430\u0432 \u0431\u0435\u0437 \u043c\u0430\u043b\u043e\u0433\u043e 7 \u043b\u0435\u0442, \u044f \u043f\u043e\u043d\u044f\u043b \u2014 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0448\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h3>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u043b\u0430\u0433\u0438\u043d \u043a dracut \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u043a\u0430\u0436\u0434\u044b\u0439, \u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e. \u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430 systemd \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0445\u043e\u0434 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435 \u0442\u0430\u043a \u0438 \u043b\u0435\u0433\u043a\u043e. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043a dracut \u043f\u043e\u044f\u0441\u043d\u044f\u043b\u0430 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u044f \u0441\u043c\u043e\u0433 \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<h3>\u041a\u0430\u043a \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h3>\n<p>  \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u043b\u0435\u0436\u0438\u0442 \u0442\u0440\u0438 \u044e\u043d\u0438\u0442\u0430:  <\/p>\n<ol>\n<li>luks-auto-key.service \u2014 \u0438\u0449\u0435\u0442 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u0438 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0434\u043b\u044f LUKS<\/li>\n<li>luks-auto.target \u2014 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0440\u043e\u043b\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0445 \u044e\u043d\u0438\u0442\u043e\u0432 systemd-cryptsetup<\/li>\n<li>luks-auto-clean.service \u2014 \u043e\u0447\u0438\u0449\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 luks-auto-key.service<\/li>\n<\/ol>\n<p>  \u0418 luks-auto-generator.sh \u2014 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f systemd \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u044e\u043d\u0438\u0442\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u044f\u0434\u0440\u0430. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u044e\u043d\u0438\u0442\u044b fstab \u0438 \u0442.\u043f.<\/p>\n<h4>luks-auto-generator.sh<\/h4>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e drop-in.conf \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 systemd-cryptsetup, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0438\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c luks-auto.target.<\/p>\n<h4>luks-auto-key.service \u0438 luks-auto-key.sh<\/h4>\n<p>  \u042d\u0442\u043e\u0442 \u044e\u043d\u0438\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 luks-auto-key.sh, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u043a\u043b\u044e\u0447\u0430\u0445 rd.luks.*, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u043e\u0441\u0438\u0442\u0435\u043b\u0438 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u0438 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043b\u044e\u0447\u0438 \u0438\u0437 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 luks-auto-clean.service.<\/p>\n<h3>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438:<\/h3>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/usr\/lib\/dracut\/modules.d\/99luks-auto\/module-setup.sh<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">#!\/bin\/bash  check () {         if ! dracut_module_included &quot;systemd&quot;; then                 &quot;luks-auto needs systemd in the initramfs&quot;                 return 1         fi         return 255 }  depends () {         echo &quot;systemd&quot;         return 0 }  install () {         inst &quot;$systemdutildir\/systemd-cryptsetup&quot; \t\tinst_script &quot;$moddir\/luks-auto-generator.sh&quot; &quot;$systemdutildir\/system-generators\/luks-auto-generator.sh&quot; \t\tinst_script &quot;$moddir\/luks-auto-key.sh&quot; &quot;\/etc\/systemd\/system\/luks-auto-key.sh&quot; \t\tinst_script &quot;$moddir\/luks-auto.sh&quot; &quot;\/etc\/systemd\/system\/luks-auto.sh&quot; \t\tinst &quot;$moddir\/luks-auto.target&quot; &quot;${systemdsystemunitdir}\/luks-auto.target&quot; \t\tinst &quot;$moddir\/luks-auto-key.service&quot; &quot;${systemdsystemunitdir}\/luks-auto-key.service&quot; \t\tinst &quot;$moddir\/luks-auto-clean.service&quot; &quot;${systemdsystemunitdir}\/luks-auto-clean.service&quot; \t\tln_r &quot;${systemdsystemunitdir}\/luks-auto.target&quot; &quot;${systemdsystemunitdir}\/initrd.target.wants\/luks-auto.target&quot; \t\tln_r &quot;${systemdsystemunitdir}\/luks-auto-key.service&quot; &quot;${systemdsystemunitdir}\/initrd.target.wants\/luks-auto-key.service&quot; \t\tln_r &quot;${systemdsystemunitdir}\/luks-auto-clean.service&quot; &quot;${systemdsystemunitdir}\/initrd.target.wants\/luks-auto-clean.service&quot; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/usr\/lib\/dracut\/modules.d\/99luks-auto\/luks-auto-generator.sh<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> #!\/bin\/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh  . \/lib\/dracut-lib.sh  SYSTEMD_RUN='\/run\/systemd\/system' CRYPTSETUP='\/usr\/lib\/systemd\/systemd-cryptsetup' TOUT=$(getargs rd.luks.key.tout) if [ ! -z &quot;$TOUT&quot; ]; then \tmkdir -p &quot;${SYSTEMD_RUN}\/luks-auto-key.service.d&quot; \tcat &gt; &quot;${SYSTEMD_RUN}\/luks-auto-key.service.d\/drop-in.conf&quot;  &lt;&lt;EOF [Service] Type=oneshot ExecStartPre=\/usr\/bin\/sleep $TOUT  EOF fi mkdir -p &quot;$SYSTEMD_RUN\/luks-auto.target.wants&quot; for argv in $(getargs rd.luks.uuid -d rd_LUKS_UUID); do \t_UUID=${argv#luks-} \t_UUID_ESC=$(systemd-escape -p $_UUID) \tmkdir -p &quot;${SYSTEMD_RUN}\/systemd-cryptsetup@luks\\x2d${_UUID_ESC}.service.d&quot; \tcat &gt; &quot;${SYSTEMD_RUN}\/systemd-cryptsetup@luks\\x2d${_UUID_ESC}.service.d\/drop-in.conf&quot;  &lt;&lt;EOF [Unit] After=luks-auto.target ConditionPathExists=!\/dev\/mapper\/luks-${_UUID}  EOF \tcat &gt; &quot;${SYSTEMD_RUN}\/luks-auto@${_UUID_ESC}.service&quot;  &lt;&lt;EOF [Unit] Description=luks-auto Cryptography Setup for %I DefaultDependencies=no Conflicts=umount.target IgnoreOnIsolate=true Before=luks-auto.target BindsTo=dev-disk-by\\x2duuid-${_UUID_ESC}.device After=dev-disk-by\\x2duuid-${_UUID_ESC}.device luks-auto-key.service Before=umount.target  [Service] Type=oneshot RemainAfterExit=yes TimeoutSec=0 ExecStart=\/etc\/systemd\/system\/luks-auto.sh ${_UUID} ExecStop=$CRYPTSETUP detach 'luks-${_UUID}' Environment=DRACUT_SYSTEMD=1 StandardInput=null StandardOutput=syslog StandardError=syslog+console  EOF ln -fs ${SYSTEMD_RUN}\/luks-auto@${_UUID_ESC}.service $SYSTEMD_RUN\/luks-auto.target.wants\/luks-auto@${_UUID_ESC}.service done <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/usr\/lib\/dracut\/modules.d\/99luks-auto\/luks-auto-key.service<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> [Unit] Description=LUKS AUTO key searcher After=cryptsetup-pre.target Before=luks-auto.target DefaultDependencies=no  [Service] Environment=DRACUT_SYSTEMD=1 Type=oneshot ExecStartPre=\/usr\/bin\/sleep 1 ExecStart=\/etc\/systemd\/system\/luks-auto-key.sh RemainAfterExit=true StandardInput=null StandardOutput=syslog StandardError=syslog+console <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/usr\/lib\/dracut\/modules.d\/99luks-auto\/luks-auto-key.sh<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> #!\/bin\/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh export DRACUT_SYSTEMD=1  . \/lib\/dracut-lib.sh MNT_B=&quot;\/tmp\/luks-auto&quot; ARG=$(getargs rd.luks.key) IFS=$':' _t=(${ARG}) KEY=${_t[0]} F_FIELD='' F_VALUE='' if [ ! -z $KEY ] &amp;&amp; [ ! -z ${_t[1]} ];then \tIFS=$'=' _t=(${_t[1]}) \tF_FIELD=${_t[0]} \tF_VALUE=${_t[1]} \tF_VALUE=&quot;${F_VALUE%\\&quot;}&quot; \tF_VALUE=&quot;${F_VALUE#\\&quot;}&quot; fi mkdir -p $MNT_B  finding_luks_keys(){ \tlocal _DEVNAME='' \tlocal _UUID='' \tlocal _TYPE='' \tlocal _LABEL='' \tlocal _MNT='' \tlocal _KEY=&quot;$1&quot; \tlocal _F_FIELD=&quot;$2&quot; \tlocal _F_VALUE=&quot;$3&quot; \tlocal _RET=0\t \tblkid -s TYPE -s UUID -s LABEL -u filesystem | grep -v -E -e &quot;TYPE=\\&quot;.*_member\\&quot;&quot; -e &quot;TYPE=\\&quot;crypto_.*\\&quot;&quot; -e &quot;TYPE=\\&quot;swap\\&quot;&quot; | while IFS=$'' read -r _line; do \t\tIFS=$':' _t=($_line); \t\t_DEVNAME=${_t[0]} \t\t_UUID='' \t\t_TYPE='' \t\t_LABEL='' \t\t_MNT='' \t\tIFS=$' ' _t=(${_t[1]}); \t\tfor _a in &quot;${_t[@]}&quot;; do \t\t\tIFS=$'=' _v=(${_a}); \t\t\ttemp=&quot;${_v[1]%\\&quot;}&quot; \t\t\ttemp=&quot;${temp#\\&quot;}&quot; \t\t\tcase ${_v[0]} in \t\t\t\t'UUID') \t\t\t\t\t_UUID=$temp \t\t\t\t;; \t\t\t\t'TYPE') \t\t\t\t\t_TYPE=$temp \t\t\t\t;; \t\t\t\t'LABEL') \t\t\t\t\t_LABEL=$temp \t\t\t\t;; \t\t\tesac \t\tdone \t\tif [ ! -z &quot;$_F_FIELD&quot; ];then \t\t\tcase $_F_FIELD in \t\t\t\t'UUID') \t\t\t\t\t[ ! -z &quot;$_F_VALUE&quot; ] &amp;&amp; [ &quot;$_UUID&quot; != &quot;$_F_VALUE&quot; ] &amp;&amp; continue \t\t\t\t;; \t\t\t\t'LABEL') \t\t\t\t\t[ ! -z &quot;$_F_VALUE&quot; ] &amp;&amp; [ &quot;$_LABEL&quot; != &quot;$_F_VALUE&quot; ] &amp;&amp; continue \t\t\t\t;; \t\t\t\t*) \t\t\t\t\t[ &quot;$_DEVNAME&quot; != &quot;$_F_FIELD&quot; ] &amp;&amp; continue \t\t\t\t;; \t\t\tesac \t\tfi \t\t_MNT=$(findmnt -n -o TARGET $_DEVNAME) \t\tif [ -z &quot;$_MNT&quot; ]; then \t\t\t_MNT=${MNT_B}\/KEY-${_UUID} \t\t\tmkdir -p &quot;$_MNT&quot; &amp;&amp; mount -o ro &quot;$_DEVNAME&quot; &quot;$_MNT&quot; \t\t\t_RET=$? \t\telse \t\t\t_RET=0 \t\tfi \t\tif [ &quot;${_RET}&quot; -eq 0 ] &amp;&amp; [ -f &quot;${_MNT}\/${_KEY}&quot; ]; then \t\t\tcp &quot;${_MNT}\/${_KEY}&quot; &quot;$MNT_B\/${_UUID}.key&quot; \t\t\tinfo &quot;Found ${_MNT}\/${_KEY} on ${_UUID}&quot; \t\tfi \t\tif [[ &quot;${_MNT}&quot; =~ &quot;${MNT_B}&quot; ]]; then \t\t\tumount &quot;$_MNT&quot; &amp;&amp; rm -rfd --one-file-system &quot;$_MNT&quot;\t\t\t\t\t\t \t\tfi \tdone \treturn 0 } finding_luks_keys $KEY $F_FIELD $F_VALUE <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/usr\/lib\/dracut\/modules.d\/99luks-auto\/luks-auto.target<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> [Unit] Description=LUKS AUTO target After=systemd-readahead-collect.service systemd-readahead-replay.service After=cryptsetup-pre.target luks-auto-key.service Before=cryptsetup.target <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/usr\/lib\/dracut\/modules.d\/99luks-auto\/luks-auto.sh<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> #!\/bin\/sh # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh export DRACUT_SYSTEMD=1 . \/lib\/dracut-lib.sh  MNT_B=&quot;\/tmp\/luks-auto&quot; CRYPTSETUP='\/usr\/lib\/systemd\/systemd-cryptsetup'  for i in $(ls -p $MNT_B | grep -v \/);do \tinfo &quot;Trying $i on $1...&quot; \t$CRYPTSETUP attach &quot;luks-$1&quot; &quot;\/dev\/disk\/by-uuid\/$1&quot; $MNT_B\/$i 'tries=1' \tif [ &quot;$?&quot; -eq &quot;0&quot; ]; then \t\tinfo &quot;Found $i for $1&quot; \t\texit 0 \tfi done warn &quot;No key found for $1.  Fallback to passphrase mode.&quot; <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/usr\/lib\/dracut\/modules.d\/99luks-auto\/luks-auto-clean.service<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">[Unit] Description=LUKS AUTO key cleaner After=cryptsetup.target DefaultDependencies=no  [Service] Type=oneshot ExecStart=\/usr\/bin\/rm -rfd --one-file-system \/tmp\/luks-auto <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\/etc\/dracut.conf.d\/luks-auto.conf<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\">add_dracutmodules+=&quot; luks-auto &quot;<\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"bash\"> mkdir -p \/usr\/lib\/dracut\/modules.d\/99luks-auto\/ # \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u0442\u0443\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b chmod +x \/usr\/lib\/dracut\/modules.d\/99luks-auto\/*.sh # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b \/etc\/dracut.conf.d\/luks-auto.conf # \u0418 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0439 initramfs dracut -f <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u044f\u0434\u0440\u0430 \u043a\u0430\u043a \u0434\u043b\u044f \u0440\u0435\u0436\u0438\u043c\u0430 sysvinit, \u0447\u0442\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u0442\u0430\u0440\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043b\u044f\u0446\u0438\u044f.<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/504800\/\"> https:\/\/habr.com\/ru\/post\/504800\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504800\/\">\u0418\u0441\u0442\u043e\u0440\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u0434\u0430\u0432\u043d\u043e, \u0435\u0449\u0435 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 Centos 7 (RHEL 7). \u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u0434\u0438\u0441\u043a\u0430\u0445 \u0441 Centos 6, \u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0437\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439 \u0434\u0438\u0441\u043a\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 USB \u0444\u043b\u0435\u0448\u043a\u0438 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 7-\u043a\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0432\u0441\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u043a\u0430\u043a \u0432\u044b \u043f\u0440\u0438\u0432\u044b\u043a\u043b\u0438. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0435 dracut \u043a sysvinit \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0437\u0430\u043c\u044b\u0441\u043b\u043e\u0432\u0430\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435: echo &#8216;omit_dracutmodules+=&quot; systemd &quot;&#8217; &gt; \/etc\/dracut.conf.d\/luks-workaround.conf<br \/>  \u0427\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043b\u0438\u0448\u0430\u043b\u043e \u043d\u0430\u0441 \u0432\u0441\u0435\u0439 \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u0438 systemd \u2014 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0445 \u0441\u043b\u0443\u0436\u0431, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<br \/>  \u0412\u043e\u0437 \u0438 \u043d\u044b\u043d\u0435 \u0442\u0430\u043c: <a href=\"https:\/\/bugzilla.redhat.com\/show_bug.cgi?id=905683\" rel=\"nofollow\">905683<\/a><br \/>  \u041d\u0435 \u0434\u043e\u0436\u0434\u0430\u0432\u0448\u0438\u0441\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0435\u0433\u043e \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0441\u0430\u043c, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0435\u043b\u044e\u0441\u044c \u0438 \u0441 \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0434\u0430\u043b\u044c\u0448\u0435.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cr\/tt\/ao\/crttaomzbycjgrqscdpfeoejnuw.png\">  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-304649","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=304649"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304649\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}