first steps

This commit is contained in:
2026-08-18 20:47:11 +07:00
parent 0f21f1a5be
commit 53641918a9
6 changed files with 72 additions and 0 deletions

4
.env Normal file
View File

@@ -0,0 +1,4 @@
_SYS_DEV=sda
_HEADER_DEV=sdb
_EFI_SIZE=1024M
_SWAP_SIZE=2048M

3
0.info.sh Normal file → Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
lsblk -o NAME,SIZE,TYPE,MODEL,TRAN

5
0_.test.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
source .env
echo ${_SYS_DEV}22

15
1.disks.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
source .env
echo $_EFI_SIZE
sgdisk --zap-all /dev/$_SYS_DEV
sgdisk -n 1:0:+$_EFI_SIZE -t 1:ef00 -c 1:"EFI" /dev/$_SYS_DEV
sgdisk -n 2:0:+$_SWAP_SIZE -t 2:8200 -c 2:"SWAP" /dev/$_SYS_DEV
sgdisk -n 3:0:0 -t 3:8309 -c 3:"LUKS-Data" /dev/$_SYS_DEV
sgdisk -p /dev/$_SYS_DEV
dd if=/dev/zero of=/dev/$_HEADER_DEV bs=512 count=32768 status=progress
cryptsetup luksFormat --type luks2 --header /dev/$_HEADER_DEV /dev/${_SYS_DEV}3
cryptsetup open /dev/${_SYS_DEV}3 --header /dev/$_HEADER_DEV cryptroot
ls /dev/mapper/cryptroot

30
2.0.fs-init.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
source .env
mkfs.btrfs -L arch /dev/mapper/cryptroot
mkfs.fat -F 32 /dev/${_SYS_DEV}1
mount /dev/mapper/cryptroot /mnt
cd /mnt
btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @snapshots
btrfs subvolume create @var
btrfs subvolume create @var_log
btrfs subvolume create @var_cache
cd /
umount /mnt
mount -o defaults,noatime,compress=zstd,ssd,space_cache=v2,autodefrag,subvol=@ /dev/mapper/cryptroot /mnt
mkdir -p /mnt/{home,var,tmp,boot,snapshots}
mount -o defaults,noatime,compress=zstd,ssd,space_cache=v2,autodefrag,subvol=@home /dev/mapper/cryptroot /mnt/home
mount -o defaults,noatime,compress=zstd,space_cache=v2,subvol=@snapshots /dev/mapper/cryptroot /mnt/snapshots
mount -o defaults,noatime,space_cache=v2,subvol=@var /dev/mapper/cryptroot /mnt/var
mkdir -p /mnt/var/{log,cache}
mount -o defaults,noatime,space_cache=v2,nodatacow,subvol=@var_log /dev/mapper/cryptroot /mnt/var/log
mount -o defaults,noatime,space_cache=v2,nodatacow,subvol=@var_cache /dev/mapper/cryptroot /mnt/var/cache
mount -o fmask=0077,dmask=0077 /dev/${_SYS_DEV}1 /mnt/boot
mkswap /dev/${_SYS_DEV}2
swapon /dev/${_SYS_DEV}2

15
2.1.fs-mount.sh Normal file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
source .env
cd /
mount -o defaults,noatime,compress=zstd,ssd,space_cache=v2,autodefrag,subvol=@ /dev/mapper/cryptroot /mnt
mount -o defaults,noatime,compress=zstd,ssd,space_cache=v2,autodefrag,subvol=@home /dev/mapper/cryptroot /mnt/home
mount -o defaults,noatime,compress=zstd,space_cache=v2,subvol=@snapshots /dev/mapper/cryptroot /mnt/snapshots
mount -o defaults,noatime,space_cache=v2,subvol=@var /dev/mapper/cryptroot /mnt/var
mount -o defaults,noatime,space_cache=v2,nodatacow,subvol=@var_log /dev/mapper/cryptroot /mnt/var/log
mount -o defaults,noatime,space_cache=v2,nodatacow,subvol=@var_cache /dev/mapper/cryptroot /mnt/var/cache
mount -o fmask=0077,dmask=0077 /dev/${_SYS_DEV}1 /mnt/boot
mkswap /dev/${_SYS_DEV}2
swapon /dev/${_SYS_DEV}2