树莓派 安装 centos 7

发布于 2019-03-28  679 次阅读


centos arm 镜像地址为:

【已失效】http://mirror.centos.org/altarch/7/isos/armhfp/

1.centos 树莓派相关

http://www.21ic.com/eva/trick/201605/675705.htm

2.centos安装无线wifi模块

安装wifi模块

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

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

然后 reboot

查看无线网卡,连接wifi

nmcli  d

nmcli  d  wifi  #查看周围的wifi

nmcli d wifi connect yourSSID password 'yourpassword'  #连接wifi  

nmcli d  show wlan0  #查看wlan0的状态

设置静态 ip

#设置网络配置信息
vi   etc/sysconfig/network-script/ifcfg-????   #????是wifi的名字

BOOTPROTO=static              #静态IP
IPADDR=192.168.31.160       #IP地址
GATEWAY=192.168.31.1    #默认网关
NETMASK=255.255.255.0  #子网掩码

修改DNS

 vi /etc/resolv.conf #修改以下内容
nameserver 8.8.8.8 #google域名服务器
nameserver 8.8.4.4 #google域名服务器  223.5.5.5  阿里dns 
nameserver 114.114.114.114  

修改时间

yum install -y ntp
systemctl enable ntpd 
systemctl start ntpd

修改时区

cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

3.centos扩展磁盘空间

更新:

直接阅读 ~/readme ,执行 rootfs-expand 命令即可,无需执行下面的步骤

Filesystem      Size  Used Avail Use% Mounted on
rootfs          2.9G  2.8G   15M 100% /
/dev/root       2.9G  2.8G   15M 100% /
devtmpfs        214M     0  214M   0% /dev
tmpfs            44M  244K   44M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            88M     0   88M   0% /run/shm
/dev/mmcblk0p1   56M   19M   37M  34% /boot
tmpfs            88M     0   88M   0% /tmp
pi@raspberrypi ~ $ cat /sys/block/mmcblk0/mmcblk0p2/start   # 查看第二分区的起始地址,后面会用到
122880


pi@raspberrypi ~ $ sudo fdisk /dev/mmcblk0   #使用fdisk操作磁盘

Command (m for help): d   #d,删除分区
Partition number (1-4): 2   # 2,删除第二分区

Command (m for help): n  #创建一个新分区

Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended

Select (default p): p  #创建主分区

Partition number (1-4, default 2): 2  #分区2

First sector (2048-7744511, default 2048): 122880  #输入第一次得到的第二分区起始扇区

Last sector, +sectors or +size{K,M,G} (122880-7744511, default 7744511):  #最后一个sector,默认即可Enter

Using default value 7744511

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.


pi@raspberrypi ~ $ sudo reboot  #设置完成需要重启,sudo reboot

pi@raspberrypi ~ $ sudo resize2fs /dev/mmcblk0p2

4.centos修改yum源

https://zhangzifan.com/centos-nginx-yum-source.html

仅供参考,arm的centos源地址为:

【已失效】http://mirror.centos.org/altarch/7.3.1611/os/armhfp/Packages/

5.附centos下各命令

http://www.cnblogs.com/summergarden/archive/2013/05/25/3098417.html

无法安装epel-release

运行以下代码后yum安装

cat > /etc/yum.repos.d/epel.repo << EOF
[epel]
name=Epel rebuild for armhfp
baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
enabled=1
gpgcheck=0

EOF

搭建LAMP环境 若 安装 mariadb 出现 

yum [Errno 256] No more mirrors to try

  错误时

运行以下命令

yum clean all
yum makecache


君子慎独,不欺暗室。卑以自牧,含章可贞。