树莓派3安装centos7以及wifi配置、根目录磁盘分区扩展

系统文件下载

打开centos的官方网站https://www.centos.org/download/,点击下图中的红色标记区域的链接地址http://wiki.centos.org/Download,如下图:

image.png

在页面找到下图,我这里下载mini版系统镜像,不安装桌面环境,说实话树莓派3运行桌面环境真心不流畅。

image.png

镜像的下载地址如下:
http://isoredirect.centos.org/altarch/7/isos/armhfp/CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1810-sda.raw.xz

镜像写入sd卡工具下载安装

下载完镜像可以看到文件是sda.raw.xz结尾的,之前安装img镜像使用的win32diskimager工具是不能使用了,这里使用推荐的balenaEtcher镜像写入工具。
官网地址:https://www.balena.io/etcher/

image.png

点击“Download for windows x64”进行下载,下载时候双击安装即可。

镜像写入

电脑插上MicroSD卡,计算机识别后,打开安装的balenaEtcher工具。

  • 选择下载的镜像
  • 选择(sd卡一般自动选了)
  • 开始写入。
    等待完成即可。

开机启动

写入成功后,sd卡插入树莓派中,连接显示器,插上电源即可开机启动了

登陆树莓和无线网配置

在镜像下载页面的下载地址后面有个“info”的链接地址https://wiki.centos.org/SpecialInterestGroup/AltArch/armhfp

image.png

打开页面后,注意看这里

image.png

这里详细的说明了root账号默认密码为centos,启用的是eth0网卡,默认为dhcp方式。

现在就可以使用root账号登陆树莓派了,密码是centos

接着看刚刚的info页面,找到下图中的文字说明,并点击图中标记的链接地址https://nullr0ute.com/2016/09/connect-to-a-wireless-network-using-command-line-nmcli/

image

可以看到下图内容:

image.png

解释一下

# 查看设备状态
nmcli radio
# 查看驱动状态
nmcli device
# 扫描wifi信号
nmcli device wifi rescan
# 获取wifi信号列表
nmcli device wifi list
# 连接wifi,SSID-Name为wifi名称,wireless-password为wifi对应的密码
nmcli device wifi connect SSID-Name password wireless-password

账号密码输入正确的情况下是很轻易的就能连接上wifi了。

查看是否连接上wifi

ifconfig

查看wlan0是否有ip地址信息即可。

根目录扩展

连上网了,想执行一下yum update,提示磁盘空间不够了,使用命令df -h可以看到新安装的centos7的'/'分区大小只有1.2G,已经使用91%了。分区总共使用大概2G左右,而我使用的是32G的MicroSD卡,因此需要扩展根目录挂载的分区大小。

查看文件系统使用情况(我这里已经扩展了,原来根分区只有1.2G)

[root@localhost ~]# df -h
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   13M  452M   3% /run
tmpfs           464M     0  464M   0% /sys/fs/cgroup
/dev/mmcblk0p1  667M   43M  625M   7% /boot
tmpfs            93M     0   93M   0% /run/user/1000
tmpfs            93M     0   93M   0% /run/user/0

查看分区挂载情况
lsblk

[root@localhost ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0     179:0    0 29.7G  0 disk
├─mmcblk0p2 179:2    0  488M  0 part [SWAP]
├─mmcblk0p3 179:3    0 28.6G  0 part /
└─mmcblk0p1 179:1    0  668M  0 part /boot

可以知道根目录挂载的是mmcblk0p3分区,调整mmcblk0p3的分区大小即可。
fdisk /dev/mmcblk0

[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.

# 这里输入m查看一下帮助信息
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help):

扩展分区的步骤如下:

  • 通过输入d删除分区
Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted

Command (m for help):
  • 输入 n 新建分区(之后一直敲回车就行)
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): 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):
  • 输入p,查看分区结果
Command (m for help): p

Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes, 62333952 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
Disk label type: dos
Disk identifier: 0x000cc7a5

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048     1370111      684032    c  W95 FAT32 (LBA)
/dev/mmcblk0p2         1370112     2369535      499712   82  Linux swap / Solaris
/dev/mmcblk0p3         2369536    62333951    29982208   83  Linux

Command (m for help):

分区起诉已经变大了,将剩余空间全部给了分区(我这里已经分过区了,现在看不到了)。

  • 输入w写入分区
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.

  • reboot重启
  • 重启之后,执行命令resize2fs /dev/mmcblk0p3,使分区生效。
[root@localhost ~]# resize2fs /dev/mmcblk0p3
resize2fs 1.42.9 (28-Dec-2013)

我安装了一个mariadb后,在mariadb启动的情况下,查看内存使用情况如下:

[root@localhost ~]# free -m
              total        used        free      shared  buff/cache   available
Mem:            927          96         684          11         146         774
Swap:           487           0         487

centos7在树莓派上还是很流畅的,文章到这里也就结束了!
祝各位玩的开心!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,233评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,013评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,030评论 0 241
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,827评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,221评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,542评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,814评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,513评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,225评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,497评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,998评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,342评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,986评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,055评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,812评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,560评论 2 271
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,461评论 2 266