上圖,bash 執行過程
 简体中文参阅 [bash]基础安装
 作者的 bash 檔 install.txt

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/bin/bash
#-------------------------------------------------------------------------------
#Created by helmuthdu mailto: helmuthdu[at]gmail[dot]com
#-------------------------------------------------------------------------------
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License.
#-------------------------------------------------------------------------------
# Modified for ArchBang by Mr Green mrgreen(at)archbang(dot)org
# Modified by chuanjang(at)gmail(dot)com
#

#Usage: 
#curl -O https://diii.neocities.org/install.txt
#nano install.txt OR vim install.txt
#sh install.txt

  # COLORS
  Bold=$(tput bold)
  Underline=$(tput sgr 0 1)
  Reset=$(tput sgr0)
  # Regular Colors
  Red=$(tput setaf 1)
  Green=$(tput setaf 2)
  Yellow=$(tput setaf 3)
  Blue=$(tput setaf 4)
  Purple=$(tput setaf 5)
  Cyan=$(tput setaf 6)
  White=$(tput setaf 7)
  # Bold
  BRed=${Bold}$(tput setaf 1)
  BGreen=${Bold}$(tput setaf 2)
  BYellow=${Bold}$(tput setaf 3)
  BBlue=${Bold}$(tput setaf 4)
  BPurple=${Bold}$(tput setaf 5)
  BCyan=${Bold}$(tput setaf 6)
  BWhite=${Bold}$(tput setaf 7)

  arch_chroot() { #{{{
    arch-chroot /mnt /bin/bash -c "${1}"
  }
  #}}}
  check_root() { #{{{
    if [[ "$(id -u)" != "0" ]]; then
      error_msg "ERROR! You must execute the script as the 'root' user."
    fi
  } #}}}
  print_line() { #{{{
    printf "%$(tput cols)s\n"|tr ' ' '-'
  } #}}}
  print_title() { #{{{
    clear
    print_line
    echo -e "# ${Bold}$1${Reset}"
    print_line
    echo ""
  } #}}}
  read_input_text() { #{{{
   read -p "$1 [y/N]: " OPTION
    OPTION=`echo "$OPTION" | tr '[:upper:]' '[:lower:]'`
  } #}}}
  pause_function() { #{{{
    print_line
    read -e -sn 1 -p "Press enter to continue..."
  } #}}}
  print_warning() { #{{{
    T_COLS=`tput cols`
    echo -e "${BYellow}$1${Reset}\n" | fold -sw $(( $T_COLS - 1 ))
  } #}}}
  error_msg() { #{{{
    local _msg="${1}"
    echo -e "${_msg}"
    exit 1
  } #}}}
  
  create_new_user(){ #{{{
    print_title "CREATE USER HAVE $(tput setaf 2)SUDO $(tput sgr0)$(tput bold)PRIVILEGES"
    while [[ -z "$username"  ]]; do
      read -p "username: " username
      username=`echo $username | tr '[:upper:]' '[:lower:]'`
	  if [ -z "$username" ] ; then
        print_warning "username empty, don't create user.\n"
      fi
    done

    arch_chroot "useradd -m -g users -G wheel -s /bin/bash ${username}"
	#arch_chroot "chfn ${username}"
	arch_chroot "passwd ${username}"
	while [[ $? -ne 0 ]]; do
      arch_chroot "passwd ${username}"
    done
	
    #arch_chroot "visudo"
	arch_chroot "chmod 777 /etc/sudoers"
	arch_chroot "echo '%wheel ALL=(ALL:ALL) ALL' >> /etc/sudoers"
    arch_chroot "chmod 440 /etc/sudoers"
  } #}}}

# Verify the boot mode
if [[ -d "/sys/firmware/efi/" ]]; then
  echo -e "${Cyan}UEFI${Reset} Mode detected\n"
  UEFI=true
else
  echo -e "${Cyan}BIOS Mode${Reset} detected\n"
  UEFI=false
fi
pause_function

# Connect to the internet
ip link
# Verify connection
ping -c 1 archlinux.org
echo -e "\n${Cyan}Connection${Reset} verified"
read_input_text "Continue or not"
if [[ $OPTION != y ]]; then
  echo -e "\n\nExit"
  exit 0
fi

# Ensure the system clock is accurate:
#timedatectl

# Partition the disks. To identify these devices, use lsblk 
#fdisk /dev/sda

if $UEFI ; then
echo -e "\n${Purple}UEFI${Reset}. Format and mount\n"
mkfs.fat -F32 /dev/sda1
mkfs.ext4 -F /dev/sda2
mount /dev/sda2 /mnt
mount --mkdir /dev/sda1 /mnt/boot
else
echo -e "\n${Purple}BIOS${Reset}. Format and mount\n"
BOOT_MNT="/dev/sda"
mkfs.ext4 -F /dev/sda1
mount /dev/sda1 /mnt 
fi

# Select the mirrors - https://archlinux.org/mirrors/status/
echo -e "\n\n"
PS3="Select ${Purple}mirror region${Reset}: "
items=("China" "Taiwan")
select item in "${items[@]}"
do
  case $REPLY in
      1) reflector --verbose --latest 10 --sort rate --country china --save /etc/pacman.d/mirrorlist
		  break
		;;
      2) reflector --verbose --latest 10 --sort rate --country taiwan --save /etc/pacman.d/mirrorlist
		break
		;;
      #$((${#items[@]}+1))) echo  -e "\n${Red}Cancel${Reset}"; break;;
      *) echo -e "Invalid option ${Red}$REPLY${Reset}";;
    esac
done

# Install essential packages and ...
pacstrap /mnt base linux linux-firmware sudo networkmanager wget nano vim dhcpcd

