How big should my swap partition be?

Why would a [plain] router need swap space?

It's not a [workstation] computer or server...you're not running software and loads that should need balancing beyond the memory, are you???

...on an Archer, I doubt it.

If a router has a need to start using swap, there's a major problem.

1 Like

Read the threads that I linked to in my OP if you want to know the reasons behind my decisions. And plenty of others have supported those decisions (as you can plainly see), so let me answer your question with a counter-question: why would a person feel the need to criticise someone for a perfectly-logical idea???

how did you back it up? if it was a tarball, just untar it. same for other archive formats. if you literally dd dumped it you have to mount it and copy the files. do you have a Linux machine?

Huh?

I've never ran swap on a router...and I don't follow off thread posts.

Sorry you took it as criticism.

And the other thread doesn't explain about an exroot???

Since you didn't answer the question about running programs (which I don't see in either thread), I don't see the sense in thinking i was attacking you...

Bye on dat.

so having swap may not help much in your specific case.
A CUPS spooling server will run just fine when only SWAP is available, whereas some applications may perform very poorly when their data it stored on the SWAP rather then being kept in the β€œreal” RAM.

~ From Wiki

So I guess you're running servers/programs and I misread, apologies.

Ah-hah! Please excuse my Linux n00bness; I had no idea that a dd dump could be mounted like any other device!

To backup I ran dd if=/dev/sda1 of=/home/username/backup.img on a Linux VM. I'm an old-school Windows power user from the time I was in primary school, which was roughly 25 years ago, but need to use Linux a lot for work (I'm a web developer). I've gotten used to all the basic commands and some advanced web admin commands, but never knew dd was so freaking awesome LOL!

Anyway, after scp-ing the file off the VM and on to the router, then running mount /mnt/ntfs1/backup.img /mnt/backup, I get mount: can't setup loop device: No such file or directory. So how can I mount the image?

Thanks again mate; I really appreciate all your help and encouragement :smiley:

LOL sorry I guess I'm getting tired after having been at this all day.

There's nothing to explain about my extroot config really...just a run-of-the-mill extroot setup on a USB HDD, which I'm also using for two NTFS data partitions and now a swap partition as well.

Granted it may not actually help me with loading a large hosts file, which you would have seen if you read right to the end of my OP here :stuck_out_tongue: , but I'm just trying whatever I can to make it work.

1 Like

OH!!!!!!!!!!

Loading something large in dnsmasq would be something to try swap for...if you were having issues ("if it ain't broke, don't fix it" - as they say).

:+1:

1 Like

LOL totally :wink: Glad we're on the same page now! :smiley:

Except that it needs to be loaded to RAM for each DNS query as dnsmasq needs to evaluate the whole blocklist to see if a domain is on the list.

In theory swap may enable using a large blocklist, but I doubt that performance will improve. Possibly the DNS queries will slow down quite much. I still highly doubt that swap will help in dnsmasq performance (like I said the in abandoned "overcrowded" thread, which is shorter than this one...)

2 Likes

I agree my Adblock loads about 245,000 domains - my router has 512 MB of RAM...that's still not enough during heavy traffic (especially since my ISP upgraded me to 100 Mbps from 50 during the pandemic); and I can't imagine a performance improvement in the swap since the balance is actually traffic thru iptables/kernel/etc.

But, since I never intended to criticize...in fact I'm curious of the results - I await to see if the OP has success.

LOL sorry I never expected to get so many great answers here, nor to start diverging off the original question on slightly-unrelated tangents. Should we continue this discussion in that original thread?

No need. Just friendly advice that as most router functions are "real-time" oriented by nature, using flash or HDD as swap will slow you down quite much compared to pure RAM.

If you get good results from swap, then good for you :wink:

1 Like

LOL thanks mate, I'll definitely LYK how I go in the coming weeks. I'm going to enable SQM when I get around to it as well - reading the official guide now, but should probably get some sleep soon since it's 1 AM here :open_mouth:

I almost never work with entire disk images, most of the disks I have are REALLY big, so there's nowhere to put them and no purpose to them. :wink: so I'm rusty on how to loopback mount a file...

I think the method is something like:

losetup /backup.img
mount /dev/loop0 /mnt/backup
...do copy here...
losetup -d /dev/loop0

Thanks again Dan (hope you don't mind me calling you that LOL :stuck_out_tongue:), I'll give that a whirl and will annoy some other poor Linux pro via Google if need be. Happy Easter mate! :smiley:

OK so it's been almost a full day since I got this all completely set up, and so far I've noticed the following:

  1. Internet performance hasn't really changed, at least not as far as I can tell.
  2. The read/write performance of my NTFS data partitions is absolutely woeful! Windows (via Samba) struggles to read from the disk any faster than 2 or 3 MB/s, and writes are even worse!
  3. I'm not sure whether having a swap partition is the cause of 2. but it seems logical since it's the only thing that has changed besides the bad NTFS performance. The swap doesn't even seem to be being used though (it's currently showing 0% usage in LuCI -> Status -> Overview)!

I've been reading this SuperUser thread that seems to be related to 2., and from the comments there it seems as though the best course of action would be to scrap the NTFS-3G driver in favour of a newer, better-maintained alternative. But I haven't been able to find one yet :frowning_face:.

So if anyone can shed some light on this situation I would be forever grateful. MTIA! :slightly_smiling_face:

As predicted.

There are two issues I see here, both NTFS (not a native filesystem or Linux) and samba are somewhat resource hungry (and samba requires special care to configure/optimize). On an OpenWrt router, I would always try to use a more linuxy filesystem. Samba is often the best choice for fille-serving to windows machines, but IHMO for decent performance need something beefier than a trusty old MIPS based archer C7.

I would be amazed if swap would be the cause, but testing it is easy, just issue swapoff -a and swap will be disabled... use free on the command line to get an idea about swap usage, and do not connect via LUCI while you benchmark, the GUI can be quite resource hungry, at least on an archer C7 class of router...

Or better yet, scrap NTFS no matter the flavor for ext4, btfs, xfs, or god-forbid zfs...

1 Like

Please don't take offence to this as I really appreciate you trying to help, but do you really expect me to backup a 1TB hard drive spread across two partitions to...God only knows where!...and then format to a Linux filesystem and copy the data back??

I don't see why I should have to since things were fine a couple of days ago, and I can't even imagine how long that would take or how dangerous, or expensive, it would be...

Once again, I hope those comments don't offend you since you had no way of knowing how much data is involved, or how precious that data is to me (very, my career and therefore livelihood would end without it!).

One more thing: you seem to be a proponent of Linux in general, which is perfectly fine, but I am a proponent of Windows, at least for myself. If I could do everything I need to for bread and butter on Windows, I 150% would :stuck_out_tongue: Given that, the only reason I'm using OpenWrt at all is because there's no Microsoft equivalent.

And let's face it: if there was, I'd be moaning about even-worse network performance LOL (I will definitely concede that a Linux-based server or even PC seems to run a lot faster and smoother than any MS product ever LOL. I only stick with them because I'm so used to the way everything works in their world).

Sorry guys I went off on a bit of a tangent there! But to address moeller0's comment

I just wanted to add something that amazed me as well: disabling swap did increase disk performance! Not to the level that I would get from a PC, but by ~100%! My read speeds are roughly doubled when disabling swap, so I guess the disk doesn't like being (not) used for swap, extroot and NTFS data all at once!

Mind you I didn't take his/her suggestion to close LuCI when benchmarking, so that's next :wink:

Question, the swap device is not on the same disk as your data, I assume? +1 for testing :wink:

1 Like