after-reboot.sh
· 247 B · Bash
Исходник
echo "export EDITOR=nvim" >> ~/.bash_profile
source ~/.bash_profile
useradd -m -G wheel -s /bin/bash frain
passwd frain
visudo
su frain
sudo pacman -S chezmoi
chezmoi init [email protected]:6957efbbba2d7df023d9a849/dotfiles.git
chezmoi apply
| 1 | echo "export EDITOR=nvim" >> ~/.bash_profile |
| 2 | source ~/.bash_profile |
| 3 | useradd -m -G wheel -s /bin/bash frain |
| 4 | passwd frain |
| 5 | visudo |
| 6 | |
| 7 | su frain |
| 8 | sudo pacman -S chezmoi |
| 9 | chezmoi init [email protected]:6957efbbba2d7df023d9a849/dotfiles.git |
| 10 | chezmoi apply |
| 11 |
arch-install-btrfs.sh
· 1.6 KiB · Bash
Исходник
#!/bin/bash
# Variables
ESP=/dev/nvme0n1p1
ROOT=/dev/nvme0n1p2
SWAPFILESIZE=2G
# Optimization: Added discard=async for NVMe, removed redundant nodiratime
MOUNT_OPTIONS="noatime,compress=zstd,space_cache=v2,discard=async,ssd"
# 1. Format the partition
mkfs.btrfs -L ROOT $ROOT -f
# 2. Create Flat Subvolume Layout
mount $ROOT /mnt
btrfs sub create /mnt/@
btrfs sub create /mnt/@home
btrfs sub create /mnt/@pkg
btrfs sub create /mnt/@snapshots
btrfs sub create /mnt/@vm
btrfs sub create /mnt/@log
btrfs sub create /mnt/@swap
umount /mnt
# 3. Mount Root Subvolume
mount -o $MOUNT_OPTIONS,subvol=@ $ROOT /mnt
# 4. Create Mount Points
mkdir -p /mnt/{boot,home,var/cache/pacman/pkg,var/log,var/lib/libvirt,.snapshots,btrfs}
# 5. Mount Other Subvolumes
mount -o $MOUNT_OPTIONS,subvol=@home $ROOT /mnt/home
mount -o $MOUNT_OPTIONS,subvol=@pkg $ROOT /mnt/var/cache/pacman/pkg
mount -o $MOUNT_OPTIONS,subvol=@snapshots $ROOT /mnt/.snapshots
mount -o $MOUNT_OPTIONS,subvol=@log $ROOT /mnt/var/log
mount -o $MOUNT_OPTIONS,subvolid=5 $ROOT /mnt/btrfs
# 6. Specialized Subvolume Mounting (NoCOW for VMs)
mount -o $MOUNT_OPTIONS,subvol=@vm $ROOT /mnt/var/lib/libvirt
chattr +C /mnt/var/lib/libvirt # Disable Copy-on-Write for VM performance
# 7. Mount ESP
mount $ESP /mnt/boot
# 8. Create Swapfile on Btrfs
# btrfs-progs automatically handles NoCOW and compression exclusion for swapfiles
btrfs filesystem mkswapfile --size $SWAPFILESIZE --uuid clear /mnt/btrfs/@swap/swapfile
swapon /mnt/btrfs/@swap/swapfile
pacstrap -K /mnt base linux linux-firmware intel-ucode sof-firmware networkmanager man-db man-pages neovim grub efibootmgr zsh sudo
| 1 | #!/bin/bash |
| 2 | |
| 3 | # Variables |
| 4 | ESP=/dev/nvme0n1p1 |
| 5 | ROOT=/dev/nvme0n1p2 |
| 6 | SWAPFILESIZE=2G |
| 7 | # Optimization: Added discard=async for NVMe, removed redundant nodiratime |
| 8 | MOUNT_OPTIONS="noatime,compress=zstd,space_cache=v2,discard=async,ssd" |
| 9 | |
| 10 | # 1. Format the partition |
| 11 | mkfs.btrfs -L ROOT $ROOT -f |
| 12 | |
| 13 | # 2. Create Flat Subvolume Layout |
| 14 | mount $ROOT /mnt |
| 15 | btrfs sub create /mnt/@ |
| 16 | btrfs sub create /mnt/@home |
| 17 | btrfs sub create /mnt/@pkg |
| 18 | btrfs sub create /mnt/@snapshots |
| 19 | btrfs sub create /mnt/@vm |
| 20 | btrfs sub create /mnt/@log |
| 21 | btrfs sub create /mnt/@swap |
| 22 | umount /mnt |
| 23 | |
| 24 | # 3. Mount Root Subvolume |
| 25 | mount -o $MOUNT_OPTIONS,subvol=@ $ROOT /mnt |
| 26 | |
| 27 | # 4. Create Mount Points |
| 28 | mkdir -p /mnt/{boot,home,var/cache/pacman/pkg,var/log,var/lib/libvirt,.snapshots,btrfs} |
| 29 | |
| 30 | # 5. Mount Other Subvolumes |
| 31 | mount -o $MOUNT_OPTIONS,subvol=@home $ROOT /mnt/home |
| 32 | mount -o $MOUNT_OPTIONS,subvol=@pkg $ROOT /mnt/var/cache/pacman/pkg |
| 33 | mount -o $MOUNT_OPTIONS,subvol=@snapshots $ROOT /mnt/.snapshots |
| 34 | mount -o $MOUNT_OPTIONS,subvol=@log $ROOT /mnt/var/log |
| 35 | mount -o $MOUNT_OPTIONS,subvolid=5 $ROOT /mnt/btrfs |
| 36 | |
| 37 | # 6. Specialized Subvolume Mounting (NoCOW for VMs) |
| 38 | mount -o $MOUNT_OPTIONS,subvol=@vm $ROOT /mnt/var/lib/libvirt |
| 39 | chattr +C /mnt/var/lib/libvirt # Disable Copy-on-Write for VM performance |
| 40 | |
| 41 | # 7. Mount ESP |
| 42 | mount $ESP /mnt/boot |
| 43 | |
| 44 | # 8. Create Swapfile on Btrfs |
| 45 | # btrfs-progs automatically handles NoCOW and compression exclusion for swapfiles |
| 46 | btrfs filesystem mkswapfile --size $SWAPFILESIZE --uuid clear /mnt/btrfs/@swap/swapfile |
| 47 | swapon /mnt/btrfs/@swap/swapfile |
| 48 | |
| 49 | pacstrap -K /mnt base linux linux-firmware intel-ucode sof-firmware networkmanager man-db man-pages neovim grub efibootmgr zsh sudo |
arch-install-chroot.sh
· 806 B · Bash
Исходник
# Replace hostname with the name for your host
export HOST=hostname
# Replace Europe/London with your Region/City
export TZ="Asia/Shanghai"
echo $HOST > /etc/hostname
cat << EOF >> /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 $HOST.localdomain $HOST
EOF
ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
# Sync system time to hardware clock
hwclock --systohc
# - set locale
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
#echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg
systemctl enable NetworkManager
# enable ssh root login
#sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
passwd root
| 1 | # Replace hostname with the name for your host |
| 2 | export HOST=hostname |
| 3 | # Replace Europe/London with your Region/City |
| 4 | export TZ="Asia/Shanghai" |
| 5 | |
| 6 | echo $HOST > /etc/hostname |
| 7 | cat << EOF >> /etc/hosts |
| 8 | 127.0.0.1 localhost |
| 9 | ::1 localhost |
| 10 | 127.0.1.1 $HOST.localdomain $HOST |
| 11 | EOF |
| 12 | |
| 13 | ln -sf /usr/share/zoneinfo/$TZ /etc/localtime |
| 14 | # Sync system time to hardware clock |
| 15 | hwclock --systohc |
| 16 | |
| 17 | # - set locale |
| 18 | echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen |
| 19 | #echo "zh_CN.UTF-8 UTF-8" >> /etc/locale.gen |
| 20 | locale-gen |
| 21 | echo 'LANG=en_US.UTF-8' > /etc/locale.conf |
| 22 | |
| 23 | grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB |
| 24 | grub-mkconfig -o /boot/grub/grub.cfg |
| 25 | |
| 26 | systemctl enable NetworkManager |
| 27 | # enable ssh root login |
| 28 | #sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config |
| 29 | |
| 30 | passwd root |
| 31 |