OpenWrt 23.05 系统磁盘扩容教程
创作时间:
作者:
@小白创作中心
OpenWrt 23.05 系统磁盘扩容教程
引用
CSDN
1.
https://blog.csdn.net/tonyhi6/article/details/139218163
OpenWrt是一个基于Linux的开源嵌入式操作系统,主要用于路由器等网络设备。在使用过程中,用户可能会遇到磁盘空间不足的问题。本文将详细介绍如何在OpenWrt 23.05版本中进行磁盘扩容,使系统能够充分利用硬件资源。
1. 安装fdisk
首先需要更新包列表并安装fdisk工具:
opkg update
opkg install fdisk
查看当前磁盘分区情况:
root@OpenWrt:~# fdisk -l
GPT PMBR size mismatch (246303 != 250069679) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: ASUS-S-128G1BYB0
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: gpt
Disk identifier: 7117DB1B-5559-E8FA-6528-E16757565D00
Device Start End Sectors Size Type
/dev/sda1 512 33279 32768 16M Linux filesystem
/dev/sda2 33280 246271 212992 104M Linux filesystem
/dev/sda128 34 511 478 239K BIOS boot
Partition table entries are not in disk order.
2. 安装parted
接下来安装parted工具并修复分区表:
opkg install parted
执行修复命令:
root@OpenWrt:~# parted -l
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra 249823375 blocks) or continue with
the current setting?
Fix/Ignore? fix
Model: ATA ASUS-S-128G1BYB0 (scsi)
Disk /dev/sda: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 126MB 109MB ext2
再次查看磁盘分区情况:
root@OpenWrt:~# parted -l
Model: ATA ASUS-S-128G1BYB0 (scsi)
Disk /dev/sda: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
128 17.4kB 262kB 245kB bios_grub
1 262kB 17.0MB 16.8MB fat16 legacy_boot
2 17.0MB 126MB 109MB ext2
3. 安装cfdisk,分配剩余磁盘空间
更新包列表并安装cfdisk:
opkg update
opkg install cfdisk
开始分区:
cfdisk /dev/sda
在cfdisk界面中选择NEW,输入所需的空间大小。
4. 查看新分区
使用fdisk查看新的磁盘分区情况:
root@OpenWrt:~# fdisk -l
Disk /dev/sda: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: ASUS-S-128G1BYB0
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: gpt
Disk identifier: 7117DB1B-5559-E8FA-6528-E16757565D00
Device Start End Sectors Size Type
/dev/sda1 512 33279 32768 16M Linux filesystem
/dev/sda2 33280 246271 212992 104M Linux filesystem
/dev/sda3 247808 250068991 249821184 119.1G Linux filesystem
/dev/sda128 34 511 478 239K BIOS boot
Partition table entries are not in disk order.
查看当前磁盘使用情况:
root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 102.3M 57.1M 43.1M 57% /
tmpfs 3.8G 11.5M 3.8G 0% /tmp
/dev/sda1 16.0M 6.1M 9.8M 38% /boot
/dev/sda1 16.0M 6.1M 9.8M 38% /boot
tmpfs 512.0K 0 512.0K 0% /dev
格式化新分区:
root@OpenWrt:~# mkfs.ext4 /dev/sda3
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 31227648 4k blocks and 7806976 inodes
Filesystem UUID: 5f4ddd57-cf95-4953-b292-8a7b37cebc4b
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done
5. 安装block-mount并重启
安装block-mount以启用Web界面中的挂载点功能:
opkg update
opkg install block-mount
reboot
重启后,通过Web界面或SSH登录OpenWrt:
mkdir -p /tmp/introot
mkdir -p /tmp/extroot
mount --bind / /tmp/introot
mount /dev/sda3 /tmp/extroot #注意挂载新分区(⊙﹏⊙)
tar -C /tmp/introot -cvf - . | tar -C /tmp/extroot -xf -
umount /tmp/introot
umount /tmp/extroot
6. 重启并验证
重启OpenWrt服务器并检查磁盘使用情况:
root@OpenWrt:~# df -hT
Filesystem Type Size Used Available Use% Mounted on
/dev/root ext4 102.3M 57.9M 42.4M 58% /rom
tmpfs tmpfs 3.8G 3.6M 3.8G 0% /tmp
/dev/sda3 ext4 116.7G 59.9M 110.7G 0% /
/dev/sda1 vfat 16.0M 6.1M 9.8M 38% /boot
/dev/sda1 vfat 16.0M 6.1M 9.8M 38% /boot
tmpfs tmpfs 512.0K 0 512.0K 0% /dev
热门推荐
吐血是什么病?可能由这些原因引起
如何在保留小农经济优势的同时,实现规模经营和现代化生产?
面试UI设计师应该怎样准备作品集和作品?
红军“围城打援”:江油战役大获全胜
期货预测的依据是什么?这些依据的可靠性如何?
负数补码如何求源码
Brunnstrom分期全解析与康复策略
从科学的角度分析 为什么说猫屎咖啡与象屎咖啡只是一场炒作?
为什么古代战争爆发时,都要排兵布阵?“阵法”真有那么玄乎?
IP地址与MAC地址的区别:理解网络层与数据链路层的基石
房屋银行贷款还完后自动解除抵押吗
团队负责人如何管理团队
玩转镜子,打造N种“消失的”建筑
光学领域的革命性突破——超透镜
不焯水吃就等于“服毒”?为了家人健康,这几种菜再懒也要焯下水
ERP系统与数据库对接的五种方法及实施要点
陈晓平教授:难治性高血压药物与介入治疗进展
怎样挑选汽车坐垫?看哪些参数?
猫咪频繁打喷嚏是什么原因?3 大常见病因解析
柔性机器人执行器模型与控制算法研究:从参数化建模到非线性控制
K字头火车座位分布图及各类火车座位号详解
六爻代人起卦如何取用神?六爻卦象对用神是否有影响?
2025河南定向士官最新政策:学校名单、招生计划、录取分数线
健康头皮如何“养”出来
脾胃虚弱吃哪种蜂蜜?脾虚的人能否喝蜂蜜?
网民间热议:睡前阅读是培养孩子的最佳方式!
JS判断字符串是否加密的多种方法
番茄炒蛋的烹饪技巧:从食材准备到出锅装盘的完整指南
在家庭教育中如何有效设定家庭规则与界限
2025 年撰写有效职位描述的 9 个要点