Installing OpenWRT in a X86 System in a partition, having both WIN11 and OpenWRT

Check the output of mount - the results should help you determine which partition to expand. For me, I expanded the partition in question to fill the disk. You could do the same, or you could expand it a little bit and then create another partition to take up the slack.

Keep in mind the risk of future upgrades potentially overwriting your partition table; if you're going to use OpenWRT as a NAS, I strongly recommend keeping a separate backup of the data you intend to put on the NAS.

Hmm, i think it doesnt help me too much...

root@OpenWrt:~# mount
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/loop0 on /overlay type ext4 (rw,noatime)
overlayfs:/overlay on / type overlay (rw,noatime,lowerdir=/,upperdir=/overlay/upper,workdir=/overlay/work)
/dev/sda1 on /boot type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sda1 on /boot type vfat (rw,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
tmpfs on /dev type tmpfs (rw,nosuid,noexec,noatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,mode=600,ptmxmode=000)
debugfs on /sys/kernel/debug type debugfs (rw,noatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,noatime,mode=700)

Low knowledgement maybe... Sorry for that

It's a process of elimination.

/dev/sda1 is mounted to /boot, so it's not the partition you want to expand.

That leaves /dev/sda2.

On mine, /dev/sda2 is the one I expanded to fill the SSD.

if using ext4

boot from the openwrt usb stick again, run opkg update on it, and opkg install resize2fs fdisk.

fire up fdisk /dev/sda (assuming sda is still your NVME drive).
d)elete partition 2
n)ew partition, and set the size to whatever you'd like, but larger than it was
w)rite the changes
q)uit

run resize2fs /dev/sda2, and fsck /dev/sda2

and you're done, pull the flash drive, and reboot.

if the system would fail to boot, in grub2 press e, and replace the current root= value with root=/dev/sda2, then Ctrl-X to boot. this isn't however a lasting change, you need to edit /boot/grub/grub.conf and make the same change there.

1 Like

tried it, but:

Command (m for help): F

Unpartitioned space /dev/sda: 5 GiB, 5367995904 bytes, 10484367 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

    Start       End  Sectors Size
489633792 500118158 10484367   5G

Command (m for help): d
Partition number (1-3,128, default 128): 2

Partition 2 has been deleted.

Command (m for help): n
Partition number (2,4-127, default 2): 2
First sector (33280-500118158, default 489633792):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (489633792-500118158, default 500118158):

Created a new partition 2 of type 'Linux filesystem' and of size 5 GiB.

Command (m for help): w
The partition table has been altered.
***Failed to remove partition 2 from system: Resource busy***
***Failed to add partition 2 to system: Resource busy***

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.

root@OpenWrt:~# resize2fs /dev/sda2
resize2fs 1.46.5 (30-Dec-2021)
resize2fs: Resource busy while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
root@OpenWrt:~# fsck /dev/sda2
-ash: fsck: not found
root@OpenWrt:~#

I previously boot the T8 with Gparted Live and did a partition of 233.4Gb, leaving /dev/sda2 5Gb for opkg packets as you can see here

Command (m for help): F

Unpartitioned space /dev/sda: 5 GiB, 5367995904 bytes, 10484367 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Start End Sectors Size
489633792 500118158 10484367 5G

did you do this running from the NVME ?

might be fsck.ext4

Running from USB stick

Check lsblk command:

root@OpenWrt:~# lsblk
NAME     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0      7:0    0  99.3M  0 loop /overlay
sda        8:0    0 238.5G  0 disk
├─sda1     8:1    0    16M  0 part /boot
│                                  /boot
├─sda2     8:2    0   104M  0 part /rom
├─sda3     8:3    0 233.4G  0 part
└─sda128 259:0    0   239K  0 part
sdb        8:16   1   7.5G  0 disk
├─sdb1     8:17   1    16M  0 part
├─sdb2     8:18   1   104M  0 part
└─sdb3     8:19   1   239K  0 part

you can't extend a partition if there's one created after it.

i think i dont understand you, as you can see here

there is 5Gb not partitioned, what i intend is to expand /dev/sda2, adding to it this 5Gb or as you say here:

