Modification : vm_{host,hosted,remote} -> {host,local,remote}/ .
[lhc/ateliers.git] / host / part-root-format
1 #!/bin/sh -eu
2 tool=$(readlink -e "${0%/*}/..")
3 . "$tool"/host/lib.sh
4
5 if ! mount | grep -q "^$vm_dev_disk_root "
6 then
7 sudo cryptsetup luksFormat --hash=sha512 --key-size=512 \
8 --cipher=aes-xts-essiv:sha256 --align-payload=8 $vm_dev_disk_root
9 sudo cryptsetup luksOpen $vm_dev_disk_root ${vm_lvm_lv}_root_deciphered
10 sudo mke2fs -t ext4 -c -c -m 5 -T ext4 -b $vm_e2fs_block_size \
11 -E resize=30G${vm_e2fs_extended_options} \
12 -L ${vm_lvm_lv}_root \
13 /dev/mapper/${vm_lvm_lv}_root_deciphered
14 ! mountpoint -q /mnt/$vm_fqdn
15 sudo mount -v /dev/mapper/${vm_lvm_lv}_root_deciphered /mnt/$vm_fqdn
16 sudo install -d -m 770 -o root -g root \
17 /mnt/$vm_fqdn/boot \
18 /mnt/$vm_fqdn/dev \
19 /mnt/$vm_fqdn/home \
20 /mnt/$vm_fqdn/proc \
21 /mnt/$vm_fqdn/root \
22 /mnt/$vm_fqdn/root/src \
23 /mnt/$vm_fqdn/root/src/$vm \
24 /mnt/$vm_fqdn/sys \
25 /mnt/$vm_fqdn/var
26 sudo umount -v /mnt/$vm_fqdn
27 sudo cryptsetup luksClose ${vm_lvm_lv}_root_deciphered
28 fi