Created
May 26, 2022 22:46
-
-
Save gmariette/9e35b22e4051766318cdf6afaea5c2a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_main_disk(fs): | |
disk_to_extend = subprocess.check_output('lsblk -l | grep -B1 ' + fs + ' | head -1 | awk \'{print $1}\'', shell=True).strip().decode('ascii') | |
return disk_to_extend | |
def extend_disk(fs): | |
disk_to_extend = get_main_disk(fs) | |
try: | |
print(f'Extending disk {disk_to_extend}') | |
disk_entend = subprocess.check_output(f'sudo growpart /dev/{disk_to_extend} 1', shell=True).strip().decode('ascii') | |
print(disk_entend) | |
return True | |
except Exception as e: | |
print(f'Unable to extend the disk, exception: {e}') | |
return False | |
def extend_partition(fs): | |
try: | |
print(f'Extending partition {fs}') | |
partition_entend = subprocess.check_output(f'sudo xfs_growfs -d {fs}', shell=True).decode('ascii') | |
print(partition_entend) | |
return True | |
except Exception as e: | |
print(f'Unable to extend partition, exception: {e}') | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment