Resize Extroot for Swap

Hey guys, I just setup my router to use a 8gb USB for extra storage, and I'm wondering if it's possible to resize the partition to include 2GB of swap storage. I have an Archer A7 V5 with Openwrt 19.07

It should be possible, but you can simply use a swap file:
https://openwrt.org/docs/guide-user/additional-software/extroot_configuration#devices_32_mb_ram

1 Like

Uh, so I went and ran the commands, but this happened:

root@OpenWrt:~# mkswap /overlay/upper/swap
mkswap: can't open '/overlay/upper/swap': No such file or directory
root@OpenWrt:~#  
root@OpenWrt:~# uci -q delete fstab.swap
root@OpenWrt:~# uci set fstab.swap="swap"
root@OpenWrt:~# uci set fstab.swap.device="/overlay/swap"
root@OpenWrt:~# uci commit fstab
root@OpenWrt:~# /etc/init.d/fstab boot

Is that bad that mkswap couldn't make the file and the rest of the commands ran?

1 Like

It should be:

mkswap /overlay/swap

I've updated the wiki.

Oh no, it went and formatted over my system backup drive <_> What do I do now???

--edit--
OH wait wait, I misread the value as megabytes instead of bytes

Alrighty, so it made the swap file. Is that all I have to do for it?

1 Like
free; cat /proc/swaps

Here ya go

root@OpenWrt:~# free; cat /proc/swaps
              total        used        free      shared  buff/cache   available
Mem:         124520       34100       31104         280       59316       46716
Swap:        102396           0      102396
Filename				Type		Size	Used	Priority
/overlay/swap                           file		102396	0	-2

It's suppose to look like that right?

1 Like

Yep, looks fine.

1 Like

Cool, thanks!

1 Like

Oh, out of curiosity, is it possible to make the swap file larger?

1 Like
swapoff /overlay/swap
dd if=/dev/zero of=/overlay/swap bs=1M count=500
mkswap /overlay/swap
swapon /overlay/swap
2 Likes

Cool, thanks!

1 Like

Hi, does enabling swapping as explained in 'Extroot configuration' guide has the same functionality as the zram-swap script? or that script meant to create a swap partition that is interacting with zram?

No, but a similar purpose.

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