summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorGonéri Le Bouder <goneri@lebouder.net>2019-05-28 15:39:48 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-05-28 15:39:48 +0000
commit6197c347c3960254dbcdb28eb73989d062ad9689 (patch)
tree047c3e31145795baddafa19ac36ec503add14523 /cloudinit
parent0f8695323262e41c699588c7cd140f6b58c62017 (diff)
downloadvyos-cloud-init-6197c347c3960254dbcdb28eb73989d062ad9689.tar.gz
vyos-cloud-init-6197c347c3960254dbcdb28eb73989d062ad9689.zip
freebsd: ability to grow root file system
- UFS file system support - GPT partition table support - add support for newfs's -L parameter (label) - move freebsd specific test from Azure to freebsd
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_growpart.py3
-rw-r--r--cloudinit/config/cc_resizefs.py6
-rw-r--r--cloudinit/util.py22
3 files changed, 18 insertions, 13 deletions
diff --git a/cloudinit/config/cc_growpart.py b/cloudinit/config/cc_growpart.py
index bafca9d8..564f376f 100644
--- a/cloudinit/config/cc_growpart.py
+++ b/cloudinit/config/cc_growpart.py
@@ -215,7 +215,8 @@ def device_part_info(devpath):
# FreeBSD doesn't know of sysfs so just get everything we need from
# the device, like /dev/vtbd0p2.
if util.is_FreeBSD():
- m = re.search('^(/dev/.+)p([0-9])$', devpath)
+ freebsd_part = "/dev/" + util.find_freebsd_part(devpath)
+ m = re.search('^(/dev/.+)p([0-9])$', freebsd_part)
return (m.group(1), m.group(2))
if not os.path.exists(syspath):
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index 076b9d5a..afd2e060 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -81,7 +81,7 @@ def _resize_xfs(mount_point, devpth):
def _resize_ufs(mount_point, devpth):
- return ('growfs', '-y', devpth)
+ return ('growfs', '-y', mount_point)
def _resize_zfs(mount_point, devpth):
@@ -101,7 +101,7 @@ def _can_skip_resize_ufs(mount_point, devpth):
"""
# dumpfs -m /
# newfs command for / (/dev/label/rootfs)
- newfs -O 2 -U -a 4 -b 32768 -d 32768 -e 4096 -f 4096 -g 16384
+ newfs -L rootf -O 2 -U -a 4 -b 32768 -d 32768 -e 4096 -f 4096 -g 16384
-h 64 -i 8192 -j -k 6408 -m 8 -o time -s 58719232 /dev/label/rootf
"""
cur_fs_sz = None
@@ -110,7 +110,7 @@ def _can_skip_resize_ufs(mount_point, devpth):
for line in dumpfs_res.splitlines():
if not line.startswith('#'):
newfs_cmd = shlex.split(line)
- opt_value = 'O:Ua:s:b:d:e:f:g:h:i:jk:m:o:'
+ opt_value = 'O:Ua:s:b:d:e:f:g:h:i:jk:m:o:L:'
optlist, _args = getopt.getopt(newfs_cmd[1:], opt_value)
for o, a in optlist:
if o == "-s":
diff --git a/cloudinit/util.py b/cloudinit/util.py
index ea4199cd..aa23b3f3 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2337,17 +2337,21 @@ def parse_mtab(path):
return None
-def find_freebsd_part(label_part):
- if label_part.startswith("/dev/label/"):
- target_label = label_part[5:]
- (label_part, _err) = subp(['glabel', 'status', '-s'])
- for labels in label_part.split("\n"):
+def find_freebsd_part(fs):
+ splitted = fs.split('/')
+ if len(splitted) == 3:
+ return splitted[2]
+ elif splitted[2] in ['label', 'gpt', 'ufs']:
+ target_label = fs[5:]
+ (part, _err) = subp(['glabel', 'status', '-s'])
+ for labels in part.split("\n"):
items = labels.split()
- if len(items) > 0 and items[0].startswith(target_label):
- label_part = items[2]
+ if len(items) > 0 and items[0] == target_label:
+ part = items[2]
break
- label_part = str(label_part)
- return label_part
+ return str(part)
+ else:
+ LOG.warning("Unexpected input in find_freebsd_part: %s", fs)
def get_path_dev_freebsd(path, mnt_list):