OpenWrt 23.05磁盘扩容教程:从工具安装到分区挂载的完整指南
创作时间:
作者:
@小白创作中心
OpenWrt 23.05磁盘扩容教程:从工具安装到分区挂载的完整指南
引用
CSDN
1.
https://blog.csdn.net/tonyhi6/article/details/139218163
本文将详细介绍如何在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
3. 安装cfdisk,分配剩余磁盘空间
安装cfdisk工具并开始分区:
opkg update
opkg install cfdisk
cfdisk /dev/sda
在cfdisk界面中选择NEW,输入所需的空间大小。
4. 分区查看格式
查看新的分区信息:
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
由于OpenWrt Web界面中没有挂载点选项,需要安装block-mount:
opkg update
opkg install block-mount
reboot
重启后通过Web界面或SSH登录进行挂载:
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
热门推荐
英国肺结核治疗中的副作用及管理指南
2025年迁坟最佳吉日全新一览表(1月-12月)
被DeepSeek对《哪吒2》无量仙翁的解读惊到,文科博士:我白读了?
健康饮食不仅护心还能健脑!
购买二手理想ONE必读指南:细节验车、合同签订及售后服务全面解析
甲醛检测仪原理是什么?如何确保检测结果更准确?
古村落的文化之旅:探访安徽宏村与云南沙溪
十二星座英文名称及发音
冰汽时代2怎么规划布局?《冰汽时代2》规划布局思路分享
碘伏可以擦脸吗
碘伏消毒的正确使用方法是什么
磁力泵隔离套作用
《原神》官方与同人绘画精选集:探索游戏角色与场景的艺术创作全览
互联网电商,自营与平台模式的异同理解
一根头发半截黑半截白,是咋回事?
不废江河万古流——书写文化传承发展的当涂新画卷
天麻好搭档与避讳食物,健康食用小贴士
IT技术支持工程师的面试技巧
固执不只是性格?神经科学揭示大脑的固执密码
八部顶级搞笑动漫大盘点,笑到肚子疼的夏日消暑良品
固态电池时代来临,新能源车会淘汰吗?燃油车命运又将如何?
缓解烦躁焦虑不安的小妙招
到明年年底,南海至少三成社区卫生服务中心将转型为热敏灸特色站
如何接触投资团队
用八字选姓名,根据八字取名字有没有科学依据
二月初十“长寿日”,“1事不做,2样要吃,忌1事”,福寿安康
我的世界埋葬的宝藏怎么找:坐标指令代码详解
上海九院突破血管瘤诊疗难题,建立国际领先诊疗体系
治疗三叉神经痛的首选药物及注意事项
女生学习八字命理学,哪种流派或方法最适合呢