From abc08d2101ae2c4ccc222bdf3e9ea0dcba4c95fc Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Sat, 4 May 2024 20:59:38 -0600 Subject: [PATCH] feat(disk_setup): Add support for nvme devices (#5263) Fixes GH-5246 --- cloudinit/config/cc_disk_setup.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cloudinit/config/cc_disk_setup.py b/cloudinit/config/cc_disk_setup.py index 0b324696896..2c03d920e32 100644 --- a/cloudinit/config/cc_disk_setup.py +++ b/cloudinit/config/cc_disk_setup.py @@ -10,6 +10,7 @@ import logging import os import shlex +from pathlib import Path from textwrap import dedent from cloudinit import subp, util @@ -908,7 +909,15 @@ def mkfs(fs_cfg): if not partition or partition.isdigit(): # Handle manual definition of partition if partition.isdigit(): + # nvme support + # https://github.com/torvalds/linux/blob/45db3ab/block/partitions + # /core.c#L330 + if device[-1].isdigit(): + device = f"{device}p" device = "%s%s" % (device, partition) + if not Path(device).is_block_device(): + LOG.warning("Path %s does not exist or is not a block device") + return LOG.debug( "Manual request of partition %s for %s", partition, device )