Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have added the file /etc/initramfs-tools/etc/motd so that it would be available in /etc of the initramfs environment. However, it does not turn up. This is my second try where I gave the file all permissions available (I've also used 600):

root@cow:~# ls -l /etc/initramfs-tools/etc/
total 8
drwx------ 2 root root 4096 Sep 19 00:57 dropbear
-rwxrwxrwx 1 root root  117 Sep 29 15:32 motd

After that I sudo update-initramfs -u, boot into the initramfs environment and log in through SSH via Dropbear, and the file is still not there:

~ # ls -l /etc
total 20
-rw-------    1 root     0             4077 Sep 29 13:44 boottime.kmap.gz
drwx------    2 root     0                0 Sep 29 13:44 dropbear
-rw-r--r--    1 root     0             1991 Sep 29 13:44 ld.so.cache
-rw-r--r--    1 root     0               34 Sep 18 17:24 ld.so.conf
drwxr-xr-x    2 root     0                0 Sep 18 17:25 ld.so.conf.d
drwx------    2 root     0                0 Sep 29 13:44 lvm
drwx------    2 root     0                0 Sep 29 13:44 mdadm
drwx------    2 root     0                0 Sep 29 13:44 modprobe.d
-rw-------    1 root     0               15 Sep 29 13:44 nsswitch.conf
-rw-------    1 root     0               30 Sep 29 13:44 passwd
drwx------    2 root     0                0 Sep 29 13:44 udev

How should I add it? Why didn't the above way work?

share|improve this question
up vote 4 down vote accepted

You're placing your master-file in the wrong place. You want to use an initramfs hook.

Take a look beneath /usr/share/initramfs-tools/hooks there you'll see examples, but in brief you want to do something like:



          echo "$PREREQ"

  case $1 in
  # get pre-requisites
          exit 0

  . /usr/share/initramfs-tools/hook-functions
  mkdir -p ${DESTDIR}/etc/motd || true
  cp -pnL /etc/motd ${DESTDIR}/etc/motd
  chmod 644 ${DESTDIR}/etc/motd

Hope that helps.

Remember that hook script must be executable.

UPDATE: Also bear in mind that if your system is booted chances are the initramfs environment has been replaced by your root-filesystem. You should be able to verify what your initramfs image contains via cpio etc though.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.