Skip to content
This repository was archived by the owner on Jul 13, 2021. It is now read-only.

Commit cd23544

Browse files
authored
Merge pull request #19 from upgrades-migrations/check_free_space
Check for sufficient space in /boot
2 parents 6393419 + c9f661a commit cd23544

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Diff for: redhat-upgrade-tool.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from redhat_upgrade_tool.util import call, check_call, rm_f, mkdir_p, rlistdir
2929
from redhat_upgrade_tool.download import UpgradeDownloader, YumBaseError, yum_plugin_for_exc, URLGrabError
3030
from redhat_upgrade_tool.sysprep import prep_upgrade, prep_boot, setup_media_mount, setup_cleanup_post, disable_old_repos, Config
31-
from redhat_upgrade_tool.sysprep import modify_repos, remove_cache
31+
from redhat_upgrade_tool.sysprep import modify_repos, remove_cache, reset_boot
3232
from redhat_upgrade_tool.boot import upgrade_boot_args
3333
from redhat_upgrade_tool.upgrade import RPMUpgrade, TransactionError
3434

@@ -38,6 +38,8 @@
3838
from redhat_upgrade_tool import rhel_gpgkey_path
3939
from redhat_upgrade_tool import preupgrade_script_path
4040
from redhat_upgrade_tool import release_version_file
41+
from redhat_upgrade_tool import _, kernelpath, initrdpath
42+
from redhat_upgrade_tool import MIN_AVAIL_BYTES_FOR_BOOT
4143

4244
import redhat_upgrade_tool.logutils as logutils
4345
import redhat_upgrade_tool.media as media
@@ -51,7 +53,6 @@ def message(m):
5153
print m
5254
log.info(m)
5355

54-
from redhat_upgrade_tool import _, kernelpath, initrdpath
5556

5657
def setup_downloader(version, instrepo=None, cacheonly=False, repos=[],
5758
enable_plugins=[], disable_plugins=[], noverifyssl=False):
@@ -365,6 +366,18 @@ def handle_sigwinch(signum, frame):
365366
upgrade_boot_args()
366367
prep_boot(kernel, initrd)
367368

369+
# Check for available space in /boot/ needed for kernel and grub
370+
# installation during the upgrade.
371+
statvfs = os.statvfs("/boot")
372+
avail_bytes = statvfs.f_frsize * statvfs.f_bavail
373+
if avail_bytes < MIN_AVAIL_BYTES_FOR_BOOT:
374+
reset_boot()
375+
additional_mib_needed = \
376+
(MIN_AVAIL_BYTES_FOR_BOOT - avail_bytes) / 2**20
377+
sys.stderr.write(_("Not enough space. /boot/ needs additional %d MiB"
378+
".\n") % additional_mib_needed)
379+
raise SystemExit(1)
380+
368381
# Replace temporary media paths
369382
modify_repos(args)
370383

Diff for: redhat_upgrade_tool/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@
6868
preupgrade_script_path = os.path.join(preupgrade_dir, 'preupgrade-scripts')
6969
release_version_file = os.path.join(preupgrade_dir, preupgrade_script_path, 'release_version')
7070
grub_conf_file = "/boot/grub/grub.conf"
71+
72+
MIN_AVAIL_BYTES_FOR_BOOT = 50 * 2**20 # 50 MiB

Diff for: redhat_upgrade_tool/download.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,11 @@ def checkfile(cb):
454454
cacheinitrd = os.path.join(cachedir, os.path.basename(initrdpath))
455455
initrd = grab_and_check(arch, 'upgrade', cacheinitrd)
456456
# copy the downloaded initrd to the target path
457-
copy2(initrd, initrdpath)
457+
try:
458+
copy2(initrd, initrdpath)
459+
except IOError as e:
460+
print _("Copying initrd to '%s' failed:\n%s") % (initrdpath, e)
461+
raise SystemExit(1)
458462
initrd = initrdpath
459463
except TreeinfoError as e:
460464
raise YumBaseError(_("invalid data in .treeinfo: %s") % str(e))

0 commit comments

Comments
 (0)