当前位置: 首页 > article >正文

树莓派刷入OpenWrt后扩容overlay的方法

问题:

128G的SD卡刷入openwrt后发现可用空间不足100M(我用的squashfs固件,ext4也存在同样的问题,但能否用此方法需要自己尝试一下)。

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.0M      5.0M         0 100% /rom
tmpfs                   928.4M     64.0K    928.4M   0% /tmp
/dev/loop0               87.3M      3.3M     77.1M   4% /overlay
overlayfs:/overlay       87.3M      3.3M     77.1M   4% /
/dev/mmcblk0p1           63.9M     17.7M     46.2M  28% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

其它空间用不了,随便装几个软件就会出现空间满的问题。

解决:

1 先安装必要工具:

opkg install blkid fdisk resize2fs

2 再fdisk分区:
fdisk /dev/mmcblk0
输入p先查看原有/dev/mmcblk0p2的起始位置(我的是147456)
输入d 回车 3 删除mmcblk0p3分区(如果有做这一步,如果没有不需要)
输入d 回车 2 删除mmcblk0p2分区
输入n 回车 新建一个分区,开始位置需与原来的mmcblk0p2一致(这里是147456)
root@OpenWrt:~# fdisk /dev/mmcblk0

root@OpenWrt:~# fdisk /dev/mmcblk0
 

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

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Command (m for help): p

Disk /dev/mmcblk0: 119.08 GiB, 127865454592 bytes, 249737216 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: 0x5452574f

Device         Boot  Start       End   Sectors   Size Id Type
/dev/mmcblk0p1 *      8192    139263    131072    64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456    360447    212992   104M 83 Linux
/dev/mmcblk0p3      360448 249737215 249376768 118.9G 83 Linux

Command (m for help): d
Partition number (1-3, default 3): <----如果没有这个分区不需要删。这里删了它,是为了后面合入2做准备!

Partition 3 has been deleted.

Command (m for help): d
Partition number (1,2, default 2): <----先把2分区删了,后面会加回来的,主要是为了修改End区的值。

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):

Using default response p.
Partition number (2-4, default 2):
First sector (2048-249737215, default 2048): 147456 <----这个值一定要用上面mmcblk0p2的原始值,后面就直接回车
Last sector, +/-sectors or +/-size{K,M,G,T,P} (147456-249737215, default 249737215):

Created a new partition 2 of type 'Linux' and of size 119 GiB.
Partition #2 contains a squashfs signature.

Do you want to remove the signature? [Y]es/[N]o: N <----注意这里选No!!!

Command (m for help): w  <----保存

The partition table has been altered.
Syncing disks.

 3 重启:

reboot

4 重启后resize2fs -f /dev/loop0调分区:

root@OpenWrt:~# df -h  <----先查看,没有变
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.0M      5.0M         0 100% /rom
tmpfs                   928.4M     64.0K    928.4M   0% /tmp
/dev/loop0               87.3M      3.3M     77.1M   4% /overlay
overlayfs:/overlay       87.3M      3.3M     77.1M   4% /
/dev/mmcblk0p1           63.9M     17.7M     46.2M  28% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

root@OpenWrt:~# resize2fs -f /dev/loop0    <----调整
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/loop0 is mounted on /overlay; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 953
The filesystem on /dev/loop0 is now 124789824 (1k) blocks long.
再查看,生效:
root@OpenWrt:~#
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.0M      5.0M         0 100% /rom
tmpfs                   928.4M     64.0K    928.4M   0% /tmp
/dev/loop0              111.9G      3.3M    107.1G   0% /overlay
overlayfs:/overlay      111.9G      3.3M    107.1G   0% /
/dev/mmcblk0p1           63.9M     17.7M     46.2M  28% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

完美搞定。网上一大堆文章全是垃圾。 


http://www.kler.cn/news/357199.html

相关文章:

  • 诺贝尔物理学奖与机器学习、神经网络:一场跨时代的融合与展望
  • Spring容器详解:BeanFactory和ApplicationContext的不同
  • spring mvc后端实现过程
  • 【计算机网络 - 基础问题】每日 3 题(四十一)
  • 字节回应实习生破坏大模型训练:确有此事 但部分报道夸大失实
  • 推荐系统 # 二、推荐系统召回:协同过滤 ItemCF/UserCF、离散特征处理、双塔模型、自监督学习、多路召回、曝光过滤
  • VUE 仿神州租车-开放平台
  • Java中的一些名词概念
  • C++服务端的配置文件库介绍
  • Linux 中文件的权限说明
  • 论线段树的调试
  • 如何保护您的服务器免受Shellshock Bash漏洞的影响
  • IDEA项目提交至SVNGIT仓库
  • 【升华】人工智能python重要库scikit-learn学习
  • 【ARM】MDK-Flex服务管理软件使用说明
  • 基于SpringBoot+Vue+uniapp微信小程序的校园反诈骗微信小程序的详细设计和实现(源码+lw+部署文档+讲解等)
  • 【华为HCIP实战课程十三】OSPF网络中3类LSA及区域间负载均衡,网络工程师
  • 读人工智能全传16读后总结与感想兼导读
  • 苍穹外卖笔记
  • LeetCode 206 - 反转链表