OpenWrt分区扩容

背景

这里使用的是x86的64位ext4的OpenWrt镜像。下面是OpenWrt下载地址:
https://downloads.openwrt.org/releases/19.07.4/targets/x86/64/
使用OpenWrt的ext4镜像制作好U盘镜像文件后,然后,再对u盘进行分区扩容。

默认分区

OpenWrt默认就2个分区:

  1. /dev/sda1是16MB大小的 ext4格式的 /boot分区,用于存储GRUB和内核。
  2. /dev/sda2是一个256MB大小分区,其中包含squasfs根文件系统和可读写的f2fs文件系统或ext4根文件系统(取决于您选择的映像)。

我们的目标就是要扩展/dev/sda2这个256MB的分区,将这个分区扩完u盘的最大空间即可。

分区扩容

这里主要使用fdisk软件进行分区扩容。**注意:**这里的u盘镜像是外挂到一个linux系统下面进行扩容的,使用过程中的OpenWrt系统是不能动态扩容的。

root@OpenWrt:~# fdisk /dev/sdb

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


Command (m for help): p
Disk /dev/sdb: 7.2 GiB, 7751073792 bytes, 15138816 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: 0xcbad8a62

Device     Boot Start    End Sectors  Size Id Type
/dev/sdb1  *      512  33279   32768   16M 83 Linux
/dev/sdb2       33792 558079  524288  256M 83 Linux

Command (m for help): d
Partition number (1,2, default 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 (33280-15138815, default 34816): 33792
Last sector, +sectors or +size{K,M,G,T,P} (33792-15138815, default 15138815): 

Created a new partition 2 of type 'Linux' and of size 7.2 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.

root@OpenWrt:~# resize2fs /dev/sdb2

参考

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值