2021-03-11 14:04:04 +01:00
|
|
|
|
module start "disk" "Partition disk"
|
2021-03-12 19:40:59 +01:00
|
|
|
|
if ! yesno "nun gehts los, sicher?" n; then
|
|
|
|
|
exit
|
|
|
|
|
fi
|
2021-03-11 14:04:04 +01:00
|
|
|
|
|
|
|
|
|
source "${var}"
|
|
|
|
|
|
|
|
|
|
#umounter "${dest}" || exit
|
|
|
|
|
|
|
|
|
|
if [[ ! "${cfg[fde_key_store]}" == "none" ]]; then
|
|
|
|
|
addpkg cryptsetup
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
diskid="${cfg[diskid]//-/_}"
|
|
|
|
|
if [[ -n "${cfg[wipe]}" ]]; then
|
|
|
|
|
echo "Formatting disk"
|
|
|
|
|
echo "o
|
|
|
|
|
w
|
|
|
|
|
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [[ "${cfg[fde_key_store]}" == "once" ]]; then
|
|
|
|
|
echo "create bootpartition"
|
|
|
|
|
target_boot="${cfg[diskname]}1"
|
|
|
|
|
echo "n
|
|
|
|
|
p
|
|
|
|
|
1
|
|
|
|
|
|
|
|
|
|
+${cfg[bootsize]}G
|
|
|
|
|
a
|
|
|
|
|
w
|
|
|
|
|
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
|
|
|
|
|
if [[ "${cfg[rootfssize]}" == "rest" ]]; then
|
|
|
|
|
target_partition_tmp="${cfg[diskname]}2"
|
|
|
|
|
echo "create rootfs"
|
|
|
|
|
echo "n
|
|
|
|
|
p
|
|
|
|
|
2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w
|
|
|
|
|
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
|
|
|
|
|
elif [[ ! "${cfg[rootfssize]}" == "rest" ]]; then
|
|
|
|
|
target_partition_tmp="${cfg[diskname]}2"
|
|
|
|
|
echo "create rootfs with a specific size"
|
|
|
|
|
echo "n
|
|
|
|
|
p
|
|
|
|
|
2
|
|
|
|
|
|
|
|
|
|
+${rootfssize}G
|
|
|
|
|
w
|
|
|
|
|
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
if [[ "${cfg[rootfssize]}" == "rest" ]]; then
|
|
|
|
|
target_partition_tmp="${cfg[diskname]}1"
|
|
|
|
|
echo "create rootfs without boot"
|
|
|
|
|
echo "n
|
|
|
|
|
p
|
|
|
|
|
1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
a
|
|
|
|
|
w
|
|
|
|
|
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
|
|
|
|
|
elif [[ ! "${cfg[rootfssize]}" == "rest" ]]; then
|
|
|
|
|
target_partition_tmp="${cfg[diskname]}1"
|
|
|
|
|
echo "create rootfs with a specific size without boot"
|
|
|
|
|
echo "n
|
|
|
|
|
p
|
|
|
|
|
1
|
|
|
|
|
|
|
|
|
|
+${rootfssize}G
|
|
|
|
|
a
|
|
|
|
|
w
|
|
|
|
|
q" | fdisk "${cfg[diskname]}" 2>1 > /dev/null
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
target_partition="${target_partition_tmp}"
|
|
|
|
|
if [[ ! "${fde_key_store}" == "none" ]]; then
|
|
|
|
|
echo -n "${cfg[diskpw]}" | cryptsetup luksFormat --type luks1 "${target_partition}" -d -
|
|
|
|
|
echo -n "${cfg[diskpw]}" | cryptsetup luksOpen "${target_partition}" "voidluks-${diskid}" -d -
|
|
|
|
|
target_partition="/dev/mapper/voidluks-${diskid}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vgcreate -q -f "voidvg.${diskid}" "${target_partition}" || exit 1
|
|
|
|
|
lvcreate -q -y --name swap -L "${cfg[swapsize]}"G "voidvg.${diskid}"
|
|
|
|
|
lvcreate -q -y --name root -l 100%FREE "voidvg.${diskid}"
|
|
|
|
|
mkfs.btrfs -q -f "/dev/mapper/voidvg.${diskid}-root"
|
|
|
|
|
mkswap "/dev/mapper/voidvg.${diskid}-swap"
|
|
|
|
|
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"
|
|
|
|
|
btrfs subvol create "${dest}/void-rootfs"
|
|
|
|
|
btrfs subvol create "${dest}/home"
|
|
|
|
|
umount "${dest}"
|
|
|
|
|
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}" -o subvol=void-rootfs
|
|
|
|
|
for i in boot home dev proc sys tmp etc var/lib/backup var/db; do mkdir -p "${dest}/${i}"; done
|
|
|
|
|
mount "/dev/mapper/voidvg.${diskid}-root" "${dest}"/home -o subvol=home
|
|
|
|
|
if [[ "${cfg[fde_key_store]}" == "once" ]]; then
|
|
|
|
|
mkfs.btrfs -q -f "${target_boot}"
|
|
|
|
|
mount "${target_boot}" "${dest}/boot"
|
|
|
|
|
fi
|
|
|
|
|
for dir in dev proc sys run; do mkdir -p "${dest}"/$dir ; mount --rbind /$dir "${dest}"/$dir ; mount --make-rslave "${dest}"/$dir ; done
|
|
|
|
|
|
|
|
|
|
setconf add rootuuid "$(blkid -o value -s UUID ${target_partition})"
|
|
|
|
|
setconf add partuuid "$(blkid -o value -s UUID ${cfg[diskname]}${cfg[target_part]})"
|
|
|
|
|
[[ "${cfg[fde_key_store]}" == "once" ]] && setconf "add" "bootuuid" "$(blkid -o value -s UUID ${target_boot})"
|
|
|
|
|
setconf add swapuuid "$(blkid -o value -s UUID /dev/mapper/voidvg.${diskid}-swap)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mount -t tmpfs -o size=512m tmpfs "${dest}"/tmp
|
|
|
|
|
|
2021-03-12 19:40:59 +01:00
|
|
|
|
module end
|