[anaconda] Create and use free space snapshot for swap suggestion (#1132436)

Vratislav Podzimek vpodzime at redhat.com
Fri Aug 29 07:14:38 UTC 2014


On Thu, 2014-08-28 at 16:49 -0700, Brian C. Lane wrote:
> On Thu, Aug 28, 2014 at 05:54:26PM +0200, Vratislav Podzimek wrote:
> > Otherwise when creating swap on an LV there's no free space on the disk by that
> > time, because it is occupied by the LV's VG's PV.
> 
>  was confused by 'snapshot' at first, thinking it was related to LVM
>  snapshots :) Maybe say - "snapshot free space before partitioning" or
>  something like that.
That's a good point, thanks!

> 
> 
> > 
> > Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> > ---
> >  pyanaconda/kickstart.py | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
> > index 95252a7..fc180ae 100644
> > --- a/pyanaconda/kickstart.py
> > +++ b/pyanaconda/kickstart.py
> > @@ -210,7 +210,7 @@ def getAvailableDiskSpace(storage):
> >      """
> >  
> >  
> > -    free_space = storage.getFreeSpace()
> > +    free_space = storage.freeSpaceSnapshot
> >      return int(sum(disk_free.convertTo("MiB") for disk_free, fs_free in free_space.values()))
> >  
> >  def refreshAutoSwapSize(storage):
> > @@ -749,6 +749,7 @@ class LogVolData(commands.logvol.F20_LogVolData):
> >          vgname = ksdata.onPart.get(self.vgname, self.vgname)
> >  
> >          if self.mountpoint == "swap":
> > +            import pdb; pdb.set_trace()
> 
> That's going to make things way more interactive than we want :p
Ups, fixing locally.

> 
> 
> >              type = "swap"
> >              self.mountpoint = ""
> >              if self.recommended or self.hibernation:
> > @@ -1778,6 +1779,10 @@ def doKickstartStorage(storage, ksdata, instClass):
> >      if not any(d for d in storage.disks
> >                 if not d.format.hidden and not d.protected):
> >          return
> > +
> > +    # snapshot free space now so that we know how much we had avaiable
> > +    storage.createFreeSpaceSnapshot()
> > +
> 
> Does this work correctly with the multitude of partitioning schemes? eg.
> What if there are pre-existing partitions but clearpart --all is used in
> the kickstart?
That's why it happens after the ksdata.clearpart.execute() call.

Another solution for the issue would be to get the free space from
blivet and store it in a variable passed to
ksdata.autopart/logvol/part.execute() calls, but I think that the
snapshot stored in blivet is more elegant and may come handy to other
users of blivet as well.

-- 
Vratislav Podzimek

Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic




More information about the anaconda-patches mailing list