RaspberryPi 服务器相关
Summary: Author: 张亚飞 | Read Time: 3 minute read | Published: 2016-04-11
Filed under
—
Categories:
Linux
—
Tags:
Note,
RaspberryPi
树莓派^^
RaspberryPi
树莓派
RaspberryPi
安装 CentOS
系统
下载
CentOS
的RaspberryPI
定制系统
wget https://mirrors.huaweicloud.com/centos-altarch/8.1.1911/isos/armhfp/CentOS-Userland-8-armv7hl-generic-GNOME-1911-sda.raw.xz
- 安装
SD Card Formatter
格式化 SD
卡
Mac
下卸载已挂载的磁盘
$ diskutil list
/dev/disk3 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *64.0 GB disk3
1: Windows_NTFS RaspberryPi 64.0 GB disk3s1
$ diskutil umount `mount | grep "/dev/disk3" | awk '{print $3}'`
Volume RaspberryPi on disk3s1 unmounted
- 写入镜像文件
SD
卡
$ sudo xzcat CentOS-Userland-8-armv7hl-generic-GNOME-1911-sda.raw.xz | sudo gdd of=/dev/disk3 bs=32M status=progress
Password:
5548285952 bytes (5.5 GB, 5.2 GiB) copied, 2006 s, 2.8 MB/s
0+84680 records in
0+84680 records out
5549064192 bytes (5.5 GB, 5.2 GiB) copied, 2006.41 s, 2.8 MB/s
在局域网内通过网线连接树莓派,登录 ssh root@192.168.2.155
,密码: centos
wget https://server-22400.prod.hosts.ooklaserver.net/centos-altarch/8.1.1911/isos/armhfp/CentOS-Userland-8-armv7hl-generic-Minimal-1911-sda.raw.xz
diskutil umount `mount | grep "/dev/disk9" | awk '{print $3}'`
sudo xzcat ~/Downloads/CentOS-Userland-8-armv7hl-generic-Minimal-1911-sda.raw.xz | sudo gdd of=/dev/disk9 bs=32M status=progress
使用 Raspberry Pi Imager
安装操作系统
- Get Ubuntu for IoT
- Install Ubuntu on a Raspberry Pi
- How to install Ubuntu Server on your Raspberry Pi
经常出现错误
"Verifying write failed. Contents of SD card is different then(than?)what was written to it."
建议使用 BalenaEtcher
尝试
使用 BalenaEtcher
安装系统
扩展根分区
由于系统默认的映像把根分区的空间设定得很小,因此我们需要手动扩展根分区.
虽然系统上自带了一个 rootfs-expand
自动扩展根分区的脚本,但是不知道为什么我使用了没有任何效果.所以还是得手动操作一下
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 422M 0 422M 0% /dev
tmpfs 484M 0 484M 0% /dev/shm
tmpfs 484M 26M 459M 6% /run
tmpfs 484M 0 484M 0% /sys/fs/cgroup
/dev/mmcblk0p4 3.7G 2.6G 990M 73% /
/dev/mmcblk0p2 642M 91M 531M 15% /boot
/dev/mmcblk0p1 76M 27M 50M 35% /boot/efi
tmpfs 97M 12K 97M 1% /run/user/991
tmpfs 97M 4.0K 97M 1% /run/user/0
[root@localhost ~]# fdisk -l
Disk /dev/mmcblk0: 59.6 GiB, 64021856256 bytes, 125042688 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: 0xf2739457
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 157695 155648 76M c W95 FAT32 (LBA)
/dev/mmcblk0p2 * 157696 1525759 1368064 668M 83 Linux
/dev/mmcblk0p3 1525760 2525183 999424 488M 82 Linux swap / Solaris
/dev/mmcblk0p4 2525184 10338303 7813120 3.7G 83 Linux
执行完之后,输入 d
-> 按 1 下回车 -> 输入 n
-> 输入 p
-> 按 2 下回车 -> 输入 Y
-> 输入 w
-> 按回车:
[root@localhost ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): d
Partition number (1-4, default 4):
Partition 4 has been deleted.
Command (m for help): n
Partition type
p primary (3 primary, 0 extended, 1 free)
e extended (container for logical partitions)
Select (default e): p
Selected partition 4
First sector (2525184-125042687, default 2525184):
Last sector, +sectors or +size{K,M,G,T,P} (2525184-125042687, default 125042687):
Created a new partition 4 of type 'Linux' and of size 58.4 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): w
The partition table has been altered.
Syncing disks.
再次使用 fdisk -l
查看:
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 422M 0 422M 0% /dev
tmpfs 484M 0 484M 0% /dev/shm
tmpfs 484M 26M 458M 6% /run
tmpfs 484M 0 484M 0% /sys/fs/cgroup
/dev/mmcblk0p4 3.7G 2.6G 989M 73% /
/dev/mmcblk0p2 642M 91M 531M 15% /boot
/dev/mmcblk0p1 76M 27M 50M 35% /boot/efi
tmpfs 97M 24K 97M 1% /run/user/991
tmpfs 97M 4.0K 97M 1% /run/user/0
[root@localhost ~]# fdisk -l
Disk /dev/mmcblk0: 59.6 GiB, 64021856256 bytes, 125042688 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: 0xf2739457
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 157695 155648 76M c W95 FAT32 (LBA)
/dev/mmcblk0p2 * 157696 1525759 1368064 668M 83 Linux
/dev/mmcblk0p3 1525760 2525183 999424 488M 82 Linux swap / Solaris
/dev/mmcblk0p4 2525184 125042687 122517504 58.4G 83 Linux
发现 /dev/mmcblk0p4
已从 3.7G
扩展到 58.4G
然后执行 reboot
重启树莓派.
重启之后重新连接到树莓派,注意以上Partition 4 has been deleted.
编号为4
,然后执行以下命令:
[root@localhost ~]# resize2fs /dev/mmcblk0p4
resize2fs 1.44.6 (5-Mar-2019)
Filesystem at /dev/mmcblk0p4 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 8
The filesystem on /dev/mmcblk0p4 is now 15314688 (4k) blocks long.
根分区的扩展就完成了.
扩展完成后可以执行 df -h
来检查扩展是否成功.
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 422M 0 422M 0% /dev
tmpfs 484M 0 484M 0% /dev/shm
tmpfs 484M 26M 458M 6% /run
tmpfs 484M 0 484M 0% /sys/fs/cgroup
/dev/mmcblk0p4 58G 2.7G 55G 5% /
/dev/mmcblk0p2 642M 91M 531M 15% /boot
/dev/mmcblk0p1 76M 27M 50M 35% /boot/efi
tmpfs 97M 20K 97M 1% /run/user/991
tmpfs 97M 4.0K 97M 1% /run/user/0
WIFI 连接
nmtui
Comments