OS:Arch Linux
官方文件
功能:安裝 Arch Linux
官方文件
功能:安裝 Arch Linux
- #!/bin/bash
- # Program:
- # This program is for installing arch
- # History:
- # 2016/11/1 zWind First release
- # use sh -n fileName to only check grammar
- # use sh -x fileName to debug
- # disk divide partition must be done and mount
- function genSetting()
- {
- cat <<EOF > /mnt/setting.sh
- pacman -S vim --noconfirm
- # set timezone
- ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime
- hwclock --systohc
- hwclock
- # set Locale
- vim /etc/locale.gen
- locale-gen
- echo LANG=en_US.UTF-8 > /etc/locale.conf
- cat /etc/locale.conf
- # set hostName
- echo ${hostName} > /etc/hostname
- cat /etc/hostname
- echo "127.0.1.1 ${hostName}.localdomain ${hostName}" >> /etc/hosts
- vim /etc/hosts
- # Initramfs
- mkinitcpio -p linux
- # set grub
- pacman -S grub --noconfirm
- grub-install --recheck ${disk}
- grub-mkconfig -o /boot/grub/grub.cfg
- # change root password
- passwd
- # add user
- read -p "Please input your userName: " -t 30 userName
- userName=${userName:-${hostName}}
- useradd -m -g users ${userName}
- passwd ${userName}
- # exit
- exit
- EOF
- }
- disk="/dev/sda"
- bootDisk="${disk}1"
- swapDisk="${disk}2"
- echo "create sda1 for root and sda2 for swap"
- fdisk ${disk}
- test ! -e ${bootDisk} && echo "'${bootDisk}' DO NOT exist" && exit 0
- test ! -e ${swapDisk} && echo "'${swapDisk}' DO NOT exist" && exit 0
- mkfs.ext4 ${bootDisk}
- mount ${bootDisk} /mnt
- mkswap ${swapDisk}
- swapon ${swapDisk}
- read -p "Please input your hostName name: " -t 30 hostName
- hostName=${hostName:-archTest}
- export hostName
- # install base
- pacstrap /mnt base base-devel
- # gen fstab
- genfstab -p -U /mnt >> /mnt/etc/fstab
- vim /mnt/etc/fstab
- genSetting
- # change root and run script
- arch-chroot /mnt /bin/bash ./setting.sh
- umount -R /mnt
- reboot
留言
張貼留言