SHA256
1
0
forked from pool/growpart

- Support btrfs resize, handle ro setup in rootgrow (bsc#1097455, bsc#1098681)

OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/growpart?expand=0&rev=13
This commit is contained in:
Robert Schweikert 2018-06-21 20:30:50 +00:00 committed by Git OBS Bridge
parent d3bc1e687b
commit 65c21ad35b
2 changed files with 35 additions and 0 deletions

View File

@ -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

View File

@ -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: