树莓派安装centos7

详细介绍如何在树莓派 3b+ 上安装 Centos 7。


准备工作

首先下载树莓派的centos7镜像文件

树莓派centos7镜像文件

然后解压,这里用linux解压失败,解压后的文件只有22M,所以用windows解压后有2.3G大小

再用Etcher或者Win32Disk刻录镜像即可(有的说要用SD Formatter格式化TF卡)

登录信息

默认登录账号是root 密码是centos

安装后需要做的操作:

关闭selinux

setenforce 0

如果不关闭selinux,当修改ssh端口后,启动会报错Bind to port 10222 on 0.0.0.0 failed: Permission denied

关闭防火墙

systemctl disable firewalld 或者chkconfig firewalld off

开启ssh自启动

systemctl enable sshd #修改sshd端口为10222竟然报错没有权限启动

重新给tf卡分区

因为centos的image是为2G SD卡准备的,如果想用剩余空间,就得重新分配分区

操作开始 在终端中输入fdisk /dev/mmcblk0进入硬盘分区软件 在软件中输入: p——查看旧分区情况 d——删除分区,并按照提示删除第三个分区 n——添加一个分区,空间起始位置按照系统默认(默认是最大空间) p——查看新分区情况 w——写入分区信息并退出软件 在终端中输入:可以让其重启生效,但我这里没有重启还是在终端里输入partprobe即生效了 最后再执行resize2fs /dev/mmcblk0p3重新加载分区信息

下面是实际的操作过程:

[root@localhost ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.23.2).

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-3, default 3): 3
Partition 3 is deleted

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3):
First sector (2369536-62333951, default 2369536):
Using default value 2369536
Last sector, +sectors or +size{K,M,G} (2369536-62333951, default 62333951):
Using default value 62333951
Partition 3 of type Linux and of size 28.6 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@localhost ~]# partprobe
[root@localhost ~]# resize2fs /dev/mmcblk0p3
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mmcblk0p3 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 4
The filesystem on /dev/mmcblk0p3 is now 7495552 blocks long.

重新分区后查看的分区实际占用情况:

[root@localhost ~]# df -lh
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        29G  1.2G   27G   5% /
devtmpfs        460M     0  460M   0% /dev
tmpfs           464M     0  464M   0% /dev/shm
tmpfs           464M   12M  452M   3% /run
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p1  667M   38M  629M   6% /boot
tmpfs            93M     0   93M   0% /run/user/0

树莓派安装centos7参考链接

启用WIFI

/root/READEME 中有描述

== CentOS 7 userland ==

If you want to automatically resize your / partition, just type the following (as root user):
/usr/local/bin/rootfs-expand

For wifi on the rpi3, just proceed with those steps :

curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin > /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin

curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt

systemctl reboot

设置epel源

cat /etc/yum.repos.d/epel.repo

[epel]
name=Epel rebuild for armhfp
baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
enabled=1
gpgcheck=0

设置yum源

cat /etc/yum.repos.d/CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.huaweicloud.com/centos-altarch/$releasever/os/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32

#released updates
[updates]
name=CentOS-$releasever - Updates
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.huaweicloud.com/centos-altarch/$releasever/updates/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.huaweicloud.com/centos-altarch/$releasever/extras/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirrors.huaweicloud.com/centos-altarch/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-AltArch-Arm32
上次更新:
贡献者: iEchoxu