initramfs-tools  has  one  main  script  and two different sets of sub-
       scripts which will be used during different phases of  execution.  Each
       of  these will be discussed separately below with the help of an imagi-
       nary tool which performs a frobnication of a  lvm  partition  prior  to
       mounting the root partition.

Kernel Command Line
       The  root filesystem used by the kernel is specified by the boot loader
       as always. The traditional root=/dev/sda1 style device specification is
       allowed.  If a label is used, as in root=LABEL=rootPart the initrd will
       search all available devices for  a  filesystem  with  the  appropriate
       label,  and  mount that device as the root filesystem.  root=UUID=uuid-
       number will mount the partition with that UUID as the root filesystem.

        init= "<path to real init>"
              the binary to hand over execution to on the root  fs  after  the
              initramfs scripts are done.

        root= "<path to blockdevice>"
              the  device  node  to mount as the root file system.  The recom-
              mended usage is to specify the UUID as followed "root=UUID=xxx".

              set the root file system type.

              set delay in seconds. Determines how long  mountroot  waits  for
              root to appear.  The default is 180 seconds.

              set the file system mount option string.

        loop= "<path to image>"
              path  within the original root file system to loop-mount and use
              as the real root file system.

              set the loop file system type, if applicable.

              set the loop file system mount option string, if applicable.
              details. Optional parameter for NFS root.

              is a mac address in pxelinux format with leading "01-"  and  "-"
              as  separations.   pxelinux  passes  mac address of network card
              used to PXE boot on with this bootarg.

        boot  either local or NFS (affects which initramfs  scripts  are  run,
              see the "Subdirectories" section under boot scripts).

              On install initramfs-tools tries to autodetect the resume parti-
              tion.  On  success   the   RESUME   variable   is   written   to
              /etc/initramfs-tools/conf.d/resume.   The boot variable noresume
              overrides it.

              Specify the offset from the  partition  given  by  "resume="  at
              which the swap header of the swap file is located.

        quiet reduces the amount of text output to the console during boot.

        ro    mounts the rootfs read-only.

        rw    mounts the rootfs read-write.

              disables  load  of specific modules.  Use blacklist=module1,mod-
              ule2,module3 bootparameter.

        panic sets an timeout on panic.  panic=<sec> is a documented  security
              feature: it disables the debug shell.

        debug generates    lots    of    output.    It   writes   a   log   to
              /run/initramfs/initramfs.debug.  Instead when  invoked  with  an
              arbitrary  argument output is written to console.  Use for exam-
              ple "debug=vc".

        break spawns a shell in the initramfs image at chosen  run-time  (top,
              modules, premount, mount, mountroot, bottom, init).  The default
              is premount without any arg.  Beware that if  both  "panic"  and
              "break"  are  present,  initramfs  will not spawn any shells but

       Valid boot and hook scripts names consist solely of alphabetics, numer-
       ics, dashes and underscores. Other scripts are discarded.

   Hook scripts
       These  are  used when an initramfs image is created and not included in
       the image itself. They can however cause files to be  included  in  the
       image.  Hook scripts are executed under errexit. Thus a hook script can
       abort the mkinitramfs build on possible errors (exitcode != 0).

   Boot scripts
       These are included in the initramfs image and normally executed  during
       kernel  boot in the early user-space before the root partition has been

       Hooks can be found in two places: /usr/share/initramfs-tools/hooks  and
       /etc/initramfs-tools/hooks.  They are executed during generation of the
       initramfs-image and are responsible for  including  all  the  necessary
       components  in the image itself. No guarantees are made as to the order
       in which the different scripts are executed unless the prereqs are set-
       up in the script.

       In  order to support prereqs, each script should begin with the follow-
       ing lines:

                   echo "$PREREQ"

              case $1 in
                   exit 0

              . /usr/share/initramfs-tools/hook-functions
              # Begin real processing below this line

       For example, if you are writing a new hook script which relies on  lvm,
       the  line  starting with PREREQ should be changed to PREREQ="lvm" which
       will ensure that the lvm hook script is run before your custom script.

   Help functions
       /usr/share/initramfs-tools/hook-functions contains a  number  of  func-
              the module.

              Example: add_modules_from_file /tmp/modlist

              force_load adds a module (and its dependencies) to the initramfs
              image  and  also  unconditionally  loads the module during boot.
              Also supports passing arguments to the module  by  listing  them
              after the module name.

              Example: force_load cdrom debug=1

              copy_modules_dir   copies   an   entire  module  directory  from
              /lib/modules/KERNELVERSION/ into the initramfs image.

              Example: copy_modules_dir kernel/drivers/ata

   Including binaries
       If you need to copy binaries to the initramfs module,  a  command  like
       this should be used:

              copy_exec /sbin/mdadm /sbin

       mkinitramfs  will  automatically  detect which libraries the executable
       depends on and copy them to the initramfs. This means  that  most  exe-
       cutables,  unless compiled with klibc, will automatically include glibc
       in the image which will increase its size by several hundred kilobytes.

   Exported variables
       mkinitramfs sets several variables for the hook scripts environment.

              corresponds to the linux-2.6 modules dir.

              is the $(uname -r) linux-2.6 version against mkinitramfs is run.

              is the path of the used initramfs-tools configurations.

              is the root path of the newly build initramfs.

              allows arch specific hook additions.

              corresponds to the verbosity of the update-initramfs run.


       Like for hook scripts, there are no guarantees as to the order in which
       the different scripts in one subdirectory (see "Subdirectories"  below)
       are  executed.  In order to define a certain order, a similar header as
       for hook scripts should be used:

                   echo "$PREREQ"

              case $1 in
                   exit 0

       Where PREREQ is modified to list other scripts in the same subdirectory
       if necessary.

   Help functions
       A number of functions (mostly dealing with output) are provided to boot
       scripts in /scripts/functions :

              log_success_msg Logs a success message

              Example: log_success_msg "Frobnication successful"

              log_failure_msg Logs a failure message

              Example: log_failure_msg "Frobnication component froobz missing"

              log_warning_msg Logs a warning message

              Example: log_warning_msg "Only partial frobnication possible"

              log_begin_msg Logs a message that some processing step has begun

              log_end_msg Logs a message that some processing step is finished


                     log_begin_msg "Frobnication begun"
                     # Do something

              examples directory for more information.

              Example: add_mountroot_fail_hook

       Both     /usr/share/initramfs-tools/scripts     and     /etc/initramfs-
       tools/scripts contains the following subdirectories.

              init-top  the scripts in this directory are the first scripts to
              be executed after sysfs and procfs have been mounted.   It  also
              runs  the udev hook for populating the /dev tree (udev will keep
              running until init-bottom).

              init-premount happens  after  modules  specified  by  hooks  and
              /etc/initramfs-tools/modules have been loaded.

              local-top OR nfs-top After these scripts have been executed, the
              root device node is expected to be present (local) or  the  net-
              work interface is expected to be usable (NFS).

              local-premount  OR  nfs-premount are run after the sanity of the
              root device has been verified (local) or the  network  interface
              has  been  brought  up  (NFS), but before the actual root fs has
              been mounted.

              local-bottom OR nfs-bottom are run after  the  rootfs  has  been
              mounted (local) or the NFS root share has been mounted.

              init-bottom  are  the  last scripts to be executed before procfs
              and sysfs are moved to the real rootfs and execution  is  turned
              over to the init binary which should now be found in the mounted
              rootfs. udev is stopped.

   Boot parameters
              /conf/param.conf allows boot scripts to  change  exported  vari-
              ables  that  are  listed on top of init. Write the new values to
              it. It will be sourced after an boot script run if it exists.

   Hook script
       An example hook script would look something like this (and  would  usu-
       ally be placed in /etc/initramfs-tools/hooks/frobnicate):


              . /usr/share/initramfs-tools/hook-functions
              # Begin real processing below this line

              if [ ! -x "/sbin/frobnicate" ]; then
                   exit 0

              force_load frobnicator interval=10
              cp /sbin/frobnicate "${DESTDIR}/sbin"
              exit 0

   Boot script
       An  example  boot script would look something like this (and would usu-
       ally be placed in /etc/initramfs-tools/scripts/local-top/frobnicate):

              # Example frobnication boot script

                   echo "$PREREQ"

              case $1 in
                   exit 0

              . /scripts/functions
              # Begin real processing below this line
              if [ ! -x "/sbin/frobnicate" ]; then
                   panic "Frobnication executable not found"

              if [ ! -e "/dev/mapper/frobb" ]; then
                   panic "Frobnication device not found"

              log_begin_msg "Starting frobnication"
              /sbin/frobnicate "/dev/mapper/frobb" || panic "Frobnication failed"

              exit 0

   Exported variables
       init sets several variables for the boot scripts environment.

        blacklist, panic, quiet, resume, noresume, resume_offset
              set according relevant boot option.

        break Useful  for  manual intervention during setup and coding an boot

              Argument passed to the panic helper function.  Use to  find  out
              why you landed in the initramfs shell.

        init  passes the path to init(8) usually /sbin/init.

              is  the  default  for  mounting  the  root corresponds to the ro
              bootarg.  Overridden by rw bootarg.

              is the path where root gets mounted usually /root.

        debug indicates that a debug log is captured  for  further  investiga-

       It  is  easy  to check the generated initramfs for its content. One may
       need to double-check if it contains the relevant binaries, libs or mod-
              mkdir tmp/initramfs
              cd tmp/initramfs
              gunzip -c /boot/initrd.img-2.6.18-1-686 | \
              cpio -i -d -H newc --no-absolute-filenames

       The initramfs-tools are written by Maximilian Attems <>,
       Jeff Bailey <> and numerous others.

       This manual was written by David  Hardeman <>, updated
       by Maximilian Attems <>.

        initramfs.conf(5), mkinitramfs(8), update-initramfs(8).

Linux                             2010/09/23                INITRAMFS-TOOLS(8)
Man Pages Copyright Respective Owners. Site Copyright (C) 1994 - 2017 Hurricane Electric. All Rights Reserved.