Arch Linux
1、获取镜像
2、安装前的准备
- 准备安装介质
- 启动到 Live 环境
- 验证引导模式
- 连接到互联网
- 更新系统时间
- 硬盘分区
- 格式化分区
- 挂载分区
# 验证引导模式
root@archiso ~ # [ -d /sys/firmware/efi/efivars/ ] && echo "Uefi" || echo "Bios"
Uefi
磁盘
- Uefi 磁盘分区选 GPT
- Bios 磁盘分区选 MBR
grub 引导
# 获取 IP
root@archiso ~ # ip addr | awk '/inet / {print $2}' | grep -v "127.0.0.1/8"
10.52.17.32/24
root@archiso ~ # ping www.baidu.com -c 2
PING www.a.shifen.com (36.152.44.96) 56(84) bytes of data.
64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=1 ttl=57 time=6.32 ms
64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=2 ttl=57 time=6.75 ms
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 5135ms
rtt min/avg/max/mdev = 6.319/6.532/6.745/0.213 ms
root@archiso ~ # timedatectl set-timezone Asia/Shanghai
root@archiso ~ # timedatectl status
Local time: Tue 2023-04-04 13:16:06 CST
Universal time: Tue 2023-04-04 05:16:06 UTC
RTC time: Tue 2023-04-04 05:16:06
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
root@archiso ~ # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 687.9M 1 loop /run/archiso/airootfs
sda 8:0 0 149.1G 0 disk
├─sda1 8:1 0 149G 0 part
│ └─ventoy 254:0 0 809.3M 1 dm
└─sda2 8:2 0 32M 0 part
mmcblk0 179:0 0 115.3G 0 disk
├─mmcblk0p1 179:1 0 500M 0 part
├─mmcblk0p2 179:2 0 2G 0 part
└─mmcblk0p3 179:3 0 112.8G 0 part
mmcblk0boot0 179:8 0 4M 1 disk
mmcblk0boot1 179:16 0 4M 1 disk
root@archiso ~ # fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4746e965
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 1026047 1024000 500M ef EFI (FAT-12/16/32)
/dev/mmcblk0p2 1026048 5220351 4194304 2G 82 Linux swap / Solaris
/dev/mmcblk0p3 5220352 241696767 236476416 112.8G 83 Linux
Command (m for help): d
Partition number (1-3, default 3):
Partition 3 has been deleted.
Command (m for help): d
Partition number (1,2, default 2):
Partition 2 has been deleted.
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): p
Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4746e965
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-241696767, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-241696767, default 241696767): +1G
Created a new partition 1 of type 'Linux' and of size 1 GiB.
Partition #1 contains a vfat signature.
Do you want to remove the signature? [Y]es/[N]o: y
The signature will be removed by a write command.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (2-4, default 2):
First sector (2099200-241696767, default 2099200):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-241696767, default 241696767): +2G
Created a new partition 2 of type 'Linux' and of size 2 GiB.
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (3,4, default 3):
First sector (6293504-241696767, default 6293504):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (6293504-241696767, default 241696767):
Created a new partition 3 of type 'Linux' and of size 112.2 GiB.
Command (m for help): p
Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4746e965
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 2099199 2097152 1G 83 Linux
/dev/mmcblk0p2 2099200 6293503 4194304 2G 83 Linux
/dev/mmcblk0p3 6293504 241696767 235403264 112.2G 83 Linux
Filesystem/RAID signature on partition 1 will be wiped.
Command (m for help): t
Partition number (1-3, default 3): 1
Hex code or alias (type L to list all): L
00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx
04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / .
06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility
07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt
08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended
0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor
12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective
17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS
18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE
1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto
1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep
1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT
24 NEC DOS
Aliases:
linux - 83
swap - 82
extended - 05
uefi - EF
raid - FD
lvm - 8E
linuxex - 85
Hex code or alias (type L to list all): ef
Changed type of partition 'Linux' to 'EFI (FAT-12/16/32)'.
Command (m for help): t
Partition number (1-3, default 3): 2
Hex code or alias (type L to list all): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Command (m for help): p
Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4746e965
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 2099199 2097152 1G ef EFI (FAT-12/16/32)
/dev/mmcblk0p2 2099200 6293503 4194304 2G 82 Linux swap / Solaris
/dev/mmcblk0p3 6293504 241696767 235403264 112.2G 83 Linux
Filesystem/RAID signature on partition 1 will be wiped.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@archiso ~ # fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4746e965
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 2099199 2097152 1G ef EFI (FAT-12/16/32)
/dev/mmcblk0p2 2099200 6293503 4194304 2G 82 Linux swap / Solaris
/dev/mmcblk0p3 6293504 241696767 235403264 112.2G 83 Linux
root@archiso ~ # mkfs.ext4 /dev/mmcblk0p3
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 29425408 4k blocks and 7356416 inodes
Filesystem UUID: c7bfd5b1-7e6b-4ae5-b483-e1b4a2ed2674
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done
root@archiso ~ # mkswap /dev/mmcblk0p2
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=5c75e41d-ee5a-4e2f-9346-eafc20ae1b1a
root@archiso ~ # mkfs.fat -F 32 /dev/mmcblk0p1
mkfs.fat 4.2 (2021-01-31)
{/collapse-item}
root@archiso ~ # mount /dev/mmcblk0p3 /mnt
root@archiso ~ # mount --mkdir /dev/mmcblk0p1 /mnt/boot/efi
root@archiso ~ # swapon /dev/mmcblk0p2
3、安装
- 配置镜像源
- 安装软件包
root@archiso ~ # nano /etc/pacman.d/mirrorlist
# 第一行添加
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
root@archiso ~ # pacman -Syy
:: Synchronizing package databases...
core
extra 153.9 KiB 719 KiB/s 00:00 [#########################################] 100%
community 1746.2 KiB 13.4 MiB/s 00:00 [#########################################] 100%
root@archiso ~ # pacman -S archlinux-keyring
root@archiso ~ # pacstrap /mnt base base-devel linux-lts linux-firmware linux-lts-headers
pacstrap /mnt base base-devel linux-lts linux-firmware linux-lts-headers 48.63s user 29.30s system 85% cpu 1:31.19 total
root@archiso ~ # pacstrap /mnt networkmanager dhcpcd openssh vim git grub efibootmgr intel-ucode man-db man-pages ntfs-3g noto-fonts-cjk noto-fonts-emoji
4、安装后的配置
- 配置 Fstab
- Chroot
- 设置时区
- 设置区域语言
- 网络配置 & 主机名
- root 密码
- 安装引导程序
- 重启
root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab
root@archiso ~ # cat /mnt/etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.
# <file system> <dir> <type> <options> <dump> <pass>
# /dev/mmcblk0p3
UUID=c7bfd5b1-7e6b-4ae5-b483-e1b4a2ed2674 / ext4 rw,relatime 0 1
# /dev/mmcblk0p1
UUID=4973-14CE /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
# /dev/mmcblk0p2
UUID=5c75e41d-ee5a-4e2f-9346-eafc20ae1b1a none swap defaults 0 0
root@archiso ~ # arch-chroot /mnt
[root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@archiso /]# date
Tue Apr 4 14:00:44 CST 2023
[root@archiso /]# hwclock --systohc
[root@archiso /]# vim /etc/locale.gen
# 171
en_US.UTF-8 UTF-8
# 496
zh_CN.UTF-8 UTF-8
[root@archiso /]# locale-gen
Generating locales...
en_US.UTF-8... done
zh_CN.UTF-8... done
Generation complete.
[root@archiso /]# echo "Arch" > /etc/hostname
[root@archiso /]# passwd
New password:
Retype new password:
passwd: password updated successfully
[root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
Installing for x86_64-efi platform.
Installation finished. No error reported.
[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg
{/tabs-pane}
{tabs-pane label="Bios"}
[root@archiso /]# grub-install # grub-install --target=i386-pc /dev/sda
Installing for x86_64-efi platform.
Installation finished. No error reported.
[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg
{/tabs-pane}
[root@archiso /]# useradd -m acha -G wheel
[root@archiso /]# passwd acha
New password:
Retype new password:
passwd: password updated successfully
评论