标签:signature 它的 cbo requested oschina ext2 evel info 计算
制作启动盘
将U盘插入待装主机,设置U盘启动,重启进入系统安装界面
设置root密码
root@archiso~ # passwd
启动允许远程连接
root@archiso~ # systemctl start sshd
链接无线网络
root@archiso~ # wifi-menu
查看待装主机的IP地址
root@archiso~ # ip a
拿出MacBook我们使用远程安装
macOS:~ hhbsh$ ssh root@192.168.3.8
更新在线安装源
在下列文件开头
root@archiso ~ # vim /etc/pacman.d/mirrorlist
添加
Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch
更新
root@archiso ~ # sudo pacman -Syy
分区,使用如下命令查看磁盘分区情况
root@archiso ~ # fdisk -l
找到待装磁盘符。我这里是 /dev/sda
Disk /dev/sda: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Disk model: Lenovo SSD SL700
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: gpt
Disk identifier: 6109DCF3-362D-468B-970C-81967DD0D852
Device Start End Sectors Size Type
/dev/sda1 2048 6143 4096 2M BIOS boot
/dev/sda2 6144 415743 409600 200M Linux filesystem
/dev/sda3 415744 17192959 16777216 8G Linux filesystem
/dev/sda4 17192960 250069646 232876687 111G Linux filesystem
抹除 /dev/sda
磁盘的所有数据
root@archiso ~ # fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.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/sda: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Disk model: Lenovo SSD SL700
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: gpt
Disk identifier: 6109DCF3-362D-468B-970C-81967DD0D852
Device Start End Sectors Size Type
/dev/sda1 2048 6143 4096 2M BIOS boot
/dev/sda2 6144 415743 409600 200M Linux filesystem
/dev/sda3 415744 17192959 16777216 8G Linux filesystem
/dev/sda4 17192960 250069646 232876687 111G Linux filesystem
Command (m for help): d
Partition number (1-4, default 4):
Partition 4 has been deleted.
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): d
No partition is defined yet!
Command (m for help):
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
使用下面命令刷新信息
root@archiso ~ # partprobe
重启机器
root@archiso ~ # reboot
注:当然还是选择U盘启动。选第一个即可。
在待安装主机重复 3~6 步骤
然后我们就到MacBook使用远程安装,执行步骤 7。出现下列问题
macOS:~ hhbsh$ ssh root@192.168.3.8
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:kGzwhZIhRjRwXG7UNenF1zhXruVLaOz6MyGCtnAu5Wg.
Please contact your system administrator.
Add correct host key in /Users/hhbsh/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/hhbsh/.ssh/known_hosts:8
ECDSA host key for 192.168.3.8 has changed and you have requested strict checking.
Host key verification failed.
原因是我们之前链接的ssh协商的 192.168.3.8
该 IP 地址的主机密钥失效。我们在MacBook的 /Users/hhbsh/.ssh/known_hosts
文件内删除 192.168.3.8
相关信息, :wq
保存退出,重新生成密钥即可。
macOS:~ hhbsh$ vim /Users/hhbsh/.ssh/known_hosts
macOS:~ hhbsh$ ssh root@192.168.3.8
The authenticity of host '192.168.3.8 (192.168.3.8)' can't be established.
ECDSA key fingerprint is SHA256:IhRjRwXG7fsfgUNenF1zhXruVLaOz6MdfgdfGCtnAu5Wg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.3.8' (ECDSA) to the list of known hosts.
root@192.168.3.8's password:
Last login: Mon Feb 4 05:08:29 2019
root@archiso ~ #
我们再来查看 /dev/sda
分区信息。发现与 11 步的信息完全不同了,我们已经擦除了该磁盘数据。
root@archiso ~ # fdisk -l
Disk /dev/sda: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Disk model: Lenovo SSD SL700
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: gpt
Disk identifier: 6109DCF3-362D-468B-970C-81967DD0D852
创建分区
sda1
,留着后边我们设定它的标志为 bios_grub
;sda2
;sda3
;sda4
。root@archiso ~ # fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition number (1-128, default 1):
First sector (34-250069646, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-250069646, default 250069646): +2M
Created a new partition 1 of type 'Linux filesystem' and of size 2 MiB.
Command (m for help): n
Partition number (2-128, default 2):
First sector (6144-250069646, default 6144):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (6144-250069646, default 250069646): +200M
Created a new partition 2 of type 'Linux filesystem' and of size 200 MiB.
Partition #2 contains a ext2 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 number (3-128, default 3):
First sector (415744-250069646, default 415744):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (415744-250069646, default 250069646): +8G
Created a new partition 3 of type 'Linux filesystem' and of size 8 GiB.
Partition #3 contains a swap 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 number (4-128, default 4):
First sector (17192960-250069646, default 17192960):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (17192960-250069646, default 250069646):
Created a new partition 4 of type 'Linux filesystem' and of size 111 GiB.
Partition #4 contains a ext4 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):
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
格式化分区
root@archiso ~ # partprobe /dev/sda
1 root@archiso ~ # mkfs.ext4 /dev/sda1
root@archiso ~ # mkfs.ext2 /dev/sda2
root@archiso ~ # mkswap /dev/sda3
root@archiso ~ # mkfs.ext4 /dev/sda4
挂载文件系统
分区 | 挂载点 |
---|---|
sda4 | / |
sda2 | /boot |
sda3 | swap |
root@archiso ~ # mount /dev/sda4 /mnt
root@archiso ~ # mkdir /mnt/boot
root@archiso ~ # mount /dev/sda2 /mnt/boot
root@archiso ~ # swapon /dev/sda3
root@archiso ~ # swapon -a
root@archiso ~ # swapon -s
Filename Type Size Used Priority
/dev/sda3 partition 8388604 0 -2
root@archiso ~ #
因为我们在步骤 14 有重启过系统,需要再次执行步骤 8,配置源。
刷新源
root@archiso ~ # pacman -Syy
安装基本的 package
root@archiso ~ # pacstrap /mnt base base-devel
注:此步稍费时,去喝杯咖啡~
chroot
环境下的配置:
root@archiso ~ # arch-chroot /mnt
[root@archiso /]# pacman -S vim
注:安装 vim 编辑器,利于编辑(可选择任意你喜欢的编辑器即可)。
时区、时间配置
[root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Beijing /etc/localtime
[root@archiso /]# hwclock --systohc
主机名配置
[root@archiso /]# vim /etc/hostname
本地化设置
[root@archiso /]# vim /etc/locale.gen
把 locale.gen 文件内的
#en_US.UTF-8 UTF-8
#zh_CN.UTF-8 UTF-8
前边的注释符号 #
删除,使该语句生效。
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8
执行下列语句使步骤 3 生效
[root@archiso /]# locale-gen
配置 fstab
。执行此步骤需要暂时退出 arch-chroot
。
[root@archiso /]# exit
exit
arch-chroot /mnt 7.39s user 0.86s system 0% cpu 18:25.04 total
root@archiso ~ # genfstab -U /mnt > /mnt/etc/fstab
root@archiso ~ # cat /mnt/etc/fstab
# /dev/sda4
UUID=cc6af4fb-f72b-47a2-9a41-6e5253bf0167 / ext4 rw,relatime 0 1
# /dev/sda2
UUID=bce9b3fa-b6ad-45ad-918f-5b3a46b3a04d /boot ext2 rw,relatime,block_validity,barrier,user_xattr,acl 0 2
# /dev/sda3
UUID=c9b5a804-988b-4a7c-8519-a1e3fe63554c none swap defaults,pri=-2 0 0
root@archiso ~ #
配置 grub
。需要再次进入 arch-chroot
root@archiso ~ # arch-chroot /mnt
[root@archiso /]# pacman -S grub
网络配置
我们可以安装 networkmanager
包来管理我们的网络:
[root@archiso /]# pacman -S networkmanager
启用 NetworkManager
:
[root@archiso /]# sudo systemctl enable NetworkManager
[root@archiso /]# sudo systemctl start NetworkManager
安装 openssh
并设置为开机启动
[root@archiso /]# pacman -S openssh
[root@archiso /]# sudo systemctl enable sshd
Created symlink /etc/systemd/system/multi-user.target.wants/sshd.service → /usr/lib/systemd/system/sshd.service.
[root@archiso /]# sudo systemctl start sshd
Running in chroot, ignoring request: start
用户及权限配置
设置 root 用户密码
[root@archiso /]# passwd
New password:
Retype new password:
passwd: password updated successfully
配置 sudoers 文件
[root@archiso /]# vim /etc/sudoers
将 # %wheel ALL=(ALL) NOPASSWD: ALL
语句前边的注释符 #
删掉,:q!
强制保存退出。
添加一个与 root 同一个组的用户,并给该用户创建密码
[root@archiso /]# useradd -m -G wheel eric
[root@archiso /]# id eric
uid=1000(eric) gid=1000(eric) groups=1000(eric),998(wheel)
[root@archiso /]# passwd eric
New password:
Retype new password:
passwd: password updated successfully
[root@archiso /]#
再次配置 grub
[root@archiso /]# grub-install /dev/sda
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.
发现执行错误。参考此帖,这里也是解释了为什么步骤 19-1 我们要分配 2M 的分区 /dev/sda1
。
执行:
[root@archiso /]# pacman -S parted
[root@archiso /]# parted /dev/sda set 1 bios_grub on
Information: You may need to update /etc/fstab.
[root@archiso /]# parted /dev/sda print
Model: ATA Lenovo SSD SL700 (scsi)
Disk /dev/sda: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 3146kB 2097kB ext4 bios_grub
2 3146kB 213MB 210MB ext2
3 213MB 8803MB 8590MB linux-swap(v1)
4 8803MB 128GB 119GB ext4
[root@archiso /]#
再次执行下列语句
[root@archiso /]# grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
[root@archiso /]# 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 /]#
成功。
安装 neofetch
[root@archiso /]# pacman -S neofetch
通过下边这条命令我们发现 arch Linux 基本已经安装好了:
[root@archiso /]# neofetch
-` root@archiso
.o+` ------------
`ooo/ OS: Arch Linux x86_64
`+oooo: Host: IdeaPad Y460 Rev 1.0
`+oooooo: Kernel: 4.20.6-arch1-1-ARCH
-+oooooo+: Uptime: 2 hours, 9 mins
`/:-:++oooo+: Packages: 186 (pacman)
`/++++/+++++++: Shell: bash 5.0.0
`/++++++++++++++: Terminal: /dev/pts/0
`/+++ooooooooooooo/` CPU: Intel i3 M 380 (4) @ 2.533GHz
./ooosssso++osssssso+` GPU: Intel Core Processor
.oossssso-````/ossssss+` GPU: NVIDIA GeForce GT 425M
-osssssso. :ssssssso. Memory: 247MiB / 3743MiB
:osssssss/ osssso+++.
/ossssssss/ +ssssooo/-
`/ossssso+/:- -:/+osssso+-
`+sso+:-` `.-/+oso:
`++:. `-/+/
.` `/
[root@archiso /]#
退出 arch-chroot
环境。配置 NetworkManager
和 openssh
开机自启
[root@archiso /]# exit
exit
arch-chroot /mnt 9.40s user 4.36s system 0% cpu 1:02:26.92 total
root@archiso ~ # sudo systemctl start NetworkManager
Failed to start NetworkManager.service: Unit NetworkManager.service not found.
5 root@archiso ~ # sudo systemctl start sshd :(
root@archiso ~ #
关闭 /mnt
下的所有挂载点,重启计算机
root@archiso ~ # umount -R /mnt
root@archiso ~ # reboot
注:reboot
命令执行会关闭待装主机,主机关机时(重启前)拔下 U 盘。如果没来得及拔掉,直接用物理关机键强制关机,拔下 U 盘,然后开机。
留作扩充
参考帖子
标签:signature 它的 cbo requested oschina ext2 evel info 计算
原文地址:https://www.cnblogs.com/d0ct0rx/p/10351892.html