一、启动安装
本案例使用vmware15,需要注意使用EFI模式启动
二、启动22端口(目的是使用远程ssh工具,便于复制粘贴)
# 生成3个密钥
ssh-keygen -A
# 启动22端口
/usr/sbin/sshd -D &
# 查看ip
root@archiso ~ # ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 22.48.3.163 netmask 255.255.255.0 broadcast 22.48.3.255
inet6 fe80::20c:29ff:fe06:e412 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:06:e4:12 txqueuelen 1000 (Ethernet)
RX packets 7554 bytes 9859989 (9.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2675 bytes 260233 (254.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 288 bytes 25632 (25.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 288 bytes 25632 (25.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# 测试网络
root@archiso ~ # ping archlinux.org
PING archlinux.org (138.201.81.199) 56(84) bytes of data.
64 bytes from apollo.archlinux.org (138.201.81.199): icmp_seq=1 ttl=128 time=223 ms
64 bytes from apollo.archlinux.org (138.201.81.199): icmp_seq=2 ttl=128 time=223 ms
^C
--- archlinux.org ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 222.812/222.820/222.829/0.008 ms
# 修改root密码
passwd
三、使用SecureCRT远程登录
四、更新系统时间
root@archiso ~ # timedatectl status
Local time: Sat 2020-10-24 22:49:52 UTC
Universal time: Sat 2020-10-24 22:49:52 UTC
RTC time: Sat 2020-10-24 22:49:53
Time zone: UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
root@archiso ~ # timedatectl set-ntp true
root@archiso ~ #
五、使用parted建立硬盘分区
root@archiso ~ # parted -a optimal /dev/sda
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 1100GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted) unit mib
(parted) mkpart primary 1 1025
(parted) name 1 boot
(parted) mkpart primary 1025 2049
(parted) name 2 efi
(parted) mkpart primary 2049 11000
(parted) name 3 swap
(parted) mkpart primary 11000 25000
(parted) name 4 root
(parted) mkpart primary 25000 50000
(parted) name 5 var
(parted) mkpart primary 50000 100000
(parted) name 6 tmp
(parted) mkpart primary 100000 -1
(parted) name 7 home
(parted) set 1 bios_grub on
(parted) set 2 boot on
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 1048576MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1.00MiB 1025MiB 1024MiB boot bios_grub
2 1025MiB 2049MiB 1024MiB efi boot, esp
3 2049MiB 11000MiB 8951MiB swap
4 11000MiB 25000MiB 14000MiB root
5 25000MiB 50000MiB 25000MiB var
6 50000MiB 100000MiB 50000MiB tmp
7 100000MiB 1048575MiB 948575MiB home
(parted) quit
Information: You may need to update /etc/fstab.
# 这里不用理会,是实时生效的
root@archiso ~ # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 566.2M 1 loop /run/archiso/sfs/airootfs
sda 8:0 0 1T 0 disk
├─sda1 8:1 0 1G 0 part
├─sda2 8:2 0 1G 0 part
├─sda3 8:3 0 8.7G 0 part
├─sda4 8:4 0 13.7G 0 part
├─sda5 8:5 0 24.4G 0 part
├─sda6 8:6 0 48.8G 0 part
└─sda7 8:7 0 926.3G 0 part
sr0 11:0 1 681M 0 rom /run/archiso/bootmnt
# 分那么多个盘主要是为了建立/var /home / 这些文件系统,便于遇重装的情况不丢失数据,数据存放在/var /home下,如重装则安装在/下
六、 挂载文件系统
root@archiso ~ # mkfs.fat -F32 /dev/sda1
mkfs.fat 4.1 (2017-01-24)
root@archiso ~ # mkfs.fat -F32 /dev/sda2
mkfs.fat 4.1 (2017-01-24)
root@archiso ~ # mkswap /dev/sda3
Setting up swapspace version 1, size = 8.7 GiB (9385799680 bytes)
no label, UUID=d009253f-ec3d-40cd-bf5c-3ba8beb8f0a9
root@archiso ~ # mkfs.ext4 /dev/sda4
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 3584000 4k blocks and 897600 inodes
Filesystem UUID: 3929db31-4fe3-4215-9a2d-9702e1037361
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
root@archiso ~ # mkfs.ext4 /dev/sda5
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 6400000 4k blocks and 1602496 inodes
Filesystem UUID: f26c523a-3ed4-40fd-9893-75ab2c72e7de
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
root@archiso ~ # mkfs.ext4 /dev/sda6
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 12800000 4k blocks and 3203072 inodes
Filesystem UUID: 4a394b38-a17a-4f8d-8539-3eae33c2cd43
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done
root@archiso ~ # mkfs.ext4 /dev/sda7
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 242835200 4k blocks and 60710912 inodes
Filesystem UUID: a9b032b5-2c1b-4e8c-ae74-fe01457600e6
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
root@archiso ~ # mount /dev/sda4 /mnt
root@archiso ~ # cd /mnt
root@archiso /mnt # mkdir boot efi tmp var home
root@archiso /mnt # cd
root@archiso ~ # mount /dev/sda1 /mnt/boot
root@archiso ~ # mount /dev/sda2 /mnt/efi
root@archiso ~ # mount /dev/sda5 /mnt/var
root@archiso ~ # mount /dev/sda6 /mnt/tmp
root@archiso ~ # mount /dev/sda7 /mnt/home
七、确定源是否含国内
vim /etc/pacman.d/mirrorlist
(调整里面第一条为国内源:
Server = http://mirrors.163.com/archlinux/$repo/os/$arch
)
八、安装内核
pacstrap -i /mnt base base-devel linux-lts linux-firmware # 这里内核选择了 linux-lts,可选内核包括linux 和linux-zen等
# 可以将 [linux] 替换为 [kernel](https://wiki.archlinux.org/index.php/Kernel "Kernel") 页面中介绍的内核软件包。
# 在虚拟机或容器中安装时,可以不安装固件软件包。
九、设置开机自动挂载文件系统
root@archiso /mnt # genfstab -U /mnt >> /mnt/etc/fstab
root@archiso /mnt # cat /mnt/etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.
# <file system> <dir> <type> <options> <dump> <pass>
# /dev/sda5
UUID=49e77f64-4d6b-4867-af54-dce4d73c5459 / ext4 rw,relatime 0 1
# /dev/sda1
UUID=33C6-4C59 /efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 2
# /dev/sda2
UUID=22c42f66-478d-4219-81f0-c83af0c8f363 /boot ext4 rw,relatime 0 2
# /dev/sda4
UUID=d9d28860-4c29-4c07-a14c-97135c7c2833 /var ext4 rw,relatime 0 2
# /dev/sda6
UUID=b01ed83b-413a-46bb-ab74-585a2d84ca1c /home ext4 rw,relatime 0 2
十、切到新系统
root@archiso /mnt # arch-chroot /mnt
[root@archiso /]#
十一、设置时区
# 查看时区清单
[root@archiso /]# timedatectl list-timezones
# 设置
[root@archiso /]# timedatectl set-timezone Asia/Shanghai
[root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@archiso /]# hwclock --systohc
十二、本地化
[root@archiso /]# pacman -S vi vim net-tools sysstat openssh
vi /etc/locale.gen
# 去掉下面行的注释
# en_SG.UTF-8
# zh_CN.UTF-8
# 将系统 locale 设置为 en_US.UTF-8 ,系统的 log 就会用英文显示,这样更容易判断和处理问题;
# 也可以设置为 en_GB.UTF-8 或 en_SG.UTF-8,附带以下优点:
# 进入桌面环境后以 24 小时制显示时间;
# LibreOffice 等办公软件的纸张尺寸会默认为 A4 而非 Letter(US);
# 可尽量避免不必要且可能造成处理麻烦的英制单位。
# 警告: 不推荐在此设置任何中文 locale,会导致 tty 乱码。
[root@archiso /]# locale-gen
Generating locales...
en_US.UTF-8... done
zh_CN.UTF-8... done
Generation complete.
[root@archiso /]#
十三、设置主机名及相关设置
vi /etc/hostname #创建文件 这里主机名为arch
vi /etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 arch.localdomain arch
# 如果系统有一个永久的 IP 地址,请使用这个永久的 IP 地址而不是 `127.0.1.1`。
十四、设置用户密码
这里创建一个docker用户
[root@archiso /]# passwd
New password:
Retype new password:
passwd: password updated successfully
[root@archiso /]# useradd -m -d /home/docker docker
[root@archiso /]# passwd docker
New password:
Retype new password:
passwd: password updated successfully
vi /etc/sudoers
十五、显示与图形界面
# 执行如下命令查询显卡类型
[root@archiso /]# lspci | grep -e VGA -e 3D
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
# 输入下面命令,查看所有开源驱动:
[root@archiso /]# pacman -Ss xf86-video
extra/xf86-video-amdgpu 19.1.0-2 (xorg-drivers)
X.org amdgpu video driver
extra/xf86-video-ati 1:19.1.0-2 (xorg-drivers)
X.org ati video driver
extra/xf86-video-dummy 0.3.8-4 (xorg-drivers)
X.org dummy video driver
extra/xf86-video-fbdev 0.5.0-2 (xorg-drivers)
X.org framebuffer video driver
extra/xf86-video-intel 1:2.99.917+908+g7181c5a4-1 (xorg-drivers)
X.org Intel i810/i830/i915/945G/G965+ video drivers
extra/xf86-video-nouveau 1.0.16-2 (xorg-drivers)
Open Source 3D acceleration driver for nVidia cards
extra/xf86-video-openchrome 0.6.0-4 (xorg-drivers)
X.Org Openchrome drivers
extra/xf86-video-sisusb 0.9.7-3
X.org SiS USB video driver
extra/xf86-video-vesa 2.5.0-1 (xorg-drivers xorg)
X.org vesa video driver
extra/xf86-video-vmware 13.3.0-2 (xorg-drivers)
X.org vmware video driver
extra/xf86-video-voodoo 1.2.5-11 (xorg-drivers)
X.org 3dfx Voodoo1/Voodoo2 2D video driver
community/xf86-video-qxl 0.1.5-8 (xorg-drivers)
Xorg X11 qxl video driver
[root@archiso /]# pacman -S xf86-video-vesa xorg lxqt breeze-icons oxygen-icons alsa-utils ntfs-3g
# pacman -S xf86-input-synaptics #台式机不用装 触摸板驱动
[root@archiso /]# pacman -S ttf-dejavu wqy-bitmapfont wqy-microhei wqy-zenhei noto-fonts noto-fonts-emoji
[root@archiso etc]# pacman -S sddm
[root@archiso etc]# systemctl enable sddm
Created symlink /etc/systemd/system/display-manager.service → /usr/lib/systemd/system/sddm.service.
十五、网络及相关软件安装
[root@archiso /]# pacman -S connman cmst wpa_supplicant
[root@archiso etc]# systemctl enable connman
connmanctl enable wifi
connmanctl scan wifi
# pacman -S iw wpa_supplicant dialog # 无线
# adsl
# pacman -S rp-pppoe
# pppoe-setup
# systemctl start adsl
[root@archiso etc]# vi /etc/pacman.conf
# 末尾追加两行
[archlinuxcn]
SigLevel=Never
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
# pacman -Sy fcitx-im fcitx-configtool # 中文输入法
十六、安装引导程序
[root@archiso /]# pacman -Sy dosfstools grub efibootmgr
[root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/efi --recheck --bootloader-id=GRUB
# grub-install /dev/sda --boot-directory=/boot --recheck --bootloader-id=GRUB 注意sda后面无数字
Installing for x86_64-efi platform.
Installation finished. No error reported.
[root@archiso etc]# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux
Found initrd image: /boot/initramfs-linux.img
Found fallback initrd image(s) in /boot: initramfs-linux-fallback.img
done
[root@archiso etc]# umount -R /mnt