快,快到碗里来

快到碗里来的博客

winepot2005@gmail.com

http://github.com/inpot

快,快到碗里来

贝壳云小钢炮root分区扩容

贝壳云小钢炮root分区扩容

小钢炮刷机后,root分区仅700多M,但是硬件是8G,我就感觉奇怪了,剩下的哪去了呢.首先尝试创建新分区,发现有不连续的两段.分区为p2,p3. 自动挂载太麻烦, docker又在root分区,所以尝试扩容

  1. 查看当前分区状况
   [root@beikeyun:/]# lsblk
   root@beikeyun:/]# fdisk -l
   Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
   Units: sectors of 1 * 512 = 512 bytes
   Sector size (logical/physical): 512 bytes / 4096 bytes
   I/O size (minimum/optimal): 4096 bytes / 4096 bytes
   
   
   Disk /dev/mmcblk0: 7.3 GiB, 7818182656 bytes, 15269888 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: 0x00000000
   
   Device         Boot   Start      End  Sectors  Size Id Type
   /dev/mmcblk0p1        32768  1671167  1638400  800M 83 Linux
   /dev/mmcblk0p2         2048    32767    30720   15M 83 Linux
   /dev/mmcblk0p3      1671168 15269887 13598720  6.5G 83 Linux
   
   Partition table entries are not in disk order.

  1. 可以看出p1和p3连续的, 顺序为p2,p1,p3. 所以就简单了,直接方案就是删除p1,p3,再重建p1

   [root@beikeyun:/]# lsblk
   NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
   mmcblk0      179:0    0  7.3G  0 disk
   ├─mmcblk0p1  179:1    0  800M  0 part /
   ├─mmcblk0p2  179:2    0   15M  0 part
   └─mmcblk0p3  179:3    0  6.5G  0 part
   mmcblk0boot0 179:32   0    4M  1 disk
   mmcblk0boot1 179:64   0    4M  1 disk
   mmcblk0rpmb  179:96   0  512K  0 disk
  1. fdisk删除p3,p1,并重建p1

    [root@beikeyun:/]# fdisk /dev/mmcblk0
    
    Welcome to fdisk (util-linux 2.32.1).
    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
    
    Partition 3 has been deleted.
    
    Command (m for help): d
    Partition number (1,2, default 2): 1 //删除1
       
    Partition 1 has been deleted.
    
    Command (m for help): n  //重新建1
    Partition type
       p   primary (1 primary, 0 extended, 3 free)
       e   extended (container for logical partitions)
    Select (default p):
       
    Using default response p.
    Partition number (1,3,4, default 1): //分配号
    First sector (32768-15269887, default 32768): //默认起始位置
    Last sector, +sectors or +size{K,M,G,T,P} (32768-15269887, default 15269887):
       
    Created a new partition 1 of type 'Linux' and of size 7.3 GiB.
    Partition #1 contains a ext4 signature.
       
    Do you want to remove the signature? [Y]es/[N]o: N    //p1上有数据,原分区为ext4,保持数据
       
    Command (m for help): w
       
    The partition table has been altered.
    Syncing disks.
       
    
  2. 继续查看分区

    [root@beikeyun:/]# df
    Filesystem                Size      Used Available Use% Mounted on
    /dev/mmcblk0p1          771.4M    716.6M         0 100% /
    devtmpfs                490.3M         0    490.3M   0% /dev
    tmpfs                   492.7M         0    492.7M   0% /dev/shm
    tmpfs                   492.7M      3.1M    489.7M   1% /tmp
    tmpfs                   492.7M    100.0K    492.6M   0% /run
    tmpfs                   492.7M         0    492.7M   0% /media
    cgroup                  492.7M         0    492.7M   0% /sys/fs/cgroup
    /dev/mmcblk0p1          771.4M    716.6M         0 100% /var/lib/docker
    
  3. p1似乎还没有扩容,但是使用lsblk查看分区大小

[root@beikeyun:/]# lsblk
NAME     MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0   179:0  0 7.3G 0 disk
├─mmcblk0p1 179:1  0 7.3G 0 part /
└─mmcblk0p2 179:2  0  15M 0 part
mmcblk0boot0 179:32  0  4M 1 disk
mmcblk0boot1 179:64  0  4M 1 disk
mmcblk0rpmb 179:96  0 512K 0 disk
  1. 刷新根分区并查看状态
[root@beikeyun:~]# partprobe /dev/mmcblk0
[root@beikeyun:~]# resize2fs /dev/mmcblk0p1   //resize2fs 针对ext2,ext3,ext4 文件格式
resize2fs 1.44.2 (14-May-2018)
Filesystem at /dev/mmcblk0p1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p1 is now 1904640 (4k) blocks long.

最后再用df查看

[root@beikeyun:~]# df
Filesystem                Size      Used Available Use% Mounted on
/dev/mmcblk0p1            7.1G    717.6M      6.1G  10% /
devtmpfs                490.3M         0    490.3M   0% /dev
tmpfs                   492.7M         0    492.7M   0% /dev/shm
tmpfs                   492.7M      3.0M    489.7M   1% /tmp
tmpfs                   492.7M    100.0K    492.6M   0% /run
tmpfs                   492.7M         0    492.7M   0% /media
cgroup                  492.7M         0    492.7M   0% /sys/fs/cgroup
/dev/mmcblk0p1            7.1G    717.6M      6.1G  10% /var/lib/docker

嗯.完美扩容.