Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 533084 - sys-kernel/dracut - dracut-initramfs-restore should mount separate /boot partition
Summary: sys-kernel/dracut - dracut-initramfs-restore should mount separate /boot part...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Amadeusz Żołnowski (RETIRED)
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2014-12-20 00:05 UTC by Garry Filakhtov
Modified: 2015-08-16 10:38 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
dracut mount /boot patch (dracut-mount-boot.patch,1007 bytes, patch)
2014-12-20 00:05 UTC, Garry Filakhtov
Details | Diff
Initramfs restore script with auto-umount functionality (dracut-initamfs-restore.sh.patch,963 bytes, patch)
2015-03-27 19:40 UTC, Garry Filakhtov
Details | Diff
New patch, using findmnt and ro mount option (dracut-initramfs-restore.sh.patch,879 bytes, patch)
2015-03-28 21:01 UTC, Garry Filakhtov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Garry Filakhtov 2014-12-20 00:05:41 UTC
Created attachment 392064 [details, diff]
dracut mount /boot patch

Dracut does not mount /boot partition if it is separated.

sys-kernel/dracut-040-r2 was built with the following:
USE="systemd -debug (-selinux)" ABI_X86="64"

Attached a patch to detect /boot mountpoint inside /etc/fstab and try to mount it. Check /proc/mounts before try mounting. This is very useful when /boot has noauto option.
Comment 1 Amadeusz Żołnowski (RETIRED) gentoo-dev 2015-03-25 09:51:43 UTC
Sorry, I've totally missed that bug report.

Is there any reason why you provide full path to `grep`, `egrep` and `mount` commands?
Comment 2 Garry Filakhtov 2015-03-25 20:36:20 UTC
No any specific reasons for that. Feel free to remove full paths.
Comment 3 Amadeusz Żołnowski (RETIRED) gentoo-dev 2015-03-26 07:46:39 UTC
Hm… why one would like to mount /boot at initramfs-time? Actually I mount boot only when I upgrade kernel or change something in Grub.
Comment 4 Garry Filakhtov 2015-03-26 20:04:24 UTC
Dracut has a special shutdown hook.
This hook is used to shutdown special devices like LVM and/or RAID arrays (both for me).

dracut-initramfs-restore script does unpacking content of initramfs inside the /run/initramfs folder and after shutdown systemd doing a pivot-root to this folder and running a shutdown script.

I have a noauto,nofail options set for /boot partition and this partition is not mounted automatically.
So then dracut-initramfs-restore script runs it fails to unpack initramfs and thus doing not clean shutdown.

That's why this fix is kinda good thing.
Comment 5 Alexander Tsoy 2015-03-27 13:57:32 UTC
Yeah, I'm aware of this bug. It forced me to remove noauto from fstab long time ago. :)

How about the following logic:

if findmnt -s -n --target=/boot &>/dev/null; then
    mountpoint -q /boot || mount /boot
fi
Comment 6 Alexander Tsoy 2015-03-27 14:01:03 UTC
But I'm not sure if /boot mount point will be correctly tracked by systemd and unmounted during shutdown.
Comment 7 Amadeusz Żołnowski (RETIRED) gentoo-dev 2015-03-27 14:45:28 UTC
/boot could me mounted read-only.

Igor, could you test Alexander suggestion (+ro) and possibly correct the patch?
Comment 8 Garry Filakhtov 2015-03-27 19:39:21 UTC
Ah.. I already use more recent version with umounting the /boot after unpacking initramfs. I'll add an attachment.
Comment 9 Garry Filakhtov 2015-03-27 19:40:11 UTC
Created attachment 399892 [details, diff]
Initramfs restore script with auto-umount functionality
Comment 10 Amadeusz Żołnowski (RETIRED) gentoo-dev 2015-03-28 13:45:01 UTC
Nice, you've added unmounting at the end. And what about findmnt usage suggested by Alexander? Could you also mount /boot with "ro" anyway? /boot is not supposed to be modified.
Comment 11 Garry Filakhtov 2015-03-28 21:01:22 UTC
Created attachment 399978 [details, diff]
New patch, using findmnt and ro mount option

I've attached a new patch. Right now using findmnt to find the mount source and mounting /boot in read-only mode.
Comment 12 Alexander Tsoy 2015-06-02 10:32:54 UTC
Harald commited fix for this bug:

http://git.kernel.org/cgit/boot/dracut/dracut.git/commit/?id=4f0c7fc91728a0c9aca211cbab5ae69bd08335d5
Comment 13 Alexander Tsoy 2015-07-15 17:38:15 UTC
Should be fixed in dracut-043
Comment 14 Alexander Tsoy 2015-07-28 11:41:26 UTC
Hmm.. Upstream solution have a bug:

set -e
...
mount -o ro /boot &>/dev/null

So if /boot is not a mount point or is already mounted, then script exits after unsuccessful mount command. :) I'll send upstream a fix.
Comment 16 Amadeusz Żołnowski (RETIRED) gentoo-dev 2015-08-16 10:38:14 UTC
Thank you guys!

commit 01f96bde83ab52f47cea0c0f9641e0528b87522e