目錄
- Vmware Station安裝Arch Linux
- 一、測驗環境及工具
- 二、下載arch linux鏡像
- 三、vmware創建虛擬機
- 四、安裝arch linux
- 1. 遠程終端登錄
- 2. iso啟動系統更換國內源
- 3. 磁盤磁區
- 4. 掛載磁區并安裝系統
- 5. 進入新系統并配置
- 6. 重啟進入安裝系統
- 五、Arch Linux wiki
- 六、參考檔案
Vmware Station安裝Arch Linux
一、測驗環境及工具
當前教程在win10環境中進行,網路為有線連接
vmware station版本為 16.2.1
arch linux鏡像為 archlinux-2022.04.05-x86_64.iso
終端工具Xshell 6,也可使用putty,mobaxterm,finalshell等工具均可,沒有區別
二、下載arch linux鏡像
訪問阿里開源鏡像站
http://mirrors.aliyun.com/archlinux/iso/
選擇當前最新版本,用下載工具下載到本地
http://mirrors.aliyun.com/archlinux/iso/2022.04.05/archlinux-2022.04.05-x86_64.iso
三、vmware創建虛擬機

創建新的虛擬機-->自定義(高級)

默認下一步

選擇稍后安裝作業系統

選擇Linux和其他linux 5.x內核64位

自定義虛擬機名稱和虛擬機的保存位置

默認下一步

根據自己的情況配置虛擬機記憶體,當前配置成2GB

默認下一步

默認下一步

默認下一步

創建新虛擬磁盤,下一步

自定義磁盤大小,選擇將虛擬磁務存盤為單個檔案

默認下一步

選擇自定義硬體


設定arch linux的iso路徑

編輯虛擬機設定,設定uefi啟動

四、安裝arch linux
1. 遠程終端登錄

啟動虛擬機,進入終端界面
ls /sys/firmware/efi/efivars 如果結果顯示了目錄且沒有報告錯誤,則系統是以 UEFI 模式引導的,

ping某個公網的域名,測驗網路是否是通的,通了才能進行后面的步驟,

執行以下命令查看啟動系統IP
ip -brief address

設定一個臨時密碼,簡單點就好
passwd
使用終端連接工具ssh連接啟動系統,用root和剛設定的密碼登錄,這么做是為了方便復制命令,畢竟手動在虛擬機上敲不僅慢,還容易出錯,
2. iso啟動系統更換國內源
由于在安裝arch linux程序中,需要通過網路下載安裝相關包,默認的國外源速度太慢,故配置成國內源進行安裝,
安裝中出現yes/no的提示時一率按回車,后面的步驟不再額外說明
pacman -Sy vim
等待安裝成功后,給iso啟動系統配置阿里開源鏡像站的軟體源
用vim編輯/etc/pacman.conf檔案,末尾添加以下兩行:
[archlinuxcn]
Server = https://mirrors.aliyun.com/archlinuxcn/$arch
vim /etc/pacman.d/mirrorlist把以下配置放到所有Server鏈接的最上面
Server = https://mirrors.aliyun.com/archlinux/$repo/os/$arch
保存退出后安裝 archlinuxcn-keyring 包匯入GPG key,
pacman -Sy archlinuxcn-keyring
3. 磁盤磁區
按以下的磁區種類分三個區即可,記憶體較小時,swap磁區一般設為真實記憶體的兩倍,本教程虛擬機記憶體是2G,所以swap磁區給4G就行,
EFI磁區 300 MB
swap磁區 4GB
root磁區 剩余空間
fdisk -l查看磁盤資訊,并執行cfdisk命令,如此教程中為cfdisk /dev/sda

選擇gpt磁區表,回車

選擇[ New ],回車

設定大小為300M,回車

選擇[ Type ],回車,選擇 EFI System,回車


按向下的游標鍵,回到Free space,選擇[ New ]繼續磁區,swap磁區設4G,Type選擇Linux swap,root磁區默認剩余全部空間,Type選擇Linux filesystem

分好區后選擇[ Write ]寫入配置,提示Are you sure you want to write the partition table to disk?時要手動輸入yes再回車,這里直接敲回車不管用

[ Write ]之后選擇[ Quit ]退出
接下來依次對三個磁區進行格式化
EFI磁區格式化
mkfs.vfat /dev/sda1
root磁區格式化,強制磁區為xfs
mkfs.xfs -f /dev/sda3
創建swap磁區
mkswap /dev/sda2
使用lsblk -f 查看磁盤磁區情況

