rPi4b - How to use the full USB stick space

Hi All,

I have OpenWRT running on my Raspberry Pi 4b. To avoid SD card failure, which has been happening to me so often, I have added a USB stick to expand my root filesystem. I have more storage (15Gb) and the router is running with no issues.

My question is: how can I run OpenWRT from the 15 Gb USB stick and be able to use the available space to get rid of the SD card?

I can boot off the USB stick but don't have access to the total capacity of the disk to store my packages.

Thanks in advance for your support.

gparted FTW.

Thank you @frollic for your prompt reply. Every time I try to expend the partition using GParted, the disk can no longer boot. Any advice please ?

Bad idea in my opinion. If your uSD card fails you're either buying cheap media or have some hardware issues (power supply or board). I have uSD cards in service since RPi (version 1) 10+ years now without issues/tons of read-write cycles. Do yourself a favor and get a high quality uSD, not USB.

I'm not sure how the RPi partitions are set up for OpenWrt. Is it using FIT virtual parittions? ie: /dev/sda65, /dev/sda66?

Assuming your stick is sda, can you:
dmesg | grep sda and post the result?

And maybe also print out the partition structure?
parted /dev/sda p

In broad strokes, if it is set up the way I suspect, you want to:

  • Find the container partition (the largest single one)
  • Resize it using parted and its resizepart comand
  • Then resize the filesystem located on the inner FIT virtual partition. If it's f2fs then something like: resize.f2fs /dev/sda66

The specifics above may change according to your partition structure, and (of course) whether or not it's even set up with FIT.

Are you by any chance using squashfs?

No please. I flashed the pi sdcard with the EXT4 firmware.

OpenWrt itself doesn't need a lot of space in most cases. Having a few hundred MB is usually way more than required (but can be nice to have storage available on the main partition).

My personal recommendation would be to make a second partition for any additional data storage needs such as logs, file shares, or other things. You can mount the additional partition and access those files both locally and via file sharing/serving (like samba, etc.) as needed.

Frequent writes to the memory may wear it out, so be sure to have backups of your OpenWrt configuration as well as any other important files you have on your storage. It is also a good idea to have a spare thumb drive available for quick replacement if/when the storage does begin to fail so you can be back up and running quickly (utilizing those backups, of course).

2 Likes

Hello Va1der,

Please, see below:

 dmesg | grep sda
[    2.641633] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
[    2.650312] sd 0:0:0:0: [sda] Write Protect is off
[    2.655130] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[    2.655740] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[    2.682777]  sda: sda1
[    2.687785] sd 0:0:0:0: [sda] Attached SCSI removable disk
[    6.721220] EXT4-fs (sda1): recovery complete
[    6.731168] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts:
root@SUD:~#
root@SUD:~#
root@SUD:~# parted /dev/sda p
Model:  USB  SanDisk 3.2Gen1 (scsi)
Disk /dev/sda: 15.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start   End     Size    File system  Name     Flags
 1      1049kB  15.4GB  15.4GB  ext4         extroot

Thanks for the info. I'm a little confused, though. The stick shows it's a full 15GB already.

Yes. you are right. The system still boots off the SD Card and I expanded the root filesystem using a 15 Gb USB disk as per the following instructions https://openwrt.org/docs/guide-user/additional-software/extroot_configuration

Again, you want to boot off the uSD. You can use your USB for extra storage, log files, database files, etc. simply by defining it as a persistent mount and adjusting your config files accordingly.

1 Like

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