使用CentOS 7官网镜像进行烧录的系统大约只占用了2G的空间,但是TF卡却有30G的空间可用,所以调整/root分区空间变的尤为重要,通过本文的例子即可将剩余空间全部回收利用。
环境说明
设备:Raspberry Pi 2b
系统:CentOS-Userland-7-armv7hl-Minimal
存储:SanDisk Ultra 32GB
安装基本库:
步骤清单:
==============
步骤:
执行命令:
fdisk /dev/mmcblk0
执行命令:d (删除分区3)
执行命令:p (按这时候应该是少了一个分区了)
执行命令:n (加分区)
执行命令:p (主要分区)
直接回车
后面的值默认即可
执行命令:p
执行命令:w
然后reboot
执行命令: resize2fs /dev/mmcblk0p3 重新加载分区信息
执行df -h查看
==============
[作者:漫步云端服务器 Joyist] - http://chdong.top/
http://av98.byethost10.com/index.php?thread-99.htm
实战操作开始
在登录SSH终端输入:fdisk /dev/mmcblk0 //进入硬盘分区软件
1 2 3 4 5 6 7 8 | [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
——查看旧分区情况
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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: 0x000c831c Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 1026047 512000 c W95 FAT32 (LBA) /dev/mmcblk0p2 1026048 2074623 524288 82 Linux swap / Solaris /dev/mmcblk0p3 2074624 6268927 2097152 83 Linux Command (m for help): |
d
——删除分区,并按照提示删除第三个分区
1 2 3 4 5 | Command (m for help): d Partition number (1-3, default 3): Partition 3 is deleted Command (m for help): |
n
——添加一个分区,空间起始位置按照系统默认(默认是最大空间)
1 2 3 4 5 | Command (m for help): n Partition type : p primary (2 primary, 0 extended, 2 free ) e extended Select (default p): |
执行命令:p (主要分区)
1 2 3 4 5 6 7 8 9 | 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): |
p
——查看新分区情况
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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: 0x000c831c Device Boot Start End Blocks Id System /dev/mmcblk0p1 2048 1026047 512000 c W95 FAT32 (LBA) /dev/mmcblk0p2 1026048 2074623 524288 82 Linux swap / Solaris /dev/mmcblk0p3 2074624 62333951 30129664 83 Linux Command (m for help): |
w
——写入分区信息并退出软件
1 2 3 4 5 6 7 8 9 10 | 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@centos-rpi2 ~] # |
在终端中输入:reboot
重启树莓派
1 2 3 4 5 | [root@centos-rpi2 ~] # reboot Connection closed by foreign host. Disconnected from remote host(pi会话) at 14:55:14. Type `help' to learn how to use Xshell prompt. [d:\~]$ |
在树莓派开机后登录SSH在终端输入:
resize2fs /dev/mmcblk0p3重新加载分区信息
1 2 3 4 5 6 | [root@centos-rpi2 ~] # 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@centos-rpi2 ~] # |
[作者:Joyist] - http://chdong.top/
操作结果
使用:df -h
查看新的分区信息表
1 2 3 4 5 6 7 8 9 10 | [root@centos-rpi2 ~] # df -h Filesystem Size Used Avail Use% Mounted on /dev/root 29G 954M 27G 4% / devtmpfs 460M 0 460M 0% /dev tmpfs 464M 24K 464M 1% /dev/shm tmpfs 464M 12M 452M 3% /run tmpfs 464M 0 464M 0% /sys/fs/cgroup /dev/mmcblk0p1 500M 45M 455M 9% /boot tmpfs 93M 0 93M 0% /run/user/0 [root@centos-rpi2 ~] # |
/root分区下的空间已经被扩展至29G了,与内存卡空间基本一直。
大功告成。
如果以后出现安装不了文件的情况,请尝试输入sudo apt-get update 和 sudo apt-get upgrade。