4. 掛載磁區并安裝系統
# 掛載磁區
mount /dev/sda3 /mnt
mkdir -p /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
swapon /dev/sda2
#安裝系統
pacstrap /mnt linux linux-firmware linux-headers base base-devel vim git bash-completion
# 生成檔案系統的表檔案,作用是后面重啟進去系統能自動掛載磁區
genfstab -U /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab
5. 進入新系統并配置
arch-chroot /mnt
前面把格式化好的磁區已經掛載在iso啟動系統的/mnt目錄下,并在該目錄下安裝了系統,執行arch-chroot相當于從當前的啟動系統進入到安裝好的arch linux系統中,
進到安裝好的系統之后,第一步還是配置國內源,方法跟前文中的一樣,不再贅述,
# 設定時區
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc
# 設定系統語言
sed -i "s/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g" /etc/locale.gen
sed -i "s/#zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/g" /etc/locale.gen
# 生成本地語言資訊
locale-gen
# 設定本地語言環境變數
echo "LANG=en_US.UTF-8" > /etc/locale.conf
# 設定主機名,如archlinux
echo "archlinux" > /etc/hostname
# hosts檔案中添加主機名
echo "127.0.0.1 localhost
::1 localhost
127.0.1.1 archlinux.localdomain archlinux" >> /etc/hosts
# 安裝以下軟體包
pacman -S grub efibootmgr efivar networkmanager intel-ucode
# 配置grub
grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
# 激活啟用NetworkManager
systemctl enable NetworkManager
# 給root創建密碼
passwd
# 安裝openssl
pacman -S openssh
# 設定開機自啟動
systemctl enable sshd
# 修改/etc/ssh/sshd_config允許root登錄,修改PermitRootLogin的值為yes
sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
# 添加其他用戶并設定密碼,如test_user
useradd --create-home test_user
passwd test_user
# 設定用戶組
usermod -aG wheel,users,storage,power,lp,adm,optical test_user
# 修改當前用戶權限,編輯以下檔案,取消%wheel ALL=(ALL) ALL前的注釋,用:wq!保存退出
vim /etc/sudoers
# 安裝顯卡驅動
pacman -S xf86-video-intel vulkan-intel mesa
# 安裝聲卡驅動
pacman -S alsa-utils pulseaudio pulseaudio-bluetooth cups
# 安裝英文字體
pacman -S ttf-dejavu ttf-droid ttf-hack ttf-font-awesome otf-font-awesome ttf-lato ttf-liberation ttf-linux-libertine ttf-opensans ttf-roboto ttf-ubuntu-font-family
# 安裝中文字體
pacman -S ttf-hannom noto-fonts noto-fonts-extra noto-fonts-emoji noto-fonts-cjk adobe-source-code-pro-fonts adobe-source-sans-fonts adobe-source-serif-fonts adobe-source-han-sans-cn-fonts adobe-source-han-sans-hk-fonts adobe-source-han-sans-tw-fonts adobe-source-han-serif-cn-fonts wqy-zenhei wqy-microhei
# 打開字體引擎,取消最后一句的注釋
# export FREETYPE_PROPERTIES="truetype:interpreter-version=40"
vim /etc/profile.d/freetype2.sh
# 安裝顯示服務
pacman -S xorg
# 安裝桌面環境,plasma:就是桌面環境;sddm:登錄管理器;konsole:kde下的終端;kate:文本編輯器;ark:解壓與壓縮;okular:PDF查看器;spectacle:截圖工具;AUR:管理工具
pacman -S plasma sddm konsole dolphin kate ark okular spectacle yay
# 設定sddm登錄
systemctl enable sddm
# 安裝中文輸入法
sudo pacman -S fcitx fcitx-im fcitx-configtool
yay -S fcitx-sogoupinyin
# 編輯 /root/.xprofile寫入以下內容
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
# 安裝其他軟體
sudo pacman -S typora netease-cloud-music
yay -S baidunetdisk-electron visual-studio-code-bin google-chrome qv2ray
# 清理快取
pacman -Scc
6. 重啟進入安裝系統
以上的配置是從啟動系統arch-chroot配置的,我們現在退出啟動系統,重啟進去安裝配置好的系統,
接上一步,依次執行
exit
umount /mnt/boot/efi
umount /mnt
reboot
輸入前面設定的密碼登入系統


五、Arch Linux wiki
https://wiki.archlinux.org/
六、參考檔案
https://zhuanlan.zhihu.com/p/433920079
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/462851.html
標籤:Linux
下一篇:hive的磁區策略
