summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-01-22 16:54:07 -0500
committerScott Moser <smoser@ubuntu.com>2014-01-22 16:54:07 -0500
commit84514cdff8ff025df052fe6301d2a7ed751d7d61 (patch)
treee2a550842d404c4709537122364fd668089259c3
parente26ac6b63072f3217de2fc9214584e61682cd211 (diff)
downloadvyos-cloud-init-84514cdff8ff025df052fe6301d2a7ed751d7d61.tar.gz
vyos-cloud-init-84514cdff8ff025df052fe6301d2a7ed751d7d61.zip
cc_resizefs: figure out what /dev/root means via kernel cmdline
If mount_info says that the root filesystem is on /dev/root and /dev/root does not exist, then we'll try to glean that information from the linux kernel cmdline. This situation occurs at least when you boot without an initramfs for the current ppc64el cloud images: qemu-system-ppc64 ... -kernel my.kernel -append 'root=/dev/sda' When doing that, /proc/1/mountinfo will say '/dev/root' for '/'.
-rw-r--r--ChangeLog2
-rw-r--r--cloudinit/config/cc_resizefs.py33
2 files changed, 33 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index cb9586f0..32f2a8d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,8 @@
- drop dependency on boto for crawling ec2 metadata service.
- add 'Requires' on sudo (for OpenNebula datasource) in rpm specs, and
'Recommends' in the debian/control.in [Vlastimil Holer]
+ - if mount_info reports /dev/root is a device path for /, then convert
+ that to a device via help of kernel cmdline.
0.7.4:
- fix issue mounting 'ephemeral0' if ephemeral0 was an alias for a
partitioned block device with target filesystem on ephemeral0.1.
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index 56040fdd..388ca66f 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -51,6 +51,25 @@ RESIZE_FS_PREFIXES_CMDS = [
NOBLOCK = "noblock"
+def rootdev_from_cmdline(cmdline):
+ found = None
+ for tok in cmdline.split():
+ if tok.startswith("root="):
+ found = tok[5:]
+ break
+ if found is None:
+ return None
+
+ if found.startswith("/dev/"):
+ return found
+ if found.startswith("LABEL="):
+ return "/dev/disk/by-label/" + found[len("LABEL="):]
+ if found.startswith("UUID="):
+ return "/dev/disk/by-uuid/" + found[len("UUID="):]
+
+ return "/dev/" + found
+
+
def handle(name, cfg, _cloud, log, args):
if len(args) != 0:
resize_root = args[0]
@@ -78,10 +97,20 @@ def handle(name, cfg, _cloud, log, args):
info = "dev=%s mnt_point=%s path=%s" % (devpth, mount_point, resize_what)
log.debug("resize_info: %s" % info)
+ container = util.is_container()
+
+ if (devpth == "/dev/root" and not os.path.exists(devpth) and
+ not container):
+ devpth = rootdev_from_cmdline(util.get_cmdline())
+ if devpth is None:
+ log.warn("Unable to find device '/dev/root'")
+ return
+ log.debug("Converted /dev/root to '%s' per kernel cmdline", devpth)
+
try:
statret = os.stat(devpth)
except OSError as exc:
- if util.is_container() and exc.errno == errno.ENOENT:
+ if container and exc.errno == errno.ENOENT:
log.debug("Device '%s' did not exist in container. "
"cannot resize: %s" % (devpth, info))
elif exc.errno == errno.ENOENT:
@@ -92,7 +121,7 @@ def handle(name, cfg, _cloud, log, args):
return
if not stat.S_ISBLK(statret.st_mode):
- if util.is_container():
+ if container:
log.debug("device '%s' not a block device in container."
" cannot resize: %s" % (devpth, info))
else: