DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2011-10-21 00:30:09

Gyngy
Member
Registered: 2011-05-27
Posts: 32

Swap on USB

Hi all!

I am successfully running funplug from USB. But sometimes I see that system is heavy loaded (transmission, smbd, lighthttpd) and top shows memory ussage like 150 %.
Does this means, that RAM is taken from SWAP partition on HDD? If yes is it possible to move SWAP partition to USB as well?

Maybe it is stupid question - if yes please tell me :-)

Gyngy

Offline

 

#2 2011-10-22 13:33:29

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 709

Re: Swap on USB

You can move swap to USB stick. Create a big file on the stick, convert it to swap, and use it:

Code:

dd if=/dev/zero of=/mount/path/of/stick/swapfile bs=4k count=32k # 128MiB
mkswap /mount/path/of/stick/swapfile
swapon /mount/path/of/stick/swapfile

Now you can switch off your disk-swap.

Code:

# find the swap
cat /proc/swaps
swapoff /dev/sda?

You'll have to repeat the swapon/swapoff on each boot.

Another option is to give the swap-on-usb a higher priority. in that case you don't need to switch off the disk-swap. It will be used only if the usb-swap is full.

Code:

swapon -p 10 /mount/path/of/stick/swapfile

Keep in mind that using flashmemory as swapspace will damage your stick, sooner or later. So keep your backup of your stick up-to-date. (It's not too dramatically. I had Debian running from stick for a year, with swap on stick, and normal logfiles on. The stick still lives, but it's very slow in writing.)

Last edited by Mijzelf (2011-10-22 13:36:14)

Offline

 

#3 2011-10-22 20:29:16

Gyngy
Member
Registered: 2011-05-27
Posts: 32

Re: Swap on USB

Thank you,
my DNS-320 is not equipped by debian so I hope this procedure will work for D-links linux distribution as well!

Gyngy

Offline

 

#4 2011-10-23 21:00:19

Gyngy
Member
Registered: 2011-05-27
Posts: 32

Re: Swap on USB

Mijzelf thank you!

It is working like a charm. I know about USB stick limitation about read/write cycles.
I am thinking about using one USB stick for funplug and one (old one) for swap.

BTW, DNS-320 is creating 512 MB raid 1 partitions on HDDs where swap (/dev/md0) is located.

Best regards!
Tomas

Offline

 

#5 2011-11-14 00:11:15

SerpensAlatus
Member
Registered: 2011-11-13
Posts: 8

Re: Swap on USB

Hi,

the DNS320 does also create a swap with only one drive? Or is it possible to create one after the setup by hand?

Regards

Offline

 

#6 2011-11-14 14:37:22

Gyngy
Member
Registered: 2011-05-27
Posts: 32

Re: Swap on USB

@ SerpensAlatus

Yes and yes.

1. standard swap is created by system as raid 1 block on discs while initializing new HDD in system. If there is only one drive then it will be same RAID array but degraded.

2. you could turn off swap (swap off) and turn it on only on one disc (swapon /dev/sda1)

Gyngy

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB