cloud-init-dev team mailing list archive
-
cloud-init-dev team
-
Mailing list archive
-
Message #01843
[Merge] ~vorlon/cloud-init:master into cloud-init:master
Steve Langasek has proposed merging ~vorlon/cloud-init:master into cloud-init:master.
Requested reviews:
cloud init development team (cloud-init-dev)
For more details, see:
https://code.launchpad.net/~vorlon/cloud-init/+git/cloud-init/+merge/321245
When booted without an initramfs, the root device will be /dev/root, not a named device. There is partial support for this when resizing filesystems, but not for growing partitions, without which it doesn't do much good. Move the /dev/root resolution code to util.py and use it from cc_growpart.py.
Also, booting without an initramfs only works with a root= argument that's either a kernel device name (which is unstable) or a partition UUID. Handle the case of root=PARTUUID=value, not just LABEL and UUID.
--
Your team cloud init development team is requested to review the proposed merge of ~vorlon/cloud-init:master into cloud-init:master.
diff --git a/cloudinit/config/cc_growpart.py b/cloudinit/config/cc_growpart.py
index 832bb3f..089693e 100644
--- a/cloudinit/config/cc_growpart.py
+++ b/cloudinit/config/cc_growpart.py
@@ -247,7 +247,16 @@ def devent2dev(devent):
result = util.get_mount_info(devent)
if not result:
raise ValueError("Could not determine device of '%s' % dev_ent")
- return result[0]
+ dev = result[0]
+
+ container = util.is_container()
+
+ # Ensure the path is a block device.
+ if (dev == "/dev/root" and not os.path.exists(dev) and not container):
+ dev = util.rootdev_from_cmdline(util.get_cmdline())
+ if dev is None:
+ raise ValueError("Unable to find device '/dev/root'")
+ return dev
def resize_devices(resizer, devices):
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index e028abf..60e3ab5 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -71,25 +71,6 @@ 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]
@@ -121,7 +102,7 @@ def handle(name, cfg, _cloud, log, args):
# Ensure the path is a block device.
if (devpth == "/dev/root" and not os.path.exists(devpth) and
not container):
- devpth = rootdev_from_cmdline(util.get_cmdline())
+ devpth = util.rootdev_from_cmdline(util.get_cmdline())
if devpth is None:
log.warn("Unable to find device '/dev/root'")
return
diff --git a/cloudinit/util.py b/cloudinit/util.py
index 3301957..bb17e3b 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2382,4 +2382,26 @@ def indent(text, prefix):
return ''.join(lines)
+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="):]
+ if found.startswith("PARTUUID="):
+ cmd = ['blkid', '-l', '-t', found, '-o', 'device']
+ return subp(cmd, capture=True)[0].strip()
+
+ return "/dev/" + found
+
+
# vi: ts=4 expandtab
Follow ups