New backup 2025-07-25 14:45:06
This commit is contained in:
parent
cedf37d3d7
commit
6567f9f4a9
1 changed files with 26 additions and 7 deletions
|
@ -1,23 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "this is not yet done!"
|
||||
echo "Currently it does not add swap to /etc/fstab or /etc/crypttab"
|
||||
exit 1
|
||||
#echo "this is not yet done!"
|
||||
#echo "Currently it does not add swap to /etc/fstab or /etc/crypttab"
|
||||
#exit 1
|
||||
if [[ "$(whoami)" == "root" ]];then
|
||||
echo "[-] running as root, continuing...\n"
|
||||
else
|
||||
printf "[!] Run this script as root!\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -p '[?] keyfile path [/etc/crypttab.d/swap_key]: ' keyfile_dest
|
||||
keyfile_dest=${keyfile_dest:-/etc/crypttab.d/swap_key}
|
||||
read -p '[?] swap partition name [swap_crypt]: ' part_name
|
||||
part_name=${part_name:-swap_crypt}
|
||||
read -p '[?] partition password: ' part_pass
|
||||
read -p '[?] partition password (input hidden): ' -s part_pass
|
||||
while [[ -z "${part_pass}" ]]; do
|
||||
printf '[!] empty password\n'
|
||||
read -p '[?] partition password: ' part_pass
|
||||
read -p '[?] partition password (input hidden): ' -s part_pass
|
||||
done
|
||||
|
||||
#printf '\n'
|
||||
#lsblk -o NAME,SIZE,FSTYPE
|
||||
lsblk -o PATH,SIZE,FSTYPE
|
||||
read -p '[?] encrypted swap device:' swap_blk_dev
|
||||
read -p '[?] encrypted swap device: ' swap_blk_dev
|
||||
while [[ ! "$(file ${swap_blk_dev})" == *'block'* ]]; do
|
||||
printf '[!] bad encrypted swap device\n'
|
||||
read -p '[?] encrypted swap device: ' swap_blk_dev
|
||||
|
@ -39,7 +45,7 @@ case "${proceed_confirm}" in
|
|||
;;
|
||||
esac
|
||||
|
||||
exit
|
||||
#exit
|
||||
|
||||
printf '[-] Writing keyfile...\n'
|
||||
mkdir -p "$(dirname ${keyfile_dest})"
|
||||
|
@ -62,3 +68,16 @@ cryptsetup luksOpen "${swap_blk_dev}" "${part_name}" --key-file "${keyfile_dest}
|
|||
|
||||
printf '[-] Creating swap inside encrypted partition\n'
|
||||
mkswap "/dev/mapper/${part_name}"
|
||||
|
||||
crypt_uuid=$(lsblk -rno UUID "${swap_blk_dev}")
|
||||
|
||||
printf '[!] Finished. Follow the instructions below to complete setup.\n\n'
|
||||
printf '[-] 1. Add the following line to your /etc/crypttab file:\n\n'
|
||||
printf 'swap_crypt UUID=%s /etc/crypttab.d/swap_key luks,swap,discard\n\n' "${crypt_uuid}"
|
||||
printf '[-] 1a. if a similar crypttab entry previously existed, remove it from the crypttab file\n'
|
||||
printf '[-] 2. If it does not already exist, add the following line to your /etc/fstab file:\n'
|
||||
printf '/dev/mapper/%s none swap sw 0 0\n' "${part_name}"
|
||||
printf '[-] 3. run the following command to enable the swap partition for the current session:\n'
|
||||
printf 'sudo swapon -a\n'
|
||||
printf '[-] 4. run the following command to regenerate your initial ramdisk:\n\n'
|
||||
printf 'sudo update-initramfs -u -k all\n\n'
|
||||
|
|
Loading…
Add table
Reference in a new issue