302
# FIXME: this is currently run *after* /var/log/dist-upgrade/main.log
303
# is opened and its not in the aufs file
302
def _bindMount(self, from_dir, to_dir):
303
" helper that bind mounts a given dir to a new place "
304
if not os.path.exists(to_dir):
306
cmd = ["mount","--bind", from_dir, to_dir]
307
res = subprocess.call(cmd)
309
# FIXME: revert already mounted stuff
310
logging.error("Failed to bind mount from '%s' to '%s'" % (from_dir, to_dir))
314
def _aufsOverlayMount(self, target, rwdir):
316
helper that takes a target dir and mounts a rw dir over it, e.g.
317
/var , /tmp/upgrade-rw
319
if not os.path.exists(rw_dir+target):
320
os.makedirs(rw_dir+target)
323
"-o","br:%s:%s=ro" % (rw_dir+target, target),
326
res = subprocess.call(cmd)
328
# FIXME: revert already mounted stuff
329
logging.error("Failed to mount rw aufs overlay for '%s'" % target)
304
333
def setupAufs(self):
305
334
" setup aufs overlay "
335
# FIXME: this is currently run *after* /var/log/dist-upgrade/main.log
336
# is opened and its not in the aufs file
306
337
logging.debug("setupAufs")
338
rw_dir = self.aufs_rw_dir
339
# aufs mounts do not support stacked filesystems, so
340
# if we mount /var we will loose the tmpfs stuff
341
# first bind mount varun and varlock into the tmpfs
342
tmpfses = ["/var/run","/var/lock"]
344
if not self._bindMount(d, rw_dir+"/tmpfs/"+d):
307
346
# setup writable overlay into /tmp/upgrade-rw so that all
308
347
# changes are written there instead of the real fs
309
rw_dir = self.aufs_rw_dir
310
348
for d in ["/bin","/boot","/etc","/lib","/sbin","/usr","/var"]:
311
if not os.path.exists(rw_dir+d):
312
os.makedirs(rw_dir+d)
315
"-o","br:%s:%s=ro" % (rw_dir+d, d),
318
res = subprocess.call(cmd)
320
# FIXME: revert already mounted stuff
321
logging.error("Failed to mount %s with aufs" % d)
349
if not self._aufsOverlayMount(d, rw_dir):
351
# now bind back the tempfs to the original location
353
if not self._bindMount(rw_dir+"/tmpfs/"+d, d):
323
355
# FIXME: now what we *could* do to apply the changes is to
324
356
# mount -o bind / /orig