자동 아치 설치

자동 아치 설치

아치를 설치하는 번거로움을 덜기 위해 공통 명령어를 모두 파일에 약간 수정해서 넣어서 #!/bin/bash맨 위에 올려두었습니다. 다음과 같습니다.

#!/bin/bash
pacman -Sy reflector --noconfirm
timedatectl set-ntp true

parted --script /dev/sda \
    mklabel msdos \
    mkpart primary ext4 1MiB 10GiB \
    set 1 boot on \
    mkpart primary ext4 10GiB 100%

mkfs.ext4 -F /dev/sda1
mkfs.ext4 -F /dev/sda2
mount /dev/sda1 /mnt

reflector --country Bangladesh --country 'United States' --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist

pacstrap /mnt base
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt

ln -sf /usr/share/zoneinfo/Asia/Dhaka /etc/localtime
hwclock --systohc
sed -i -e 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
echo 'haque' > /etc/hostname

echo '127.0.0.1 localhost
::1 localhost
127.0.1.1   haque.localdomain   haque' >> /etc/hosts

pacman -S base-devel grub bash-completion sddm plasma-desktop plasma-nm plasma-pa konsole kwrite dolphin breeze-gtk kde-gtk-config falkon sudo --noconfirm

grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

echo '[Theme]
Current=breeze' >> /etc/sddm.conf

sed -i -e 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g' /etc/sudoers

echo 'Set root password'
passwd

echo 'Set Username'
read name
useradd -m $name
echo "Set password for $name"
passwd $name
usermod -aG wheel,audio,video,optical,storage $name

systemctl enable sddm NetworkManager

echo 'Setup Complete!'
exit

일단 맞으면

arch-chroot /mnt 

실행이 중지되었습니다! 스크립트로 할 수 있나요? 아니면 스크립트를 두 개로 분할하고 의 나머지 명령을 사용하여 두 번째 스크립트를 실행해야 합니까 chroot?

답변1

제안대로비스와프리요, 스크립트를 script1과 의 두 부분으로 나누었습니다 script2. 내용은 script1다음과 같습니다:

#!/bin/bash
pacman -Sy reflector --noconfirm
timedatectl set-ntp true

parted --script /dev/sda \
    mklabel msdos \
    mkpart primary ext4 1MiB 10GiB \
    set 1 boot on \
    mkpart primary ext4 10GiB 100%

mkfs.ext4 -F /dev/sda1
mkfs.ext4 -F /dev/sda2
mount /dev/sda1 /mnt

reflector --country Bangladesh --country 'United States' --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist

pacstrap /mnt base
genfstab -U /mnt >> /mnt/etc/fstab
cp script2 /mnt/home/
arch-chroot /mnt sh /home/script2

rm /mnt/home/script2
echo 'Setup Complete!'
echo 'type "reboot" and remove installation media.'

마찬가지 script2입니다:

#!/bin/bash
ln -sf /usr/share/zoneinfo/Asia/Dhaka /etc/localtime
hwclock --systohc
sed -i -e 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' > /etc/locale.conf
echo 'haque' > /etc/hostname
echo '127.0.0.1 localhost
::1 localhost
127.0.1.1   haque.localdomain   haque' >> /etc/hosts

pacman -S base-devel grub bash-completion sddm plasma-desktop plasma-nm plasma-pa konsole kwrite dolphin breeze-gtk kde-gtk-config falkon --noconfirm

grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

echo '[Theme]
Current=breeze' >> /etc/sddm.conf

sed -i -e 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g' /etc/sudoers

echo 'Set root password'
passwd

read -p "Enter username: " name
useradd -m $name
echo "Set password for $name"
passwd $name

usermod -aG wheel,audio,video,optical,storage $name
systemctl enable sddm NetworkManager

exit 

이 두 개의 라이브 USB를 사용하면 sh script1먼저 입력하고 메시지가 표시되면 루트 비밀번호, 사용자 이름 및 사용자 비밀번호를 설정하고 마지막에 를 입력합니다 reboot.

이제 5분 안에 Arch를 설치할 수 있습니다!

답변2

내가 설정하는 데 사용한 스크립트는 다음과 같습니다.아치리눅스가상 머신의 경우

디스크의 기본 이름(sda 대 vda)을 변경하여 Archiso, qemu-kvm 및 virtualbox 설치에서 이 스크립트를 실행했습니다.

당신이 그것을 알아낼 수 있도록 도와 드리겠습니다:

  • 안전 장치로서 bash에게 오류 발생 시 스크립트를 종료하라고 지시합니다(set -e).
  • 파티션 테이블 생성플로피 디스크, IBM-DOS 파티션 테이블 아래의 파티션
  • 파티션을 포맷하고 /mnt/ 디렉터리에 마운트합니다.
  • 팩맨 저장소 업데이트
  • /mnt/ 아래에 pacstrap을 사용하여 Archlinux 라이브러리를 설치합니다.
  • fstab 생성
  • grub.sh를 준비합니다. 이 파일은 Archroot에 grub(레거시 버전)을 설치하고 설정합니다. 또한 스왑으로 사용할 스왑 파일을 만들었습니다.
  • Root를 /mnt/로 변경하고 grub.sh 파일을 실행합니다.
  • 재시작

이점:

  • 엄청 쉽고 빠르다
  • sfdisk(oneline)를 사용하여 파티션 테이블을 준비합니다.
  • grub.sh를 사용하여 Arch-root에서 필요한 모든 명령을 실행하세요.
  • 오토메이션!
  • 적응하고 변경하기 쉽습니다.

결점

  • 화려하지 않음
  • 언어 설정 없음(기본값)
  • 네트워크가 이미 존재해야 합니다.
  • 비밀번호 없음(루트/사용자)

이 스크립트는 내 빌드를 자동화했습니다. 그런 다음 일반적으로 더 복잡한 설정을 지정하기 위해 ansible(구성 관리)을 실행합니다. 하지만 나에게 필요한 것은 추가 작업 없이 Archlinux를 구축하는 매우 빠른 방법입니다. 다시 시작한 후 -> 로그인하고 이전이 아닌 다른 모든 문제를 해결합니다.

#!/usr/bin/bash
set -e

# Archlinux Installation Script for VMs
# ebal, Wed 21 Aug 2019

#Disk=sda # VirtualBox
Disk=vda # Qemu/KVM

echo ',,,*;' | sfdisk /dev/$Disk

mkdir -pv /mnt/$Disk
mkfs.ext4 -v -L rootfs /dev/${Disk}1
mount /dev/${Disk}1 /mnt/$Disk

pacman -Syy

pacstrap /mnt/$Disk base
genfstab -U /mnt/$Disk >> /mnt/$Disk/etc/fstab

# Install Grub
cat > /mnt/$Disk/root/grub.sh <<EOF
pacman -S --noconfirm grub vim
grub-install /dev/$Disk
grub-mkconfig -o /boot/grub/grub.cfg
# Add Swap Partition
dd if=/dev/zero of=/swapfile bs=2048 count=1048576
mkswap /swapfile -L swapfs
chmod 0600 /swapfile
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
EOF

chmod +x /mnt/$Disk/root/grub.sh

arch-chroot /mnt/$Disk/ /root/grub.sh

reboot

당신이 유용하다고 생각하기를 바랍니다.

관련 정보