Comment 1 for bug 800856

Revision history for this message
Scott Moser (smoser) wrote :

Serge,
  Is there a good way that I can determine if I'm in an lxc container so that I can decide not to try to resize the filesystem on '/' ?
  At http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/CloudConfig/cc_resizefs.py , cloud-init does:
    try:
       st_dev=os.stat("/").st_dev
       dev=os.makedev(os.major(st_dev),os.minor(st_dev))
       os.mknod(devpth, 0400 | stat.S_IFBLK, dev)
    except:
        log.warn("Failed to make device node to resize /")
        raise
Its using the os.stat / to get the major, minor, then does an mknod of that so that it has a known device node to work on (rather than guessing the path to /dev/root). Either way, right now the mknod is failing, but I'm guessing the subsequent resize would also fail in a typical lxc setup.

Any suggestions on how to decide not to attempt resize?