# man > FINALRD(1)

[_FINALRD_(1)](https://www.chedong.com/phpMan.php/man/FINALRD/1/markdown)                                     finalrd                                    [_FINALRD_(1)](https://www.chedong.com/phpMan.php/man/FINALRD/1/markdown)

## NAME
       finalrd - final runtime directory generator for shutdown

## SYNOPSIS
        systemctl enable --now finalrd.service

## HOOKS DIRECTORIES
        /usr/share/finalrd/*.finalrd
        /etc/finalrd/*.finalrd
        /run/finalrd/*.finalrd

## HOOKS INTERFACE
        foo.finalrd setup
        foo.finalrd halt|poweroff|reboot|kexec

## DESCRIPTION
       **finalrd **generates a shutdown directory _/run/initramfs_ which **systemd-shutdown **pivots to during
       shutdown. There system shutdown can be finalised and arbitrary hooks can be executed off-
       root, to safely cleanup rootfs and perform any other shutdown tasks.

       For example, a hook may takeover monitoring external metadata RAID arrays, wait for them to
       be clean, and stop them. If one is using iscsiroot, it maybe needed to perform iscsi logout
       on shutdown.

       Typically, one would not run **finalrd **directly, but instead activate **finalrd.service**. This
       would execute **finalrd **generator late in the shutdown cycle, just in time for pivot.

## HOOKLESS OPERATION
       If initramfs-tools is not available, and thus copy_exec is not available, hooks will not be
       executed or copied into the shutdown directory. However, shutdown dir will still be created
       to ensure init has somewhere to pivot, and attempt a cleaner shutdown without holding up the
       root filesystem.

       For example, Ubuntu Core is such system.

## HOOKS INTERFACE DESCRIPTION
       _*.finalrd_ hooks can be shipped in _/usr_, _/etc_, _/run_. These directories are for distribution,
       sysadmin, and transient hooks respectively.

       They are multi-purpose binaries with action passed as the first argument.

       During setup stage, hooks are executed from the rootfs with one argument **setup **passed as the
       first arg. All hooks are executed in all the directories in order, first everything in _/usr_,
       then from _/etc_, then from _/run_. Environmental variables _DESTDIR_ and _DESTROOTDIR_ are set
       pointing at the finalrd location. This is done for convenience to use _initramfs-tools_'s
       copy_exec function or dracut-install, for copying binaries.

       During shutdown stage, hooks are executed from finalrd in parallel with one argument passed
       to them. The argument is one of **halt**, **poweroff**, **reboot**, **kexec**.

       Note if there are identically named hooks in multiple configuration directories, all of them
       will be executed during setup stage. But only the last one will be copied into the finalrd
       and executed during the shutdown stage.

## SEE ALSO
       The initrd Interface of systemd
       <<https://www.freedesktop.org/wiki/Software/systemd/InitrdInterface>>

finalrd 2                                                                                 [_FINALRD_(1)](https://www.chedong.com/phpMan.php/man/FINALRD/1/markdown)
