summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorRobert Schweikert <rjschwei@suse.com>2017-11-27 19:05:52 -0500
committerScott Moser <smoser@ubuntu.com>2018-01-24 09:52:58 -0500
commitb28ab78089d362c5c6cab985feee0f5f84c9db44 (patch)
tree85b0d7ecd54d7227d4526629ff9ca421bd9a29fc /cloudinit/config
parent8a9421421497b3e7c05589c62389745d565c6633 (diff)
downloadvyos-cloud-init-b28ab78089d362c5c6cab985feee0f5f84c9db44.tar.gz
vyos-cloud-init-b28ab78089d362c5c6cab985feee0f5f84c9db44.zip
btrfs: support resizing if root is mounted ro.
Resize of btrfs fails if the mount point for the file system we are trying to resize, i.e. the root of the filesystem is read only. With this change we use a known (currently snapper specific) rw location to work around a flaw that blocks resizing of the ro filesystem. LP: #1734787
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/cc_resizefs.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/cloudinit/config/cc_resizefs.py b/cloudinit/config/cc_resizefs.py
index 0d282e63..cec22bb7 100644
--- a/cloudinit/config/cc_resizefs.py
+++ b/cloudinit/config/cc_resizefs.py
@@ -59,7 +59,17 @@ __doc__ = get_schema_doc(schema) # Supplement python help()
def _resize_btrfs(mount_point, devpth):
- return ('btrfs', 'filesystem', 'resize', 'max', mount_point)
+ # If "/" is ro resize will fail. However it should be allowed since resize
+ # makes everything bigger and subvolumes that are not ro will benefit.
+ # Use a subvolume that is not ro to trick the resize operation to do the
+ # "right" thing. The use of ".snapshot" is specific to "snapper" a generic
+ # solution would be walk the subvolumes and find a rw mounted subvolume.
+ if (not util.mount_is_read_write(mount_point) and
+ os.path.isdir("%s/.snapshots" % mount_point)):
+ return ('btrfs', 'filesystem', 'resize', 'max',
+ '%s/.snapshots' % mount_point)
+ else:
+ return ('btrfs', 'filesystem', 'resize', 'max', mount_point)
def _resize_ext(mount_point, devpth):