我的SD卡是64GB,但是只用了一部分,剩余空间未扩展。
查看磁盘使用情况
[root@localhost ~]# df -h #查看当前磁盘,只用了一部分
Filesystem Size Used Avail Use% Mounted on
/dev/root 1.4G 1.2G 211M 85% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 17M 1.9G 1% /run tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/mmcblk0p1 286M 52M 235M 18% /boot tmpfs 391M 0 391M 0% /run/user/0
查看分区使用情况
[root@localhost ~]# fdisk -l
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 8192 593919 292864 c W95 FAT32 (LBA)
/dev/mmcblk0p2 593920 1593343 499712 82 Linux swap / Solaris
/dev/mmcblk0p3 1593344 4524031 1465344 83 Linux
使用fdisk分配磁盘
[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.
Command (m for help): d #删除分区
Partition number (1-3, default 3): 3 #删除分区3,即/dev/mmcblk0p3 Partition 3 is deleted 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 #分区3 First sector (2048-124735487, default 2048): 1593344 #输入分区3的起始扇区,通过fdisk -l命令得到 Last sector, +sectors or +size{K,M,G} (1593344-124735487, default 124735487): #最后一个扇区,默认即可 Using default value 124735487 Partition 3 of type Linux and of size 58.7 GiB is set 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@localhost ~]# reboot #操作完成需要重启
重启之后,查询空间没有变化,需要输入以下命令
[root@localhost ~]# sudo 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 = 8 The filesystem on /dev/mmcblk0p3 is now 15392768 blocks long.
此时容量已经扩展了
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/root 58G 1.2G 57G 2% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 2.0G 17M 1.9G 1% /run tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/mmcblk0p1 286M 52M 235M 18% /boot tmpfs 391M 0 391M 0% /run/user/0