diff options
author | pico.dev <pico.dev@gmail.com> | 2020-06-19 19:55:44 +0200 |
---|---|---|
committer | pico.dev <pico.dev@gmail.com> | 2020-06-19 19:55:44 +0200 |
commit | cb667c5fef418c42ccecd0c9f55dec7f54635a01 (patch) | |
tree | 86e0719951de360153586b3d1c2185e79e5d29cb | |
parent | aa0c1ab0de12137c40c1d03d076357efbbefb620 (diff) |
Refactor the swapfile creation based on the wiki commands
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | alis.conf | 5 | ||||
-rw-r--r-- | alis.sh | 24 |
3 files changed, 19 insertions, 13 deletions
@@ -31,7 +31,6 @@ For new features, improvements and bugs fill an issue in GitHub or make a pull r * Encryption: root partition encrypted and no encrypted * Partition: no LVM, LVM, LVM on LUKS, GPT on UEFI, MBR on BIOS * File system: ext4, btrfs (with subvols), xfs -* Optional file swap (not supported in btrfs) * Storage: SATA, NVMe and MMC * Kernels: linux-lts, linux-hardened, linux-zen * Desktop environment: GNOME, KDE, XFCE, Mate, Cinnamon, LXDE @@ -41,7 +40,7 @@ For new features, improvements and bugs fill an issue in GitHub or make a pull r * WPA WIFI network installation * Periodic TRIM for SSD storage * Intel and AMD processors microcode -* Optional file swap (not supported in btrfs) +* Optional swap file * VirtualBox guest utils * Kernel compression and custom parameters * Users creation and add to sudoers @@ -2,6 +2,9 @@ # # Some values are preceded by a ! character, this means that the value is ignored. # Some keys accept a single value others accept multiple values as annotated in the comments. +# +# Read the Arch Linux wiki pages to learn more about the variables values. +# https://github.com/picodotdev/alis/blob/master/README.md # init KEYS="es" @@ -14,7 +17,7 @@ LVM="true" # true if use LVM for partitioning LUKS_PASSWORD="archlinux" # LUKS encryption key, if LVM will be user LVM on LUKS. Empty for not use LUKS/encryption. Warning: change it! LUKS_PASSWORD_RETYPE="archlinux" FILE_SYSTEM_TYPE="ext4 !btrfs !xfs" # (single) -SWAP_SIZE="!2GiB !4GiB !8GiB" # (single) +SWAP_SIZE="!2048 !4096 !8192" # (single, in megabytes) PARTITION_MODE="auto !custom !manual" PARTITION_CUSTOM_PARTED_UEFI="mklabel gpt mkpart primary fat32 1MiB 512MiB mkpart primary $FILE_SYSTEM_TYPE 512MiB 100% set 1 boot" PARTITION_CUSTOM_PARTED_BIOS="mklabel msdos mkpart primary ext4 4MiB 512MiB mkpart primary $FILE_SYSTEM_TYPE 512MiB 100% set 1 boot on" @@ -51,7 +51,7 @@ DEVICE_LVM="" LUKS_DEVICE_NAME="cryptroot" LVM_VOLUME_GROUP="vg" LVM_VOLUME_LOGICAL="root" -SWAPFILE="" +SWAPFILE="/swapfile" BOOT_DIRECTORY="" ESP_DIRECTORY="" #PARTITION_BOOT_NUMBER=0 @@ -520,13 +520,17 @@ function partition() { fi # swap - # btrfs: https://btrfs.wiki.kernel.org/index.php/FAQ#Does_btrfs_support_swap_files.3F - # btrfs: https://wiki.archlinux.org/index.php/Btrfs#Disabling_CoW - # btrfs: https://jlk.fjfi.cvut.cz/arch/manpages/man/btrfs.5#MOUNT_OPTIONS - if [ -n "$SWAP_SIZE" -a "$FILE_SYSTEM_TYPE" != "btrfs" ]; then - fallocate -l $SWAP_SIZE "/mnt/swapfile" - chmod 600 "/mnt/swapfile" - mkswap "/mnt/swapfile" + if [ -n "$SWAP_SIZE" ]; then + if [ "$FILE_SYSTEM_TYPE" == "btrfs" ]; then + truncate -s 0 /mnt$SWAPFILE + chattr +C /mnt$SWAPFILE + btrfs property set /mnt$SWAPFILE compression none + fi + + dd if=/dev/zero of=/mnt$SWAPFILE bs=1M count=$SWAP_SIZE status=progress + chmod 600 /mnt$SWAPFILE + mkswap /mnt$SWAPFILE + swapon /mnt$SWAPFILE fi # set variables @@ -567,9 +571,9 @@ function configuration() { genfstab -U /mnt >> /mnt/etc/fstab - if [ -n "$SWAP_SIZE" -a "$FILE_SYSTEM_TYPE" != "btrfs" ]; then + if [ -n "$SWAP_SIZE" ]; then echo "# swap" >> /mnt/etc/fstab - echo "/swapfile none swap defaults 0 0" >> /mnt/etc/fstab + echo "$SWAPFILE none swap defaults 0 0" >> /mnt/etc/fstab echo "" >> /mnt/etc/fstab fi |