start adding SWAP file support

This commit is contained in:
Tobias Powalowski 2024-06-06 07:31:31 +02:00
parent 1442571382
commit a637c09827

View file

@ -445,28 +445,30 @@ _mkfs() {
_MOUNTOPTIONS=""
if [[ "${2}" == "swap" ]]; then
swapoff -a &>"${_NO_LOG}"
if [[ -n "${4}" ]]; then
if echo "${1}" | grep -q '^/dev'; then
mkswap -L "${6}" "${1}" &>"${_LOG}"
_SWAP="${1}"
else
mkswap "${7}" "${3}"/"${1}" &>"${_LOG}"
_SWAP="${3}"/"${1}"
fi
if [[ -n "${4}" ]]; then
if echo "${1}" | grep -q '^/dev'; then
mkswap -L "${6}" ${_SWAP} &>"${_LOG}"
else
mkswap "${7}" "${_SWAP}" &>"${_LOG}"
fi
sleep 2
#shellcheck disable=SC2181
if [[ $? != 0 ]]; then
_dialog --title " ERROR " --no-mouse --infobox "Creating swap: mkswap ${1}" 0 0
_dialog --title " ERROR " --no-mouse --infobox "Creating swap: mkswap ${_SWAP}" 0 0
sleep 5
return 1
fi
fi
if echo "${1}" | grep -q '^/dev'; then
swapon "${1}" &>"${_LOG}"
else
swapon "${3}"/"${1}" &>"${_LOG}"
fi
swapon "${_SWAP}" &>"${_LOG}"
#shellcheck disable=SC2181
if [[ $? != 0 ]]; then
_dialog --title " ERROR " --no-mouse --infobox "Activating swap: swapon ${1}" 0 0
_dialog --title " ERROR " --no-mouse --infobox "Activating swap: swapon ${_SWAP}" 0 0
sleep 5
return 1
fi