mirror of
https://github.com/rocky-linux/rocky-tools.git
synced 2024-11-22 05:01:25 +00:00
Check available disk space before starting migration. (#136)
* Add disk space check
This commit is contained in:
parent
da2de96c9c
commit
a208a1ce0b
@ -172,6 +172,14 @@ stream_always_replace=(
|
|||||||
kernel-\*
|
kernel-\*
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Directory to required space in MiB
|
||||||
|
declare -A dir_space_map
|
||||||
|
dir_space_map=(
|
||||||
|
[/usr]=250
|
||||||
|
[/var]=1536
|
||||||
|
[/boot]=50
|
||||||
|
)
|
||||||
|
|
||||||
unset CDPATH
|
unset CDPATH
|
||||||
|
|
||||||
exit_message() {
|
exit_message() {
|
||||||
@ -251,6 +259,38 @@ pre_check () {
|
|||||||
'Migration from Uyuni/SUSE Manager-modified systems is not supported by '\
|
'Migration from Uyuni/SUSE Manager-modified systems is not supported by '\
|
||||||
'migrate2rocky. See the README file for details.'
|
'migrate2rocky. See the README file for details.'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get available space to compare to requirements.
|
||||||
|
# If the stock kernel is not installed we don't require space in /boot
|
||||||
|
if ! rpm -q --quiet kernel; then
|
||||||
|
dir_space_map[/boot]=0
|
||||||
|
fi
|
||||||
|
local -a errs dirs=("${!dir_space_map[@]}")
|
||||||
|
local dir mount avail i=0
|
||||||
|
local -A mount_avail_map dir_mount_map mount_space_map
|
||||||
|
while read -r mount avail; do
|
||||||
|
if [[ $mount == 'Filesystem' ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
dir=${dirs[$((i++))]}
|
||||||
|
|
||||||
|
dir_mount_map[$dir]=$mount
|
||||||
|
mount_avail_map[$mount]=${avail%M}
|
||||||
|
(( mount_space_map[$mount]+=dir_space_map[$dir] ))
|
||||||
|
done < <(df -BM --output=source,avail "${dirs[@]}")
|
||||||
|
|
||||||
|
for mount in "${!mount_space_map[@]}"; do
|
||||||
|
(( avail = mount_avail_map[$mount]*95/100 ))
|
||||||
|
if (( avail < mount_space_map[$mount] )); then
|
||||||
|
errs+=("Not enough space in $mount, ${mount_space_map[$mount]}M required, ${avail}M available.")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( ${#errs[@]} )); then
|
||||||
|
IFS=$'\n'
|
||||||
|
exit_message "${errs[*]}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# All of the binaries used by this script are available in a EL8 minimal install
|
# All of the binaries used by this script are available in a EL8 minimal install
|
||||||
@ -268,7 +308,7 @@ bin_check() {
|
|||||||
|
|
||||||
local -a missing bins
|
local -a missing bins
|
||||||
bins=(
|
bins=(
|
||||||
rpm dnf awk column tee tput mkdir cat arch sort uniq rmdir
|
rpm dnf awk column tee tput mkdir cat arch sort uniq rmdir df
|
||||||
rm head curl sha512sum mktemp systemd-detect-virt sed grep
|
rm head curl sha512sum mktemp systemd-detect-virt sed grep
|
||||||
)
|
)
|
||||||
if [[ $update_efi ]]; then
|
if [[ $update_efi ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user