Swap File Size improvements, style
This commit is contained in:
parent
9e9e73400b
commit
895acd1694
@ -8,7 +8,6 @@ confirmation() {
|
||||
|
||||
while :; do
|
||||
read -p "${message}" -n 1 -r choice
|
||||
echo $choice
|
||||
case "${choice}" in
|
||||
y | Y)
|
||||
return 0
|
||||
@ -150,7 +149,7 @@ get_available_disks() {
|
||||
ret_val="${ret_val} ${disk}"
|
||||
done
|
||||
|
||||
echo "${ret_val}"
|
||||
printf "%s\n" "${ret_val}"
|
||||
}
|
||||
|
||||
list_disks() {
|
||||
@ -161,19 +160,13 @@ list_disks() {
|
||||
count=0
|
||||
log "info" "Available disks"
|
||||
for disk in ${disks}; do
|
||||
echo " "${count}\.\) "${disk}"
|
||||
printf "%s\n" "${count}.)" "${disk}"
|
||||
count=$(( count + 1 ))
|
||||
done
|
||||
}
|
||||
|
||||
get_num_of_elems() {
|
||||
local count
|
||||
count=0
|
||||
for elem in ${1}; do
|
||||
count=$(( count + 1 ))
|
||||
done
|
||||
|
||||
echo "${count}"
|
||||
printf "%s" "${#count}"
|
||||
}
|
||||
|
||||
install() {
|
||||
@ -201,9 +194,9 @@ install() {
|
||||
valid_disk_selected=1
|
||||
while [[ "${valid_disk_selected}" != 0 ]]; do
|
||||
list_disks "${available_disks}"
|
||||
read -p "Select a disk number to install arch linux to: " disk_selected
|
||||
read -rp "Select a disk number to install arch linux to: " disk_selected
|
||||
|
||||
if ${disk_selected} -eq ${disk_selected} 2> /dev/null; then
|
||||
if "${disk_selected}" -eq "${disk_selected}" 2> /dev/null; then
|
||||
:
|
||||
else
|
||||
log "error" "A number was not passed"
|
||||
@ -272,11 +265,22 @@ install() {
|
||||
mount /dev/mapper/cryptroot /mnt
|
||||
mkdir /mnt/boot
|
||||
mount "${install_path}p1" /mnt/boot
|
||||
local mem_amount
|
||||
mem_amount="$(grep MemTotal /proc/meminfo | tr -s " " | cut -d " " -f2)"
|
||||
mem_amount=$(( mem_amount * 3/2 / 1000 ))
|
||||
log "info" "Creating swap file with memory amount: $(important "${mem_amount}") mebibytes"
|
||||
dd if=/dev/zero of=/mnt/swapfile bs=1M count="${mem_amount}" status=progress
|
||||
local mem_amount_kb
|
||||
mem_amount_kb="$(grep MemTotal /proc/meminfo | tr -s " " | cut -d " " -f2)"
|
||||
mem_amount_mb=$(( mem_amount_kb / 1024 ))
|
||||
|
||||
# Space to swap is taken from fedora guidelines:
|
||||
# https://docs.fedoraproject.org/en-US/Fedora/22/html/Installation_Guide/sect-installation-gui-manual-partitioning-recommended.html
|
||||
if (( mem_amount_mb < 2048 )); then
|
||||
mem_amount_kb=$(( mem_amount_kb * 3 / 1024 ))
|
||||
elif (( mem_amount_mb < 8192 )); then
|
||||
mem_amount_kb=$(( mem_amount_kb * 2 / 1024 ))
|
||||
elif (( mem_amount_mb < 65536 )); then
|
||||
mem_amount_kb=$((mem_amount_kb * 3/2 / 1024 ))
|
||||
fi
|
||||
|
||||
log "info" "Creating swap file with memory amount: $(important "${mem_amount_kb}") mebibytes"
|
||||
dd if=/dev/zero of=/mnt/swapfile bs=1M count="${mem_amount_kb}" status=progress
|
||||
chmod 600 /mnt/swapfile
|
||||
mkswap /mnt/swapfile
|
||||
swapon /mnt/swapfile
|
||||
@ -322,12 +326,12 @@ __EOF__
|
||||
systemctl enable NetworkManager
|
||||
__END_CHROOT_CMDS__
|
||||
log "info" "Next steps: update localities if incorrect, add your user, update the root password"
|
||||
log "info" "Notice default login is the following, username: $(important "root") password: $(important "toor")
|
||||
log "info" "Notice default login is the following, username: $(important "root") password: $(important "toor")"
|
||||
}
|
||||
|
||||
main() {
|
||||
install
|
||||
}
|
||||
|
||||
main "$@"
|
||||
main "${@}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user