diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py index 1d9f821bbd0..20e23296a4f 100644 --- a/cloudinit/config/cc_mounts.py +++ b/cloudinit/config/cc_mounts.py @@ -374,8 +374,9 @@ def parse_fstab() -> Tuple[List[str], Dict[str, str], List[str]]: fstab_removed.append(line) continue toks = line.split() - fstab_devs[toks[0]] = line - fstab_lines.append(line) + if toks: + fstab_devs[toks[0]] = line + fstab_lines.append(line) return fstab_lines, fstab_devs, fstab_removed diff --git a/tests/unittests/config/test_cc_mounts.py b/tests/unittests/config/test_cc_mounts.py index 7e85987b744..0e6d8379379 100644 --- a/tests/unittests/config/test_cc_mounts.py +++ b/tests/unittests/config/test_cc_mounts.py @@ -533,6 +533,7 @@ def test_fstab_mounts_combinations(self): "LABEL=keepme none ext4 defaults 0 0\n" "/dev/sda1 /a auto defaults,comment=cloudconfig 0 2\n" "LABEL=UEFI\n" + "\n" "/dev/sda2 /b auto defaults,comment=cloudconfig 0 2\n" ) with open(cc_mounts.FSTAB_PATH, "w") as fd: