@@ -77,6 +77,9 @@ command line and determine if ZFS is the active root filesystem.
77
77
* ` mount-zfs.sh ` : Run later in initramfs boot process after udev has settled
78
78
to mount the root dataset.
79
79
80
+ * ` export-zfs.sh ` : Run on shutdown after dracut has restored the initramfs
81
+ and pivoted to it, allowing for a clean unmount and export of the ZFS root.
82
+
80
83
` module-setup.sh `
81
84
---------------
82
85
@@ -164,3 +167,25 @@ import can lead to serious data corruption and loss of pools, so this option
164
167
should be used with extreme caution. Note that even with this flag set, if
165
168
the required zpool was auto-imported by the kernel module, no additional
166
169
` zpool import ` commands are run, so nothing is forced.
170
+
171
+ ` export-zfs.sh `
172
+ -------------
173
+
174
+ Normally the zpool containing the root dataset cannot be exported on
175
+ shutdown as it is still in use by the init process. To work around this,
176
+ Dracut is able to restore the initramfs on shutdown and pivot to it.
177
+ All remaining process are then running from a ramdisk, allowing for a
178
+ clean unmount and export of the ZFS root. The theory of operation is
179
+ described in detail in the [ Dracut manual] ( https://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html#_dracut_on_shutdown ) .
180
+
181
+ This script will try to export all remaining zpools after Dracut has
182
+ pivoted to the initramfs. If an initial regular export is not successful,
183
+ Dracut will call this script once more with the ` final ` option,
184
+ in which case a forceful export is attempted.
185
+
186
+ Other Dracut modules include similar shutdown scripts and Dracut
187
+ invokes these scripts round-robin until they succeed. In particular,
188
+ the ` 90dm ` module installs a script which tries to close and remove
189
+ all device mapper targets. Thus, if there are ZVOLs containing
190
+ dm-crypt volumes or if the zpool itself is backed by a dm-crypt
191
+ volume, the shutdown scripts will try to untangle this.
0 commit comments