delete partition 2 and creating a new one of 5Gb for package files

yes, but.

is the drive's layout as
sda1
sda2
[free space]
sda3

or

sda1
sda2
sda3
[free space]

if it's the 2nd scenario, sda2 can't be exteded, you'd have to move the free space so it's between sda2 and 3. GParted can do this, but if you've already fired it up, you might as well do all the resizing using it.

or remove sda3, extend sda2, recreate sda3 afterwards.

1 Like

i resized all as you commented, deleted sda2 from GParted, create new sda2 of 5Gb, and then created the last partition with the rest of the space and now i can only boot OpenWRT from USB stick, dont know why

root@OpenWrt:~# lsblk
NAME     MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0      7:0    0  99.3M  0 loop /overlay
sda        8:0    0 238.5G  0 disk
├─sda1     8:1    0    16M  0 part /boot
│                                  /boot
├─sda2     8:2    0     5G  0 part
├─sda3     8:3    0 233.5G  0 part
└─sda128 259:0    0   239K  0 part

sdc        8:32   1   7.5G  0 disk
├─sdc1     8:33   1    16M  0 part
├─sdc2     8:34   1   104M  0 part /rom
└─sdc3     8:35   1   239K  0 part
root@OpenWrt:~#

Note: sdc is USB stick

root@OpenWrt:~# resize2fs /dev/sda2
resize2fs 1.46.5 (30-Dec-2021)
resize2fs: Bad magic number in super-block while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
root@OpenWrt:~#
root@OpenWrt:~# fsck.ext4 /dev/sda2
e2fsck 1.46.5 (30-Dec-2021)
ext2fs_open2: Bad magic number in super-block
fsck.ext4: Superblock invalid, trying backup blocks...
Superblock has an invalid journal (inode 8).
Clear<y>? yes
*** journal has been deleted ***

/dev/sda2 has unsupported feature(s): FEATURE_C12
e2fsck: Get a newer version of e2fsck!

/dev/sda2: ***** FILE SYSTEM WAS MODIFIED *****

/dev/sda2: ********** WARNING: Filesystem still has errors **********

root@OpenWrt:~#

if you did it with gparted, I have no idea what it did on OS level.

the trick with fdisk is that if you delete and instantly recreated it, the starting point of the partition you're extending will be the same, and you're not touching the FS it contains, and you just have to resize the FS afterwards.

with gparted, extending, moving, resizing, is fine, because it'll (hopefully) keep the FS intact.
delete, and recreate, not so much.

how far do you get in the boot process ? does grub2 still work ?

ooooh didnt know that...

Grub still works, when it boots it stays waiting for "anything" that is contained in sda2, I "know" this because if I insert the USB stick it automatically boots everything

I tried to copy with dd the content of sdc2 to sda2, the command did not retrieve any error but its like nothing happens...

ok,

boot off the flash drive, and transfer (scp or wget) the generic-ext4-rootfs.img.gz to /tmp
ssh to the running openwrt and do zcat /tmp/generic-ext4-rootfs.img.gz > /dev/sda2
then resize2fs /dev/sda2 and fsck.ext4 /dev/sda2.
with a little luck, you'll be back.

its done with generic-ext4-rootfs.img.gz but i need a squashfs img to perform resets when i need them, can i do the same with generic-squashfs-rootfs.img.gz ?

I tried it but its giving me errors like:

root@OpenWrt:/tmp# zcat openwrt-22.03.5-x86-64-generic-squashfs-rootfs.img.gz >
/dev/sda2
root@OpenWrt:/tmp# resize2fs /dev/sda2
resize2fs 1.46.5 (30-Dec-2021)
resize2fs: Bad magic number in super-block while trying to open /dev/sda2
Couldn't find valid filesystem superblock.
root@OpenWrt:/tmp#

The resizing of the squashfs is more complicated, that's why I use ext4.

1 Like

with ext4 can i do sysupgrade -r "filename.tar.gz" and restore a backup? @frollic

probably, never tried it though, also depends on what the backup contains.

I use a dual openwrt setup instead, easy to alternate, via grub, if things go sideways.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.