diff --git a/growpart.changes b/growpart.changes index 449a1b6..7dc1e79 100644 --- a/growpart.changes +++ b/growpart.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Jun 21 20:28:16 UTC 2018 - rjschwei@suse.com + +- Support btrfs resize, handle ro setup in rootgrow (bsc#1097455, bsc#1098681) + ------------------------------------------------------------------- Wed Apr 4 11:41:23 CEST 2018 - kukuk@suse.de diff --git a/rootgrow b/rootgrow index 5497c9e..eda6e6a 100644 --- a/rootgrow +++ b/rootgrow @@ -11,6 +11,13 @@ def get_mount_point(device): if mount.startswith(device): return mount.split(' ')[1] +def is_mount_read_only(mountpoint): + for mount in mounts: + mount_values = mount.split(' ') + if mount_values[1] == mountpoint: + mount_opts = mount_values[3].split(',') + return 'ro' in mount_opts + def resize_fs(fs_type, device): if fs_type.startswith('ext'): cmd = 'resize2fs %s' % device @@ -27,6 +34,29 @@ def resize_fs(fs_type, device): 'Resizing: "%s"' %cmd ) os.system(cmd) + elif fs_type == 'btrfs': + mnt_point = get_mount_point(device) + # If the volume is read-only, the resize operation will fail even + # though it's still probably wanted to do the resize. A feasible + # work-around is to use snapper's .snapshots subdir (if exists) + # instead of the volume path for the resize operation. + if is_mount_read_only(mnt_point): + if os.path.isdir('{}/.snapshots'.format(mnt_point)): + cmd = 'btrfs filesystem resize max {}/.snapshots'.format( + mnt_point) + else: + syslog.syslog( + syslog.LOG_ERR, + "cannot resize read-only btrfs without snapshots" + ) + return + else: + cmd = 'btrfs filesystem resize max {}'.format(mnt_point) + syslog.syslog( + syslog.LOG_INFO, + 'Resizing: "%s"' %cmd + ) + os.system(cmd) for mount in mounts: