Raspberry Pi 3 B+安装Arch Linux ARM

Raspberry Pi 3 B+安装Arch Linux ARM

最近不知道怎么回事,一直有把笔记本系统更换为Arch Linux的骚动,无奈笔记本中工作资料比较多,未能实现该想法。不过内心的骚动还是要小小的满足一下滴,祭出吃灰的Raspberry Pi 3 Model B+先感受一下Arch魅力。

准备

  • Raspberry Pi 3 B+
  • 内存卡32G及读卡器
  • Arch Linux ARM系统包
  • 网线

安装

为了让每个人都能够安装本篇文章安装成功,我先在虚拟机里安装Arch Linux,感受一下Arch Linux的安装过程,以下操作都在虚拟机中进行,屏蔽了Windows/macOS/Linux系统带来的差异。

分区

内存卡连接至虚拟机,lsblk查看内存卡盘符,fdisk /dev/sdx格式化内存卡
lsblk
可以看到sdb是我的内存卡,有sdb1、sdb2是由于之前安装都系统了。
本次使用到的fdisk操作,更多查看Linux命令大全https://man.linuxde.net/fdisk
p列出分区
o创建DOS分区表
n创建新分区
t -> 1 -> c设置分区1的类型为W95 FAT32 (LBA)
w写入保存分区并退出

下面开始分区

[root@archlinux ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.36).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): o
Created a new DOS disklabel with disk identifier 0x813d368b.

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-62333951, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62333951, default 62333951): +1G

Created a new partition 1 of type 'Linux' and of size 1 GiB.

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-62333951, default 2099200):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-62333951, default 62333951):

Created a new partition 2 of type 'Linux' and of size 28.7 GiB.

Command (m for help): t
Partition number (1,2, default 2): 1
Hex code or alias (type L to list all): L

00 Empty            24 NEC DOS          81 Minix / old Lin  bf Solaris
01 FAT12            27 Hidden NTFS Win  82 Linux swap / So  c1 DRDOS/sec (FAT-
02 XENIX root       39 Plan 9           83 Linux            c4 DRDOS/sec (FAT-
03 XENIX usr        3c PartitionMagic   84 OS/2 hidden or   c6 DRDOS/sec (FAT-
04 FAT16 <32M       40 Venix 80286      85 Linux extended   c7 Syrinx
05 Extended         41 PPC PReP Boot    86 NTFS volume set  da Non-FS data
06 FAT16            42 SFS              87 NTFS volume set  db CP/M / CTOS / .
07 HPFS/NTFS/exFAT  4d QNX4.x           88 Linux plaintext  de Dell Utility
08 AIX              4e QNX4.x 2nd part  8e Linux LVM        df BootIt
09 AIX bootable     4f QNX4.x 3rd part  93 Amoeba           e1 DOS access
0a OS/2 Boot Manag  50 OnTrack DM       94 Amoeba BBT       e3 DOS R/O
0b W95 FAT32        51 OnTrack DM6 Aux  9f BSD/OS           e4 SpeedStor
0c W95 FAT32 (LBA)  52 CP/M             a0 IBM Thinkpad hi  ea Linux extended
0e W95 FAT16 (LBA)  53 OnTrack DM6 Aux  a5 FreeBSD          eb BeOS fs
0f W95 Ext'd (LBA)  54 OnTrackDM6       a6 OpenBSD          ee GPT
10 OPUS             55 EZ-Drive         a7 NeXTSTEP         ef EFI (FAT-12/16/
11 Hidden FAT12     56 Golden Bow       a8 Darwin UFS       f0 Linux/PA-RISC b
12 Compaq diagnost  5c Priam Edisk      a9 NetBSD           f1 SpeedStor
14 Hidden FAT16 <3  61 SpeedStor        ab Darwin boot      f4 SpeedStor
16 Hidden FAT16     63 GNU HURD or Sys  af HFS / HFS+       f2 DOS secondary
17 Hidden HPFS/NTF  64 Novell Netware   b7 BSDI fs          fb VMware VMFS
18 AST SmartSleep   65 Novell Netware   b8 BSDI swap        fc VMware VMKCORE
1b Hidden W95 FAT3  70 DiskSecure Mult  bb Boot Wizard hid  fd Linux raid auto
1c Hidden W95 FAT3  75 PC/IX            bc Acronis FAT32 L  fe LANstep
1e Hidden W95 FAT1  80 Old Minix        be Solaris boot     ff BBT

Aliases:
   linux          - 83
   swap           - 82
   extended       - 05
   uefi           - EF
   raid           - FD
   lvm            - 8E
   linuxex        - 85
Hex code or alias (type L to list all): c

Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): p
Disk /dev/sdb: 29.72 GiB, 31914983424 bytes, 62333952 sectors
Disk model: Flash Disk
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: 0x813d368b

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdb1          2048  2099199  2097152    1G  c W95 FAT32 (LBA)
/dev/sdb2       2099200 62333951 60234752 28.7G 83 Linux

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

格式化并挂载

[root@archlinux ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   64G  0 disk
└─sda1   8:1    0   64G  0 part /
sdb      8:16   1 29.7G  0 disk
├─sdb1   8:17   1    1G  0 part
└─sdb2   8:18   1 28.7G  0 part
sr0     11:0    1 1024M  0 rom
[root@archlinux ~]#
[root@archlinux ~]# mkfs.vfat -F 32 /dev/sdb1
mkfs.fat 4.1 (2017-01-24)
[root@archlinux ~]# mkfs.ext4 /dev/sdb2
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 7529344 4k blocks and 1884160 inodes
Filesystem UUID: cbbfe84e-55a1-47c4-9534-ed162275f598
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@archlinux ~]# mount /dev/sdb2 /mnt/
[root@archlinux ~]# mkdir /mnt/boot
[root@archlinux ~]# mount /dev/sdb1 /mnt/boot/
[root@archlinux ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
dev            devtmpfs  478M     0  478M   0% /dev
run            tmpfs     487M  540K  486M   1% /run
/dev/sda1      ext4       63G  2.8G   57G   5% /
tmpfs          tmpfs     487M     0  487M   0% /dev/shm
tmpfs          tmpfs     487M     0  487M   0% /sys/fs/cgroup
tmpfs          tmpfs     487M     0  487M   0% /tmp
tmpfs          tmpfs      98M     0   98M   0% /run/user/0
/dev/sdb2      ext4       29G   45M   27G   1% /mnt
/dev/sdb1      vfat     1022M  4.0K 1022M   1% /mnt/boot

系统安装

根据自己的机器型号下载不通的版本http://mirrors.ustc.edu.cn/archlinuxarm/os/rpi/
rpi_os

[root@archlinux ~]# wget http://mirrors.ustc.edu.cn/archlinuxarm/os/rpi/ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz
--2020-08-01 21:19:57--  http://mirrors.ustc.edu.cn/archlinuxarm/os/rpi/ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz
Resolving mirrors.ustc.edu.cn (mirrors.ustc.edu.cn)... 202.141.176.110, 2001:da8:d800:95::110
Connecting to mirrors.ustc.edu.cn (mirrors.ustc.edu.cn)|202.141.176.110|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 566548464 (540M) [application/gzip]
Saving to: ‘ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz’

ArchLinuxARM-2020.06-rpi-3-rootf 100%[=======================================================>] 540.30M  4.39MB/s    in 98s

2020-08-01 21:21:35 (5.49 MB/s) - ‘ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz’ saved [566548464/566548464]

[root@archlinux ~]# wget http://mirrors.ustc.edu.cn/archlinuxarm/os/rpi/ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz.md5
--2020-08-01 21:43:36--  http://mirrors.ustc.edu.cn/archlinuxarm/os/rpi/ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz.md5
Resolving mirrors.ustc.edu.cn (mirrors.ustc.edu.cn)... 202.141.176.110, 2001:da8:d800:95::110
Connecting to mirrors.ustc.edu.cn (mirrors.ustc.edu.cn)|202.141.176.110|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 75 [application/octet-stream]
Saving to: ‘ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz.md5’

ArchLinuxARM-2020.06-rpi-3-rootf 100%[=======================================================>]      75  --.-KB/s    in 0.06s

2020-08-01 21:43:36 (1.22 KB/s) - ‘ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz.md5’ saved [75/75]

[root@archlinux ~]# cat ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz.md5
4ca94920471faacfcf2e89e1e13de3cf  ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz
[root@archlinux ~]#
[root@archlinux ~]# md5sum ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz
4ca94920471faacfcf2e89e1e13de3cf  ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz

[root@archlinux ~]# bsdtar -xpf ArchLinuxARM-2020.06-rpi-3-rootfs.tar.gz -C /mnt
[root@archlinux ~]# ls /mnt/
bin  boot  dev	etc  home  lib	lost+found  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@archlinux ~]#
[root@archlinux ~]# ls /mnt/boot/
bcm2710-rpi-3-b.dtb	  bootcode.bin	dtbs	      fixup_cd.dat  Image.gz			  mkscr		start_cd.elf
bcm2710-rpi-3-b-plus.dtb  boot.scr	fixup4cd.dat  fixup.dat     initramfs-linux-fallback.img  start4cd.elf	start_db.elf
bcm2710-rpi-cm3.dtb	  boot.txt	fixup4.dat    fixup_db.dat  initramfs-linux.img		  start4db.elf	start.elf
bcm2711-rpi-4-b.dtb	  config.txt	fixup4db.dat  Image	    kernel8.img			  start4.elf
[root@archlinux ~]# umount /mnt/boot/
[root@archlinux ~]# umount /mnt/

启动树莓派

插上网线,连上电源,开机。
网线口绿灯亮,证明网络通,可以SSH登录。
普通用户alarm/alarm
超级用户root/root,没有更改sshd服务配置之前,root用户无法远程登录。

问题

  • Raspberry Pi 启动后,系统正确安装且网络无异常,但SSH无法连接?

    检查系统dhcpcd.service服务是否开机自启动

    1、将系统分区挂载至/mnt

    2、查看目录/mnt/etc/systemd/system/multi-user.target.wants/中有无dhcpcd.service服务的文件链接

    [root@archlinux ~]# cd /mnt/etc/systemd/system/multi-user.target.wants/
    [root@archlinux multi-user.target.wants]# ls -lrt
    total 0
    lrwxrwxrwx 1 root root 40 Jun 11 20:57 remote-fs.target -> /usr/lib/systemd/system/remote-fs.target
    lrwxrwxrwx 1 root root 48 Jun 11 20:58 systemd-resolved.service -> /usr/lib/systemd/system/systemd-resolved.service
    lrwxrwxrwx 1 root root 48 Jun 11 20:58 systemd-networkd.service -> /usr/lib/systemd/system/systemd-networkd.service
    lrwxrwxrwx 1 root root 36 Jun 11 20:58 sshd.service -> /usr/lib/systemd/system/sshd.service
    

    3、若无,添加开机dhcpcd.service自启动;如有,排查其它原因

    [root@archlinux ~]# cd /mnt/etc/systemd/system/multi-user.target.wants/
    [root@archlinux multi-user.target.wants]# ln -sf /usr/lib/systemd/system/dhcpcd.service dhcpcd.service
    [root@archlinux multi-user.target.wants]# ls -lrt
    total 0
    lrwxrwxrwx 1 root root 40 Jun 11 20:57 remote-fs.target -> /usr/lib/systemd/system/remote-fs.target
    lrwxrwxrwx 1 root root 48 Jun 11 20:58 systemd-resolved.service -> /usr/lib/systemd/system/systemd-resolved.service
    lrwxrwxrwx 1 root root 48 Jun 11 20:58 systemd-networkd.service -> /usr/lib/systemd/system/systemd-networkd.service
    lrwxrwxrwx 1 root root 36 Jun 11 20:58 sshd.service -> /usr/lib/systemd/system/sshd.service
    lrwxrwxrwx 1 root root 38 Aug  1 22:56 dhcpcd.service -> /usr/lib/systemd/system/dhcpcd.service
    

补充

  • 格式化磁盘时使用哪种分区表要开机器的启动引导方式,Linux ARM用的是DOS格式。
  • 需要网线是因为我不知道在没显示器的情况下怎么WiFi连接,安装raspbian-buster系统时可以在根目录放置wpa_supplicant.conf文件,但在Arch Linux ARM系统上我没有测试,不确定可不可行,如果有知道的同学麻烦告诉我一下。
  • 对于Linux系统各个发行版本的争论一直都有,极端心态不可取,各玩各的就挺好的,自己用什么发行版自己决定就好,搞鄙视链就挺头大的。
  • 如果有换系统的打算,建议先虚拟机或双系统使用一段时间,Linux的软件生态还不是很健全,某些软件真没有,微软在中国发展这么多年不是吃白饭的。

参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值