Created
April 17, 2025 16:28
-
-
Save iandark/90ee8f13c79cf76b18d02c9091533ff2 to your computer and use it in GitHub Desktop.
Arch_without_systemd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| # Configurações | |
| DISK="/dev/nvme0n1" | |
| HOSTNAME="ArchBook" | |
| USERNAME="derkian" | |
| USERPASS="derkian" | |
| LOCALE="pt_BR.UTF-8 UTF-8" | |
| LANGUAGE="pt_BR.UTF-8" | |
| KEYMAP="us" | |
| TIMEZONE="America/Sao_Paulo" | |
| LUKS_NAME="cryptroot" | |
| # 1. Preparar disco | |
| umount -R /mnt || true | |
| cryptsetup close $LUKS_NAME || true | |
| wipefs -af "$DISK" | |
| sgdisk -o "$DISK" | |
| sgdisk -n 1::+512M -t 1:ef00 "$DISK" | |
| sgdisk -n 2:: -t 2:8300 "$DISK" | |
| # 2. Criptografar e formatar | |
| cryptsetup luksFormat "${DISK}p2" | |
| cryptsetup open "${DISK}p2" $LUKS_NAME | |
| mkfs.fat -F32 "${DISK}p1" | |
| mkfs.btrfs -f "/dev/mapper/$LUKS_NAME" | |
| # 3. Montar | |
| mount "/dev/mapper/$LUKS_NAME" /mnt | |
| btrfs subvolume create /mnt/@ | |
| umount /mnt | |
| mount -o compress=zstd,subvol=@ /dev/mapper/$LUKS_NAME /mnt | |
| mkdir -p /mnt/boot | |
| mount "${DISK}p1" /mnt/boot | |
| # 4. Instalar base | |
| pacstrap -K /mnt base linux linux-firmware linux-headers \ | |
| btrfs-progs grub efibootmgr dosfstools \ | |
| dinit elogind-dinit networkmanager-dinit seatd-dinit dbus-dinit \ | |
| sway foot xorg-server xorg-xwayland mesa \ | |
| ttf-dejavu sudo nano git neovim broadcom-wl-dkms | |
| # 5. Configuração básica | |
| genfstab -U /mnt >> /mnt/etc/fstab | |
| # 6. Chroot para configurar o sistema | |
| arch-chroot /mnt /bin/bash <<EOF | |
| ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime | |
| hwclock --systohc | |
| echo "$LOCALE" > /etc/locale.gen | |
| locale-gen | |
| echo "LANG=$LANGUAGE" > /etc/locale.conf | |
| echo "KEYMAP=$KEYMAP" > /etc/vconsole.conf | |
| echo "$HOSTNAME" > /etc/hostname | |
| # mkinitcpio | |
| sed -i 's/^HOOKS=.*/HOOKS=(base udev autodetect modconf block encrypt btrfs keyboard fsck)/' /etc/mkinitcpio.conf | |
| sed -i 's/^MODULES=.*/MODULES=(nvme)/' /etc/mkinitcpio.conf | |
| mkinitcpio -P | |
| # GRUB | |
| UUID=$(blkid -s UUID -o value "${DISK}p2") | |
| grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB | |
| cat > /etc/default/grub <<EOL | |
| GRUB_DEFAULT=0 | |
| GRUB_TIMEOUT=3 | |
| GRUB_DISTRIBUTOR="Arch" | |
| GRUB_CMDLINE_LINUX="cryptdevice=UUID=$UUID:$LUKS_NAME root=/dev/mapper/$LUKS_NAME" | |
| GRUB_ENABLE_CRYPTODISK=y | |
| EOL | |
| grub-mkconfig -o /boot/grub/grub.cfg | |
| # Usuário | |
| useradd -m -G wheel,video -s /bin/bash $USERNAME | |
| echo "$USERNAME:$USERPASS" | chpasswd | |
| echo "root:$USERPASS" | chpasswd | |
| echo '%wheel ALL=(ALL:ALL) ALL' >> /etc/sudoers | |
| # Dinit: habilitar serviços essenciais | |
| ln -s /etc/dinit.d/dbus /etc/dinit.d/boot.d/ | |
| ln -s /etc/dinit.d/elogind /etc/dinit.d/default.d/ | |
| ln -s /etc/dinit.d/seatd /etc/dinit.d/default.d/ | |
| ln -s /etc/dinit.d/networkmanager /etc/dinit.d/default.d/ | |
| # Dinit: login automático no TTY1 com sway | |
| cat > /etc/dinit.d/agetty-tty1.conf <<EOL | |
| exec=/sbin/agetty --autologin $USERNAME --noclear tty1 linux | |
| depends=seatd | |
| EOL | |
| ln -s /etc/dinit.d/agetty-tty1 /etc/dinit.d/default.d/ | |
| # Bash profile para iniciar Sway | |
| mkdir -p /home/$USERNAME | |
| chown $USERNAME:$USERNAME /home/$USERNAME | |
| su - $USERNAME -c "echo 'export XDG_SESSION_TYPE=wayland' >> ~/.bash_profile" | |
| su - $USERNAME -c "echo 'export XDG_SESSION_DESKTOP=sway' >> ~/.bash_profile" | |
| su - $USERNAME -c "echo 'exec sway' >> ~/.bash_profile" | |
| EOF | |
| echo "Instalação finalizada com sucesso. Pode reiniciar!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment