-
Notifications
You must be signed in to change notification settings - Fork 0
/
init
executable file
·31 lines (27 loc) · 878 Bytes
/
init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
mount -t proc proc proc
mount -t devtmpfs dev dev
mount -t sysfs sys sys
modprobe squashfs
mkdir /mnt/modloop
mount modloop-virt /mnt/modloop/
mount --bind /mnt/modloop/modules/ /lib/modules
modprobe virtio_blk
modprobe btrfs
mkdir /mnt/root
mount /dev/vdb /mnt/root
btrfs filesystem resize -32M /mnt/root >/dev/zero
umount /mnt/root/
cryptsetup reencrypt --encrypt --verify-passphrase --reduce-device-size 32M -q /dev/vdb
UUID=$(cryptsetup luksUUID /dev/vdb)
cryptsetup luksOpen /dev/vdb enc
mount -o subvol=root /dev/mapper/enc /mnt/root
sed -i /mnt/root/etc/default/grub -e "s/rootflags=subvol=root/rootflags=subvol=root rd.luks.uuid=$UUID/"
umount /mnt/root/
mkdir /mnt/boot
modprobe ext4
mount /dev/vda /mnt/boot/
sed -i /mnt/boot/loader/entries/*.conf -e "s/rootflags=subvol=root/rootflags=subvol=root rd.luks.uuid=$UUID/"
umount /mnt/boot/
sync
poweroff -f