rwx/sh/rescue/ovh.sh
2024-11-29 19:53:27 +01:00

71 lines
1.8 KiB
Bash

rwx_rescue_wipe_0_init_ovh_vle2() {
local device="/dev/sdb"
local passphrase
# read passphrase
passphrase="$(rwx_read_passphrase)"
# warn
rwx_warn_wipe "${device}"
#
parted --script "${device}" \
mktable gpt \
unit "mib" \
mkpart "crypt" 4610 40959 \
mkpart "boot" 514 4610 \
mkpart "esp" 2 514 \
set 3 esp on \
mkpart bios 1 2 \
set 4 bios_grub on
# bios / wipe
rwx_fs_wipe "${device}4"
# esp / wipe
rwx_fs_wipe "${device}3" "1M"
# esp / format
rwx_fs_make_fat "${device}3" "esp" "00000001"
# esp / mount
mkdir --parents "/media/esp"
mount "${device}3" "/media/esp"
# boot / wipe
rwx_fs_wipe "${device}2" "1G" 1
# boot / format
rwx_fs_make_btrfs "${device}2" "boot" \
"00000000-0000-0000-0000-00000000000b"
# boot / mount
mkdir --parents "/media/boot"
mount --options "autodefrag,compress-force=zstd" \
"${device}2" "/media/boot"
# crypt / wipe
rwx_fs_wipe "${device}1" "1G" 1
# crypt / encrypt
rwx_fs_luks_format "${passphrase}" "${device}1"
# crypt / open
echo "${passphrase}" |
cryptsetup luksOpen "${device}1" "crypt"
# passphrase
unset passphrase
}
rwx_rescue_wipe_2_make_ovh_vle2() {
local device="/dev/sdb"
local passphrase
# crypt / close
cryptsetup luksClose "crypt"
# read passphrase
passphrase="$(rwx_read_passphrase)"
# crypt / encrypt
rwx_fs_luks_format "${passphrase}" "${device}1"
# crypt / open
echo "${passphrase}" |
cryptsetup luksOpen "${device}1" "crypt"
# passphrase
unset passphrase
# crypt / format
rwx_fs_make_btrfs "/dev/mapper/crypt" "crypt" \
"00000000-0000-0000-0000-00000000000c"
# crypt / mount
mkdir --parents "/media/crypt"
mount --options "autodefrag,compress-force=zstd" \
"/dev/mapper/crypt" "/media/crypt"
# crypt / swap
rwx_fs_make_btrfs_swap "/media/crypt/swap" "4g" \
"00000000-0000-0000-0000-000000000005"
}