最近使用树莓派建立自动化框架时需要烧录树莓派,因是在无网络条件下,所以选择了CentOS系统
首先下载CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw.xz,并解压得到CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1804-sda.raw,
使用Win32DiskImager进行烧写到TF卡,TF卡为16G。
烧写完成之后,将TF卡插入到树莓派中,重启树莓派。
使用ssh连接树莓派,连接方式为:ssh root@192.168.0.101
连接成功,输入密码为:centos
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 430M 0 430M 0% /dev
tmpfs 488M 0 488M 0% /dev/shm
tmpfs 488M 13M 475M 3% /run
tmpfs 488M 0 488M 0% /sys/fs/cgroup
/dev/mmcblk0p4 3.3G 2.5G 795M 76% /
/dev/mmcblk0p2 641M 194M 441M 31% /boot
/dev/mmcblk0p1 29M 13M 17M 45% /boot/fw
tmpfs 98M 8.0K 98M 1% /run/user/42
tmpfs 98M 0 98M 0% /run/user/0
可以看出centos 7 只使用了5G左右,而应11G剩余空间未能使用
[root@localhost ~]# fdisk -l
Disk /dev/mmcblk0: 15.6 GB, 15552479232 bytes, 30375936 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: 0x0003dba7
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 61439 29696 c W95 FAT32 (LBA)
/dev/mmcblk0p2 * 61440 1427455 683008 83 Linux
/dev/mmcblk0p3 1427456 2426879 499712 82 Linux swap / Solaris
/dev/mmcblk0p4 2426880 9459711 3516416 83 Linux
[root@localhost ~]# reboot
Connection to 192.168.0.101 closed by remote host.
Connection to 192.168.0.101 closed.
重启之后重新计算/dev/mmcblk0p4分区大小。
[root@localhost ~]# resize2fs /dev/mmcblk0p4
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mmcblk0p4 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p4 is now 3493632 blocks long.
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 430M 0 430M 0% /dev
tmpfs 488M 0 488M 0% /dev/shm
tmpfs 488M 13M 475M 3% /run
tmpfs 488M 0 488M 0% /sys/fs/cgroup
/dev/mmcblk0p4 14G 2.5G 11G 19% /
/dev/mmcblk0p2 641M 194M 441M 31% /boot
/dev/mmcblk0p1 29M 13M 17M 45% /boot/fw
tmpfs 98M 8.0K 98M 1% /run/user/42
tmpfs 98M 0 98M 0% /run/user/0
[root@localhost ~]#
可以从上面看出TF卡其他内存已经加入到Linux系统之中,但在删除分区之时需要仔细,
之前存在删除/dev/mmcblk0p3,并且内存空间无法加入的情况,使用resize2fs /dev/mmcblk0p3时,显示为Bad magic 问题,究其原因为/dev/mmcblk0p3 为swap 分区,因此在删除分区时,最后选择/dev/mmcblk0p4进行删除,并在重新创建分区。