From: Plom Heller Date: Mon, 31 Aug 2026 21:58:32 +0000 (+0200) Subject: Add swapping! X-Git-Url: https://plomlompom.com/repos/booking/%22https:/validator.w3.org/todos?a=commitdiff_plain;h=27885eff3fc06d35c80658df3d3126b649d767ca;p=confplom Add swapping! --- diff --git a/_lib.sh b/_lib.sh index 94e5288..2e24cc7 100644 --- a/_lib.sh +++ b/_lib.sh @@ -8,6 +8,7 @@ TO_RBIND="${NAME_DEV} proc sys" # constants we might want to change at some point NAME_DATA=data +NAME_SWAP=swap PATH_MNT=/mnt/debinst # path constructors @@ -139,6 +140,13 @@ unmount_unrbind() { chroot_sh() { LANG=C.UTF-8 chroot "${PATH_MNT}" /bin/sh -c "$@" } +create_lv() { + local VG=$1 + local LV=$2 + local SIZE=$3 + msg 'Creating logical volume "%s" inside volume group …' "${LV}" + lvcreate -L "${SIZE}" -n "${LV}" "${VG}" +} usage() { local COUNT_INPUTS=$1 shift diff --git a/install_debian.sh b/install_debian.sh index ba73dae..c212aef 100755 --- a/install_debian.sh +++ b/install_debian.sh @@ -32,6 +32,7 @@ PATH_MNT_NM_CONNECTIONS="${PATH_MNT}${PATH_NM_CONNECTIONS}" PATH_VG=$(path_vg "${NAME_LUKSVG}") PATH_VG_DATA=${PATH_VG}/${NAME_DATA} PATH_VG_ROOT=${PATH_VG}/${NAME_ROOT} +PATH_VG_SWAP=${PATH_VG}/${NAME_SWAP} # sanity checks check_tools cryptsetup debootstrap efibootmgr lvcreate mkfs.ext4 vgs @@ -54,8 +55,7 @@ msg '- name for new boot option: [ %s ]' "${NAME_BOOT}" # set up logival volume and filesystem open_luksvg "${PARTITION}" "${NAME_LUKSVG}" -msg 'Creating logical volume "%s" there …' "${NAME_ROOT}" -lvcreate -L '10G' -n "${NAME_ROOT}" "${NAME_LUKSVG}" +create_lv "${NAME_LUKSVG}" "${NAME_ROOT}" 10G await_path "${PATH_VG_ROOT}" msg 'Creating EXT4 filesystem …' mkfs.ext4 -q "${PATH_VG_ROOT}" @@ -68,10 +68,11 @@ rbind_mnt # set up minimal fstab msg 'Writing fstab …' -printf '%s / ext4 errors=remount-ro 0 1\n' "${PATH_VG_ROOT}"\ - >| "${PATH_MNT_FSTAB}" -printf '%s /data ext4 errors=remount-ro 0 2\n' "${PATH_VG_DATA}"\ - >> "${PATH_MNT_FSTAB}" +cat <| "${PATH_MNT_FSTAB}" +${PATH_VG_ROOT} / ext4 errors=remount-ro 0 1 +${PATH_VG_DATA} /${NAME_DATA} ext4 errors=remount-ro 0 2 +${PATH_VG_SWAP} none swap sw 0 0 +EOF # set up crypttab msg 'Writing crypttab …' diff --git a/make_luksvg.sh b/make_luksvg.sh index 674e0b9..8db13dc 100755 --- a/make_luksvg.sh +++ b/make_luksvg.sh @@ -8,10 +8,12 @@ NAME_LUKSVG=$2 # constants derived from changeables PATH_LUKS_MAPPER=$(path_luks_mapper "${NAME_LUKSVG}") -PATH_VG_DATA=$(path_vg "${NAME_LUKSVG}")/${NAME_DATA} +PATH_VG=$(path_vg "${NAME_LUKSVG}") +PATH_VG_DATA=${PATH_VG}/${NAME_DATA} +PATH_VG_SWAP=${PATH_VG}/${NAME_SWAP} # sanity checks -check_tools cryptsetup lvcreate mkfs.ext4 pvcreate vgcreate vgs +check_tools cryptsetup lvcreate mkfs.ext4 mkswap pvcreate vgcreate vgs check_input_partition_mountable "${PARTITION}" check_input_new_luksvg "${NAME_LUKSVG}" try_quiet cryptsetup isLuks "${PARTITION}"\ @@ -30,12 +32,13 @@ msg 'Formatting %s as LUKS container …' "${PARTITION}" cryptsetup luksFormat --batch-mode "${PARTITION}" open_luksvg "${PARTITION}" "${NAME_LUKSVG}" -# set up LVM and filesystem +# set up LVM and filesystems msg 'Creating volume group "%s" inside LUKS container …' "${NAME_LUKSVG}" vgcreate "${NAME_LUKSVG}" "${PATH_LUKS_MAPPER}" - -msg 'Creating logical volume "%s" inside volume group …' "${NAME_DATA}" -lvcreate -L '256G' -n "${NAME_DATA}" "${NAME_LUKSVG}" +create_lv "${NAME_LUKSVG}" "${NAME_SWAP}" 64G +msg 'Configuring as swap area …' +mkswap "${PATH_VG_SWAP}" +create_lv "${NAME_LUKSVG}" "${NAME_DATA}" 256G msg 'Creating EXT4 filesystem …' mkfs.ext4 -q "${PATH_VG_DATA}"