Re: Automounting of the root partition in the initramfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 17, 2013 at 10:32:11AM +0200, Juerg Haefliger wrote:
> >> >> All,
> >> >>
> >> >> The (admittedly hacky) dracut-modules-growroot package installs a
> >> >> dracut script that runs in the pre-pivot stage. It unmounts the root
> >> >> partition, extends it to the maximum possible size and then tries to
> >> >> remount it. What I noticed in F20 is that as soon as the
> >> >> repartitioning finishes (its an sfdisk command), something
> >> >> automatically remounts the root partition and the growroot script
> >> >> fails when it tries to mount the already mounted partition.
> >> >>
> >> >> Can somebody shed some light on what is happening and why the root
> >> >> partition is automatically remounted and if I can rely on that and not
> >> >> have the growroot script try to remount it?
> >> >>
> >> >> Thanks
> >> >> ...Juerg
> >> >>
> >> >
> >> > Oh, that is systemd, because it generates a unit file from the kernel command
> >> > line called sysroot.mount, which is required by the following systemd targets.
> >>
> >> Is there an easy way to wait until this (remounting of root) has
> >> happened or do I need to poll and time out?
> >
> > Yes. A unit with Requires=sysroot.mount, After=sysroot.mount will be started
> > only after /sysroot has been mounted.
> >
> > But it looks like the resize script should run *before* the automatic
> > mounting.  If the script is made into a Type=oneshot unit, adding
> > Before=sysroot.mount will delay mounting until the unit has finished.
> >
> > I'm not sure though, what's the best way to make sure that it is run
> > after the root device has been detected, unless the root device name
> > is known in advance. If it is, Requires=<device>.device, After=<device>.device
> > should be added.
> 
> Agreed, the script should probably run prior to root being mounted.
> I'm not familiar with systemd and this is too drastic of a change I
> want to make at this point. So is it possible for a script to wait
> until a systemd event has happened?
Well, ordering using Before= and After= is how systemd services are
scheduled. There's no fixed order, things that are on the list of
things to start are fired as soon as possible, i.e. after dependencies
are satisfied. Since dracut uses systemd, I don't think you have a
different choice, then to use a unit.

I still think that resizing before mounting seems cleaner, but if you
want the unit to run after root has been mounted, it is actually simpler
to write... Something like that should work:

[Unit]
Requires=sysroot.mount
After=sysroot.mount

[Service]
ExecStart=...

[Install]
WantedBy=initrd.target

See http://www.freedesktop.org/software/systemd/man/bootup.html
for a nice explanation of how this all ties together.

Zbyszek
-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux