arch Linux(一)

  1. 制作启动盘
  2. 将U盘插入待装主机,设置U盘启动,重启进入系统安装界面
  3. 设置root密码
    [email protected]~ # passwd
  4. 启动允许远程连接
    [email protected]~ # systemctl start sshd
  5. 链接无线网络
    [email protected]~ # wifi-menu
  6. 查看待装主机的IP地址
    [email protected]~ # ip a
  7. 拿出MacBook我们使用远程安装
    macOS:~ hhbsh$ ssh [email protected]
  8. 更新在线安装源

    在下列文件开头

    [email protected] ~ # 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
  9. 更新
    [email protected] ~ # sudo pacman -Syy
  10. 分区,使用如下命令查看磁盘分区情况
    [email protected] ~ # fdisk -l
  11. 找到待装磁盘符。我这里是 /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
  12. 抹除 /dev/sda 磁盘的所有数据
    [email protected] ~ # 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.
  13. 使用下面命令刷新信息
    [email protected] ~ # partprobe
  14. 重启机器
    [email protected] ~ # reboot

    注:当然还是选择U盘启动。选第一个即可。

  15. 在待安装主机重复 3~6 步骤
  16. 然后我们就到MacBook使用远程安装,执行步骤 7。出现下列问题
    macOS:~ hhbsh$ ssh [email protected]
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    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.
  17. 原因是我们之前链接的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 [email protected]
    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.
    [email protected]'s password:
    Last login: Mon Feb  4 05:08:29 2019
    [email protected] ~ #
  18. 我们再来查看 /dev/sda 分区信息。发现与 11 步的信息完全不同了,我们已经擦除了该磁盘数据。
    [email protected] ~ # 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
  19. 创建分区
    1. 首先我们创建一个 2MB 大小的分区 sda1,留着后边我们设定它的标志为 bios_grub
    2. 再创建一个 200MB 的分区 sda2
    3. 再创建一个 8G 的分区 sda3
    4. 余下的空间创建分区 sda4
    [email protected] ~ # 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.
  20. 格式化分区
    [email protected] ~ # partprobe /dev/sda
    1 [email protected] ~ # mkfs.ext4 /dev/sda1
    [email protected] ~ # mkfs.ext2 /dev/sda2
    [email protected] ~ # mkswap /dev/sda3
    [email protected] ~ # mkfs.ext4 /dev/sda4
  21. 挂载文件系统
    分区 挂载点
    sda4 /
    sda2 /boot
    sda3 swap
    [email protected] ~ # mount /dev/sda4 /mnt
    [email protected] ~ # mkdir /mnt/boot
    [email protected] ~ # mount /dev/sda2 /mnt/boot
    [email protected] ~ # swapon /dev/sda3
    [email protected] ~ # swapon -a
    [email protected] ~ # swapon -s
    Filename                Type        Size    Used    Priority
    /dev/sda3                               partition   8388604 0   -2
    [email protected] ~ #
  22. 因为我们在步骤 14 有重启过系统,需要再次执行步骤 8,配置源。
  23. 刷新源
    [email protected] ~ # pacman -Syy
  24. 安装基本的 package
    [email protected] ~ # pacstrap /mnt base base-devel

    注:此步稍费时,去喝杯咖啡~

  25. chroot 环境下的配置:
    [email protected] ~ # arch-chroot /mnt
    [[email protected] /]# pacman -S vim

    注:安装 vim 编辑器,利于编辑(可选择任意你喜欢的编辑器即可)。

    1. 时区、时间配置

      [[email protected] /]# ln -sf /usr/share/zoneinfo/Asia/Beijing /etc/localtime
      [[email protected] /]# hwclock --systohc
    2. 主机名配置
      [[email protected] /]# vim /etc/hostname
    3. 本地化设置
      [[email protected] /]# 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
    4. 执行下列语句使步骤 3 生效
      [[email protected] /]# locale-gen
    5. 配置 fstab。执行此步骤需要暂时退出 arch-chroot
      [[email protected] /]# exit
      exit
      arch-chroot /mnt  7.39s user 0.86s system 0% cpu 18:25.04 total
      [email protected] ~ # genfstab -U /mnt > /mnt/etc/fstab
      [email protected] ~ # 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
      
      [email protected] ~ #
    6. 配置 grub。需要再次进入 arch-chroot
      [email protected] ~ # arch-chroot /mnt
      [[email protected] /]# pacman -S grub
    7. 网络配置

      我们可以安装 networkmanager 包来管理我们的网络:

      [[email protected] /]# pacman -S networkmanager

      启用 NetworkManager

      [[email protected] /]# sudo systemctl enable NetworkManager
      [[email protected] /]# sudo systemctl start NetworkManager
    8. 安装 openssh 并设置为开机启动
      [[email protected] /]# pacman -S openssh
      [[email protected] /]# sudo systemctl enable sshd
      Created symlink /etc/systemd/system/multi-user.target.wants/sshd.service → /usr/lib/systemd/system/sshd.service.
      [[email protected] /]# sudo systemctl start sshd
      Running in chroot, ignoring request: start
    9. 用户及权限配置
      1. 设置 root 用户密码

        [[email protected] /]# passwd
        New password:
        Retype new password:
        passwd: password updated successfully
      2. 配置 sudoers 文件
        [[email protected] /]# vim /etc/sudoers

        # %wheel ALL=(ALL) NOPASSWD: ALL 语句前边的注释符 # 删掉,:q! 强制保存退出。

      3. 添加一个与 root 同一个组的用户,并给该用户创建密码
        [[email protected] /]# useradd -m -G wheel eric
        [[email protected] /]# id eric
        uid=1000(eric) gid=1000(eric) groups=1000(eric),998(wheel)
        [[email protected] /]# passwd eric
        New password:
        Retype new password:
        passwd: password updated successfully
        [[email protected] /]#
    10. 再次配置 grub
    [[email protected] /]# 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

    执行:

    [[email protected] /]# pacman -S parted
    [[email protected] /]# parted /dev/sda set 1 bios_grub on
    Information: You may need to update /etc/fstab.
    
    [[email protected] /]# 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
    
    [[email protected] /]#

    再次执行下列语句

    [[email protected] /]# grub-install /dev/sda
    Installing for i386-pc platform.
    Installation finished. No error reported.
    [[email protected] /]# 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
    [[email protected] /]#

    成功。

    1. 安装 neofetch

      [[email protected] /]# pacman -S neofetch

      通过下边这条命令我们发现 arch Linux 基本已经安装好了:

      [[email protected] /]# neofetch
                         -`                    [email protected]
                        .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:
       `++:.                           `-/+/
       .`                                 `/
      
      [[email protected] /]#
    2. 退出 arch-chroot 环境。配置 NetworkManageropenssh 开机自启
      [[email protected] /]# exit
      exit
      arch-chroot /mnt  9.40s user 4.36s system 0% cpu 1:02:26.92 total
      [email protected] ~ # sudo systemctl start NetworkManager
      Failed to start NetworkManager.service: Unit NetworkManager.service not found.
      5 ro[email protected] ~ # sudo systemctl start sshd                                                      :(
      [email protected] ~ #
    3. 关闭 /mnt 下的所有挂载点,重启计算机
      [email protected] ~ # umount -R /mnt
      [email protected] ~ # reboot

      注:reboot 命令执行会关闭待装主机,主机关机时(重启前)拔下 U 盘。如果没来得及拔掉,直接用物理关机键强制关机,拔下 U 盘,然后开机。

  26. 留作扩充
  27. 参考帖子

    Archlinux安装第一部分

    解决Linux安装过程中不能安装Grub的问题

    以官方Wiki的方式安装ArchLinux

    Arch Linux 怎么安装?

原文地址:https://www.cnblogs.com/d0ct0rx/p/10351892.html

时间: 2024-10-02 22:55:28

arch Linux(一)的相关文章

Arch Linux最小化安装X

Xorg Xorg-server 安装xorg-server pacman -S xorg-server 可选:xorg-server-utils pacman -S xorg-server-utils Xorg-server-utils meta-package pulls in the most useful packages for certain configuration tasks, they are pointed out in the relevant sections. Dri

Arch Linux最小化安装LXDE桌面环境

安装最小化的LXDE桌面环境: pacman -S lxde-common 安装LXDE Session: pacman -S lxsession 不安装这个没法登录进桌面环境 安装LXDE面板: pacman -S lxpanel 不安装这个,进入LXDE桌面环境后什么都没有 安装窗口管理器: pacman -S openbox 不安装这个,既不能移动窗口,也不能最大.最小化窗口 安装LXDE环境下的终端程序: pacman -S lxterminal 安装LXDE环境下的文件管理器: pac

把Arch Linux安装到U盘上的具体教程

Arch Linux简介 Arch Linux(或称Arch)是一种以轻量简洁为设计理念的Linux发行版.其开发团队秉承简洁.优雅.正确和代码最小化的设计宗旨.Arch Linux 项目受 CRUX 启发,由 Judd Vinet 于2002年启动.Arch Linux是起源于加拿大的一份致力于使用简单.系统轻量.软件更新速度快的GNU/Linux发行版.创始人Judd Vinet出于对Debian以及Red Hat的包管理器不满,以及受CRUX影响而创立.最初针对i686,但是如今对x86_

linux新手学习之Arch Linux入门经验分享

我一直是以Ubuntu与Fedora作为新手入门的系统,但是其实我真正想推荐的是Arch,经过前面的学习,或许你对Linux已经有了一个大致的了解,现在如果你想加速你的步伐,也许可以看看本文.如果要问为什么学习Linux,我也只能回答Just for fun 我一直是以 Ubuntu 与 Fedora 作为新手入门的系统,但是其实我真正想推荐的是 Arch ,经过前面的学习,或许你对 Linux 已经有了一个大致的了解,现在如果你想加速你的步伐,也许可以看看本文.如果要问为什么学习 Linux

Arch Linux之pacman调用axel多线程加速下载

转载自 奶牛博客 本来感觉Arch Linux用个国内的源就很给力了,可是到了学校移动的cmcc-edu超级不稳定,而且单线程速度就二三十k,无奈,开多线程下载.在Ubuntu下面可以用apt-fast来做加速,arch下面加速的方式很多,因为arch的pacman.conf文件提供了直接调用外部下载程序的功能.需要看文档的朋友可以参考  Improve Pacman Performance (提升pacman下载速度) 因为文中介绍了很多方法,奶牛就不熬述了,朋友们自己看,奶牛只说下axel调

在Arch Linux构建安装RhytmCat

Linux没有windows那么多好用的媒体播放器,而且在Linux系统上,多媒体格式是受限的,安装好系统之后默认并不包含解码器,需要自行搜索安装解码器以便支持各种多媒体的播放,如果需要的话.更糟糕的是,Linux系统上的软件在处理中文编码时表现得并不友好,比如说播放列表和中文歌词.....直接乱码问题.尽管用easytag处理后还是会有乱码问题,但已经很少了. RhythmCat是基于gstreamer后端的一个音乐播放器,支持显示歌词,能处理简单的中文,依赖于插件也能实现windows上那种

Arch Linux的安装和配置

Arch的安装 这没什么好讲的,在ArchWiki上已经给出了详尽的说明,只需按照给出的步骤一步步进行即可. 特别要讲的是关于grub,我用的是Windows 7+Arch Linux,由于在安装Arch之前已经装了Windows 7,Arch装好之后,在grub菜单栏没有Windows 7的选项,此时需要在/boot/grub/grub.cfg里进行设置,在最后添加如下代码即可: 1 #Windows Seven 2 menuentry "Windows Seven" { 3 set

Arch Linux 安装、配置、美化和优化

国庆假期玩了下Arch Linux,发现这货跟Ubuntu之流相差甚远,甚难调教,而且安裝过程全命令行,会有各种问题,各种知识... --- 安装引导器--- --------------------------- GRUB BIOS: # pacman -S grub os-prober # grub-install --recheck /dev/<目标磁盘> # grub-mkconfig -o /boot/grub/grub.cfg UEFI:---如果BIOS是UEFI的,就要用下面的

arch linux下nvidia 驱动死机问题

好长一段时间了,自从某次arch滚动升级nvidia驱动后,就频繁的Xorg死掉.一直没能解决,只好换用nouveau.nouveau一般使用问题到不大,但是前几天nouveau升级后,也开始抽筋. 于是又尝试换回nvidia的专有驱动,死机情况依然未解.偶然在死机后,用ssh连接上后用dmesg抓到一个错误: NVRM: GPU at 0000:01:00.0 Has Fallen Off The Bus 一番搜索,找到这篇文章: http://www.cyberciti.biz/faq/de

Arch Linux Installation Guide

Arch Linux Installation Guide timedatectl set-ntp true sed -i '/Score/{/China/!{n;s/^/#/}}' /etc/pacman.d/mirrorlist pacman -Syy 启动模式检查 检查启动模式是否支持UEFI,这将决定在安装 Bootloader 阶段的步骤: ls /sys/firmware/efi/efivars --如果如上文件存在,就说明为UEFI,否则为legacy BIOS lsblk par