Raspberry Pi (2): Expand the remaining space of the SD card

I don't know much about disk mounting, and I will add it later. I only post the record of my successful operation.
I have a 16G memory card, but looking at the disk, only half of it is available.

Disk usage before operation

local ) df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/root       7.0G  6.7G     0  100% /
devtmpfs        1.8G     0  1.8G    0% /dev
tmpfs           1.9G     0  1.9G    0% /dev/shm
tmpfs           1.9G   17M  1.9G    1% /run
tmpfs           5.0M  4.0K  5.0M    1% /run/lock
tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   52M  201M   21% /boot
tmpfs           376M     0  376M    0% /run/user/1000

operating

  1. cat /sys/block/mmcblk0/mmcblk0p2/start Record start position (532480)
  2. fdisk /dev/mmcblk0
    Command (m for help): d
    Partition number (1,2, default 2): 2
    
    Partition 2 has been deleted.
    
    Command (m for help): n
    Partition type
       p   primary (1 primary, 0 extended, 3 free)
       e   extended (container for logical partitions)
    Select (default p): p
    Partition number (2-4, default 2): 2
    First sector (2048-31116287, default 2048): 532480 (上边记录的起始位置)
    Last sector, +/-sectors or +/-size{
          
          K,M,G,T,P} (532480-31116287, default 31116287): (这里回车默认即可)
    
    Created a new partition 2 of type 'Linux' and of size 14.6 GiB.
    Partition #2 contains a ext4 signature.
    
    Do you want to remove the signature? [Y]es/[N]o: n
    
    Command (m for help): w
    
    The partition table has been altered.
    Syncing disks.
    
  3. reboot
  4. Hard disk size update resize2fs /dev/mmcblk0p2

Disk usage after operation

root ) df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/root        15G  6.7G  7.1G   49% /
devtmpfs        1.8G     0  1.8G    0% /dev
tmpfs           1.9G     0  1.9G    0% /dev/shm
tmpfs           1.9G  8.5M  1.9G    1% /run
tmpfs           5.0M  4.0K  5.0M    1% /run/lock
tmpfs           1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   52M  201M   21% /boot
tmpfs           376M     0  376M    0% /run/user/1000

Guess you like

Origin blog.csdn.net/z772532526/article/details/113727104