在树莓派安装centos7之前要准备材料:
树莓派主板 3b/3b+ 安卓充电线
16g 以上内存卡
读卡器
CentOS-Userland-7-armv7hl-RaspberryPI-Minimal-1810-sda.raw.xz
2.下载Win32DiskImager,用于把系统写到内存卡里面:
打开Win32DiskImager选择下载好的镜像文件,选好对应的盘,点击写入,等待提示写入成功。
写入成功修改剩下的盘里面的cmdline.txt,增加固定ip;为了等一下连接。增加完后保存退出插到树莓派中启动树莓派。
通过SecureCRT 连接树莓派ip172.22.42.100 用户名和密码默认为:
用户名:root
密码:centos
扩展内存空间:
进入硬盘分区软件: fdisk /dev/mmcblk0
[root@centos-rpi2 ~]# 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):
查看旧分区情况: p (经过多次安装有可能会出现只有两个分区的情况)
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: 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 30375935 14003200 83 Linux
Command (m for help):
删除分区,最后一个分区:d 如果你的分区中只有两个,删除第二个。
Command (m for help): d
Partition number (1-3, default 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):
First sector (2074624-62333951, default 2074624):
Using default value 2074624
Last sector, +sectors or +size{K,M,G} (2074624-62333951, default 62333951):
Using default value 62333951
Partition 3 of type Linux and of size 28.8 GiB is set
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
(如果刚刚添加的不是分区3,那就改成resize2fs /dev/mmcblk0p2)
最后查看空间大小 : df -h
[root@172 ~]# 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 7532416 blocks long.
[root@172 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 14G 540M 13.9G 3% /
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
[root@172 ~]#