# Configure the system
genfstab -U /mnt >> /mnt/etc/fstab

echo -e "\n\nChange root into the new system and ..."
pause_function

#Set the time zone
#arch_chroot "ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime"
#arch_chroot "ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime"

#Assumes the hardware clock is set to localtime
#arch_chroot "hwclock --systohc --localtime"

#Set language  U.S. English
arch_chroot "sed -i '/#en_US.UTF-8/{s/#//}' /etc/locale.gen"
arch_chroot "locale-gen"
arch_chroot "echo 'LANG=en_US.UTF-8' > /etc/locale.conf"

#Create the hostname file
arch_chroot "echo archlinux > /etc/hostname"

# Configure mkinitcpio
arch_chroot "mkinitcpio -p linux"

echo -e "\nSet the root password"
arch_chroot "passwd"

# Enable NetworkManager
arch_chroot "systemctl enable NetworkManager"

# Enable network connect 
echo -e "\nEnable Ethernet plug in the cable\n"
arch_chroot "systemctl enable dhcpcd"

create_new_user

# Install Grub
read_input_text "Install GRUB boot loader:"
if [[ $OPTION != y ]]; then
  #arch-chroot /mnt
  echo -e "\n\n${Red}Must${Reset} install boot loader.\n"
  exit 0
fi

# Microcode must be loaded by the boot loader, Intel processors or AMD processors
arch_chroot "pacman -S intel-ucode amd-ucode --noconfirm"

arch_chroot "pacman -S grub os-prober efibootmgr  --noconfirm"
if $UEFI ; then
  arch_chroot "grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB"
else
  arch_chroot "grub-install --target=i386-pc ${BOOT_MNT}"
fi
arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg"

# Installation finished
read_input_text "Installation finished. Reboot system"
if [[ $OPTION != y ]]; then
  arch-chroot /mnt
  exit 0
fi

umount -R /mnt
reboot

exit 0

前置作業

 只有一顆安裝 Windows 的硬碟,參閱 硬碟分割與調整 增加分割區( 對於新手,建議加購硬碟)
 下載 ISO 檔
 Windows作業系統製作 USB安裝碟
 Ventoy USB開機隨身碟製作Ventoy 教學
 Etcher USB開機隨身碟製作Etcher 教學

基礎安裝

 雖然已有 archinstall,但還是覺得煩瑣。 因此寫 bash,歡迎有志青年來接棒。底下 bash,僅是基礎安裝(base install,又稱最小安裝,minimal install),參考了官網 Installation guide 寫成,archinstall 也可以完成,但要加裝 wget,以利後續桌面安裝。
 請比較作者製作的 bash 檔 install.txt 與官網 Installation guide ,當 Installation guide 有重大變動時,執行bash可能有bug,就須小作修改了😎。底下只就一顆無資料的硬碟操作,Arch Linux 與 Windows 雙系統安裝可參閱 Windows 與 Arch Linux 雙系統,這個 bash 檔(install.txt)可修改成適合雙系統。
 無線連接自理
 USB安裝碟開機(可參閱設置電腦用USB裝置開機)到 live environment
 以 fdisk、parted 或 cfdisk 做硬碟分割 (可參閱Partition the Disk)
 curl -O https://diii.neocities.org/install.txt (下載作者的 install.txt)
 第 99行 至 105行 偵測硬碟 UEFI 或 BIOS 模式,因此可sh install.txt後,在 第 114行 至 117行 結束 bash
 編輯 install.txt,nano install.txt 或 vim install.txt (格式化分割區, 掛載分割區)
 UEFI模式:127行 至 130行

mkfs.fat -F32 /dev/sda1
mkfs.ext4 -F /dev/sda2
mount /dev/sda2 /mnt
mount --mkdir /dev/sda1 /mnt/boot

 BIOS模式:133行 至 135行

BOOT_MNT="/dev/sda"
mkfs.ext4 -F /dev/sda1
mount /dev/sda1 /mnt

 sh install.txt  (如最上圖)
 建議下載 https://diii.neocities.org/install.txt, 以 nano 或 vim 或 Notepad++ 編輯 install.txt。將 install.txt 存於硬碟或USB隨身碟,啟動 live 環境時再掛載。

重新開機與系統時間

 執行 sh install.txt 完成後,會重新開機。萬事起頭難,正確開機後,桌面安裝就非常容易😲。

 底下操作於安裝桌面後處理較容易
 以具有 sudo 權限之使用者登入,設定系統時間,可用作者的 time.txt 輕鬆處理

#!/bin/bash
#--------------------------------
# Download: wget https://diii.neocities.org/time.txt
# Usage:
# chmod +x time.txt
# sh time.txt

#將系統時鐘設置到硬體時鐘
sudo sh -c "hwclock --systohc"
#硬體時間設置成 UTC
sudo sh -c "timedatectl set-local-rtc 0"
#設定時區
sudo sh -c "ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime"

#啟動NTP(Network Time Protocol)
sudo sh -c "timedatectl set-ntp true"

echo -e "Completed!"

 wget https://diii.neocities.org/time.txt
 chmox +x time.txt
 sh time.txt

Windows 系統時間

 無論是使用兩顆硬碟分別安裝Windows、Arch Linux或一顆硬碟安裝双系統,都要設定 Windows 系統時間
 設置 Windows 系統使用 UTC,請記得禁用 Windows 的時間同步功能,以防 Windows 錯誤設置硬體時間。
 以系統管理員身份開啟 cmd 執行

reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_DWORD /f

也可以使用 regedit,新建如下 DWORD 值,並將其值設為十六進位的 1。

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\RealTimeIsUniversal

桌面安裝

 LXQt
 Xfce
 KDE