Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initramfs hook zfsunlock creates initramfs /usr/bin as as file and not directory #10434

Closed
IslandLife opened this issue Jun 10, 2020 · 3 comments
Labels
Status: Stale No recent activity for issue Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@IslandLife
Copy link

IslandLife commented Jun 10, 2020

System information

Type Version/Name
Distribution Name Ubuntu
Linux Kernel 4.4.0-184-generic
Architecture x86_64
ZFS Version 0.8.0-823_gdd4bc56
SPL Version

Describe the problem you're observing

After installing zfs 0.8.0 #823 (current at 10 June 2020) and applying a kernel update the step to rebuild initramfs failed
the hook zfs would complain that /usr/bin was not a directory so
cp to /usr/bin/dirname or env or net would all fail.

Putting this debug temporarily into the zfs hook

for ii in $COPY_EXEC_LIST
do
        dir=$(dirname "$ii")
        if  [ -d "$DESTDIR/$dir" ]
        then
            echo "INFO: OK directory $DESTDIR/$dir exists"
        elif  [ -f "$DESTDIR/$dir" ]
        then
            echo "WARNING: $DESTDIR/$dir exists - but is a file"
            ls -ld  "$DESTDIR/$dir"
            head "$DESTDIR/$dir"
        elif  [ -e "$DESTDIR/$dir" ]
        then
            echo "WARNING: $DESTDIR/$dir exists - but is not a directory"
            ls -ld  "$DESTDIR/$dir"
        elif  [ ! -d "$DESTDIR/$dir" ]
        then
          mkdir -p "$DESTDIR/$dir"
          mkdir_status=$?
          if [ $mkdir_status -ne 0 ]
          then
            echo "WARNING: bad status $mkdir_status for mkdir -p $DESTDIR/$dir"
          else
            echo "INFO OK status $mkdir_status for mkdir -p $DESTDIR/$dir"
          fi
        fi
        if  [ -d "$DESTDIR/$dir" ]
        then
          copy_exec "$ii"
        else
          echo "WARNING: skipping copy_exec $ii"
        fi
done


From the 'ls -ld' output fromn that debug output I figured out the file /usr/bin was in fact a copy of zfsunlock

Changing zfsunlock hook from

copy_exec /usr/share/initramfs-tools/zfsunlock /usr/bin

to

copy_exec /usr/share/initramfs-tools/zfsunlock /usr/bin/

i.e. adding a trailing / character fixed the problem and I was able to build the initramfs

Describe how to reproduce the problem

Include any warning/errors/backtraces from the system logs

An example is provided below.

root# update-initramfs -c -k all
update-initramfs: Generating /boot/initrd.img-4.4.0-179-generic
mkdir: cannot create directory ‘/var/tmp/mkinitramfs_evCFJO//usr/bin’: File exists
cp: failed to access '/var/tmp/mkinitramfs_evCFJO//usr/bin/dirname': Not a directory
mkdir: cannot create directory ‘/var/tmp/mkinitramfs_evCFJO//usr/bin’: File exists
cp: failed to access '/var/tmp/mkinitramfs_evCFJO//usr/bin/env': Not a directory
mkdir: cannot create directory ‘/var/tmp/mkinitramfs_evCFJO/usr/bin’: File exists
touch: cannot touch '/var/tmp/mkinitramfs_evCFJO/usr/bin/net': Not a directory
chmod: cannot access '/var/tmp/mkinitramfs_evCFJO/usr/bin/net': Not a directory
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
^C



While I see this on Ubuntu xenial I don't see it on Ubuntu focal

@behlendorf behlendorf added the Type: Defect Incorrect behavior (e.g. crash, hang) label Jun 10, 2020
@behlendorf
Copy link
Contributor

@IslandLife would you mind opening a PR with the proposed fix.

IslandLife added a commit to IslandLife/zfs that referenced this issue Jun 12, 2020
…mpting subsequent copy

Ref: initramfs hook zfsunlock creates initramfs /usr/bin as as file and not directory openzfs#10434

Modeled on the similar mkdir statement for inirtramfs /etc in the hook zfs
@nabijaczleweli
Copy link
Contributor

Closable? Seems to've been fixed by #11162

@stale
Copy link

stale bot commented May 25, 2022

This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale No recent activity for issue label May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale No recent activity for issue Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

3 participants