Accepting request 618484 from Cloud:Tools
- Support btrfs resize, handle ro setup in rootgrow (bsc#1097455, bsc#1098681) OBS-URL: https://build.opensuse.org/request/show/618484 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/growpart?expand=0&rev=6
This commit is contained in:
commit
491d8102b5
@ -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
|
Wed Apr 4 11:41:23 CEST 2018 - kukuk@suse.de
|
||||||
|
|
||||||
|
30
rootgrow
30
rootgrow
@ -11,6 +11,13 @@ def get_mount_point(device):
|
|||||||
if mount.startswith(device):
|
if mount.startswith(device):
|
||||||
return mount.split(' ')[1]
|
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):
|
def resize_fs(fs_type, device):
|
||||||
if fs_type.startswith('ext'):
|
if fs_type.startswith('ext'):
|
||||||
cmd = 'resize2fs %s' % device
|
cmd = 'resize2fs %s' % device
|
||||||
@ -27,6 +34,29 @@ def resize_fs(fs_type, device):
|
|||||||
'Resizing: "%s"' %cmd
|
'Resizing: "%s"' %cmd
|
||||||
)
|
)
|
||||||
os.system(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:
|
for mount in mounts:
|
||||||
|
Loading…
Reference in New Issue
Block a user