arch Linux(一)
制作启动盘
将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
创建分区
- 首先我们创建一个 2MB 大小的分区
sda1
,留着后边我们设定它的标志为bios_grub
; - 再创建一个 200MB 的分区
sda2
; - 再创建一个 8G 的分区
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.
- 首先我们创建一个 2MB 大小的分区
格式化分区
root@archiso ~ # partprobe /dev/sda 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/Shanghai /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
语句前边的注释符#
删掉,:wq!
强制保存退出。添加一个与 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 盘,然后开机。
留作扩充
参考帖子
arch Linux(一)的更多相关文章
- Arch Linux 安装博通 BCM4360 驱动(Arch Linux, Ubuntu, Debian, Fedora...)
BCM4360 在2010年9月,博通完全开源的硬件驱动[1].该驱动程序 brcm80211已被列入到自2.6.37之后的内核中.随着2.6.39发布,这些驱动程序已被重新命名为 brcmsmac和 ...
- Arch Linux中文乱码解决
Arch Linux中文乱码解决 1.安装中文字体 pacman -S wqy-zenhei ttf-fireflysung (flash乱码) ---乱码的原因就是缺少中文字体的支持,下载文泉驿 ...
- Arch Linux 简易打包指南
本文时代久远,请参阅更可靠的:Arch User Repository (简体中文) - 分享和维护软件包 这两天给 Kreogist µ 打 Arch Linux 包,照着 wiki 跟着搞,同时在 ...
- Arch Linux sudo: PAM authentication error: Module is unknown [Solved!]
问题描述: 我的 Arch Linux 已经用了快半年多,由于 Arch Linux 的滚挂问题,我从没有直接升级过系统.软件版本以及库自然落后了一些. 就在我准备需要用到 NFS 时,挂载网络文件系 ...
- Arch Linux Installation Guide
Arch Linux Installation Guide timedatectl set-ntp true sed -i '/Score/{/China/!{n;s/^/#/}}' /etc ...
- Arch Linux 安装、配置、美化和优化
国庆假期玩了下Arch Linux,发现这货跟Ubuntu之流相差甚远,甚难调教,而且安裝过程全命令行,会有各种问题,各种知识... --- 安装引导器--- -------------------- ...
- 如何在 Arch Linux 的终端里设定 WiFi 网络
如果你使用的是其他 Linux 发行版 而不是 Arch CLI,那么可能会不习惯在终端里设置 WiFi.尽管整个过程有点简单,不过我还是要讲一下.在这篇文章里,我将带领新手们通过一步步的设置向导,把 ...
- Arch Linux 安装记录
Arch Linux 安装记录 基本上参考wiki上的新手指南,使用arch 2014.6.1 iso安装 设置网络 有线网络 Arch Linux 默认开启DHCP. 静态ip 首先关闭DHCP:s ...
- Arch linux安装
安装archlinux可参考: http://blog.sina.com.cn/s/blog_69e5d8400101bqlj.html http://www.cnblogs.com/mad/p/32 ...
- Arch Linux 安装过程
在VM中装了Arch,由于过程较为曲折,现写博客一篇聊以慰藉. 1.新建虚拟机,将下载好的archlinux-2016.03.01-dual.iso挂到虚拟机设置的CD/DVD 2.进入Arch安装界 ...
随机推荐
- webpack项目搭建
1.新建一个文件目录,命令行进入当前目录,输入npm init 创建package.json文件 2.安装项目依赖webpack模块: npm install webpack --save-dev 3 ...
- ORACLE结构体系篇之表空间详解.md
表空间详解一.系统表空间SYSTEM 表空间是Oracle 数据库最重要的一个表空间,存放了一些DDL 语言产生的信息以及PL/SQL 包.视图.函数.过程等,称之为数据字典,因此该表空间也具有其特殊 ...
- python 关于 input
name = input("请输入你的姓名:") print(name) 解释:input表示输入,当你输入一个名字的时候, 它打印出来的东西,也就是你输入的东西, 结果: 请输入 ...
- Java 基础 IO流
一,前言 在前面的学习过程中,我们一直都是在操作文件或者文件夹,并没有给文件中写任何数据.现在我们就要开始给文件中写数据,或者读取文件中的数据. 二,字节流 2.1 字节输出流 OutputStrea ...
- [LeetCode] 236. Lowest Common Ancestor of a Binary Tree_ Medium tag: DFS, Divide and conquer
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...
- python second lesson
1.系统模块 新建的文件名不能和导入的库名相同,要不然python会优先从自己的目录下寻找. import sys sys是一个系统变量,sys.argv会调出文件的相对路径,sys.argv[2] ...
- GIEC2019第六届全球互联网经济大会北京站震撼来袭!
GIEC2019第六届全球互联网经济大会将于2019年8月26日-27日在北京召开,以“智慧零售数字商业”为主题,将邀请政府官员.企业高管.专家学者共议新形势下如何利人工智能和数字化的商业模式促进零售 ...
- ubuntu12下subversion 1.6升级为1.8版本
应用场景是.android源码体积太大.我从服务器上svn co过来,速度很慢.服务器是ubuntu14版本,我工作的机器是ubuntu12版本,14上面svn版本是1.8.8,12上svn的版本是1 ...
- linux下安装svn服务器
http://www.cnblogs.com/zhoulf/archive/2013/02/02/2889949.html 安装说明系统环境:CentOS-6.3安装方式:yum install (源 ...
- EasyUI出现多条边框重合的问题
比如在 下面使用一个datagrid表格,可能出现某几条边框重合的问题,这种情况需要在div一层的panel添加"border:false"属性,datagrid不做处理即可