树苺派4B存储空间扩容SD卡

1.问题描述

树苺派4B,配置32GB的SD卡。
系统安装完毕,拷贝程序时,因为空间有限而中断。
通过输入df或df -h命令查询树莓派SD 卡空间使用情况

pi@raspberrypi:/ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       6.8G  6.5G   51M 100% /
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           2.0G  8.6M  1.9G   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   40M  213M  16% /boot
tmpfs           391M     0  391M   0% /run/user/1000

由上可见,系统未能完全识别SD卡空间。

2.解决方法

输入如下命令

pi@raspberrypi:/ $ sudo raspi-config

在弹出的Raspberry Pi Software Configuration Tool(raspi-config)配置界面中,依次选择
(1)7 Advanced Options: Configure advanced settings
(2)Expand Filesystem: Ensures that all of the SD card storage is available to the os
回车,搞定。
将在terminal中显示如下内容信息

pi@raspberrypi:/ $ sudo raspi-config

Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): Disk /dev/mmcblk0: 29.7 GiB, 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
Disklabel type: dos
Disk identifier: 0x9fd26ab3

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        8192   532480   524289  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      540672 15138815 14598144    7G 83 Linux

Command (m for help): Partition number (1,2, default 2): 
Partition 2 has been deleted.

Command (m for help): Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): Partition number (2-4, default 2): First sector (2048-62333951, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (540672-62333951, default 62333951): 
Created a new partition 2 of type 'Linux' and of size 29.5 GiB.
Partition #2 contains a ext4 signature.

Command (m for help): 
Disk /dev/mmcblk0: 29.7 GiB, 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
Disklabel type: dos
Disk identifier: 0x9fd26ab3

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        8192   532480   524289  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      540672 62333951 61793280 29.5G 83 Linux

Command (m for help): The partition table has been altered.
Syncing disks.

重启之后,即可正常显示全部空间。扩容完毕。

pi@raspberrypi:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        29G  6.5G   22G  24% /
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           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   40M  213M  16% /boot
tmpfs           391M     0  391M   0% /run/user/1000

你可能感兴趣的:(树苺派)