Author Topic: Swap Partition Vs. Swap File  (Read 3292 times)

ShiroiKuma

  • Hero Member
  • *****
  • Posts: 900
    • View Profile
Swap Partition Vs. Swap File
« on: December 20, 2005, 05:49:52 am »
Hi all:

I'm thinking of creating a swap partition on an SD. Is there a benefit to having a swap partition as opposed to a swap file? In terms of speed or whatever?
[span style=\'font-size:8pt;line-height:100%\']Das ganze tschechische Volk ist eine Simulantenbande.[/font][/span]
Militäroberarzt Bautze

Chero

  • Hero Member
  • *****
  • Posts: 1140
    • View Profile
    • http://users.telenet.be/zaurususer/Chero
Swap Partition Vs. Swap File
« Reply #1 on: December 20, 2005, 07:55:38 am »
Quote
Hi all:

I'm thinking of creating a swap partition on an SD. Is there a benefit to having a swap partition as opposed to a swap file? In terms of speed or whatever?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=107728\"][{POST_SNAPBACK}][/a][/div]

Searching on swap would give you a lot of answers (and doubts)

What I've learned from reading the forums :
- some say swap on SD is a bad idea (intensive read and write operations on a medium with limited read and write operations before it breaks). I've been running a swapfile on SD for a year, without troubles. Second reason : SD is supposed to be slow.
- if you create the swapfile right after partitionning (formatting), it will act the same as a swap partition (there will be no defragmentation).
- will swap speed up the Z : according to the faq on the pdaX site : no. I don't totally agree with this, I'm running a 64Mb swapfile and apps launch smoother with swap on. I can imagine why.
- There is a lot of info about swap when you "search".

Chero
« Last Edit: December 20, 2005, 07:57:07 am by Chero »
HP-95LX -> HP Jornada 680 -> SL-C860 -> SL-C3100 -> Fuji u810 -> SL-C1000 -> HTC uni -> SL-C860 -> SL-C760.
March 12 2009 : Back because the Zaurus is one of a kind.
SL-C760 : pdaXrom
Pandora pre-ordered -> received and tested : great device but not my cup of tea -> sold.

ShiroiKuma

  • Hero Member
  • *****
  • Posts: 900
    • View Profile
Swap Partition Vs. Swap File
« Reply #2 on: December 20, 2005, 04:11:58 pm »
I did search the forum for swap partition articles, but really haven't seen anything that would shed clear light on it. I've read one post which simply says that swap partition is faster than a swap file but nothing more.

Is this really so?

How do you set up a swap partition then? I can create a partition with fdisk, but which format do you set it to then? How do you swap on it? Does it need to be specified in fstab? Is it really faster than just swapping on a file?
[span style=\'font-size:8pt;line-height:100%\']Das ganze tschechische Volk ist eine Simulantenbande.[/font][/span]
Militäroberarzt Bautze

karlto

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
    • http://
Swap Partition Vs. Swap File
« Reply #3 on: December 20, 2005, 04:25:23 pm »
Quote
I did search the forum for swap partition articles, but really haven't seen anything that would shed clear light on it. I've read one post which simply says that swap partition is faster than a swap file but nothing more.

Is this really so?

How do you set up a swap partition then? I can create a partition with fdisk, but which format do you set it to then? How do you swap on it? Does it need to be specified in fstab? Is it really faster than just swapping on a file?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=107812\"][{POST_SNAPBACK}][/a][/div]

I have a swap partition on CF microdrive which seems to work OK, but as mentioned the performance increase is probably marginal. I would agree that a partition is probably better than a file, but I doubt you'd see much speed difference on the Z.

After you create the partition in fdisk, change type to 82 (Linux swap) and save changes. Use 'mkswap' to format, then 'swapon' to turn it on. You can add it to fstab, but I'm not sure that pdaXrom actually uses this, and you won't normally reboot often anyway...
« Last Edit: December 20, 2005, 04:26:33 pm by karlto »
SL6000-L, RC12

Da_Blitz

  • Hero Member
  • *****
  • Posts: 1579
    • View Profile
    • http://www.pocketnix.org
Swap Partition Vs. Swap File
« Reply #4 on: December 21, 2005, 04:06:09 am »
Swap partions are faster than file when the partion is placed on the outside of the hard drive plates (as the velocity is greater but angular velocity is still the same)

the reason some people say that a partion is faster is becuase of what is stated above, normally a swap file is the first file created and is placed toward the center, basically a file gives you less control of the physical placment where as a partion gives youmore control of where it lies on the hard drive

on an SD card this is a moot point as anywhere on a sd card gives you the same amount of speed

another reason partions are prefered is that they avoid fragmentation (not normally an issue for any filesystem but FAT) however resizing them is next to imposible unlike a file, with a file thogh you do have the slight overhead of filesystem calls however these are neglibgible.

so basically flexiability = file, speed ~= partion (i say aprox. equal because in terms of actual speed it is probally farily close)
Personal Blog
Code
Twitter

Gemini Order: #95 (roughly)
Current Device: Samsung Chromebook Gen 3
Current Arm Devices Count: ~30
Looking to acquire: Cavium Thunder X2 Hardware

Zumi

  • Sr. Member
  • ****
  • Posts: 257
    • View Profile
    • http://
Swap Partition Vs. Swap File
« Reply #5 on: December 21, 2005, 05:30:15 am »
I don't think that it matters whether you use a swap partition or file if you use it on a flash card (not microdrive), because fragmentation has no meaning on memory cards, so the only drawback, as Da_Blitz said, is the small overhead of the filesystem.
I think that is a good price for sizing your swapfile as you want.

A little more info about swap usage on Z here: http://www.pdaxrom.org/index.php?showid=43&menuid=8

Zumi
SL-C860: pdaXrom 1.1.0beta1
SD: 1GB A-data, GPS: Haicom HI-303S, Bluetooth: Nokia DTL-1 CF, CF WiFi: ASUS SpaceLink WL-110
Browse user contributed packages for pdaXrom!

jcabrer

  • Full Member
  • ***
  • Posts: 161
    • View Profile
Swap Partition Vs. Swap File
« Reply #6 on: December 21, 2005, 04:10:07 pm »
I've used both swap files and swap partitions.  Here is what I found:

Speed is more dependent on the Flash Speed.  I used both 4x and 40x cards, and there was a very noticible difference.

As for Files vs. Partitions, there are pros and cons, especially if you are using a microdrive.  Using a file leaves the option of adding and removing additional swap files as your needs change.  Using a swap partition, you can create it at the outer boundries of the drive to get the extra speed offered by that area of the disk.  Files are also a bit slower to access than partitions on the same media.  Not really niticable though...
Sharp SL-C3100 - pdaXrom Beta 3
Sharp SL-6000L - pdaXrom Beta 1

scoutme

  • Hero Member
  • *****
  • Posts: 579
    • View Profile
Swap Partition Vs. Swap File
« Reply #7 on: December 21, 2005, 08:46:49 pm »
I can tell you that a swap is the only solution for memory lack we suffer on our laptop-wonnabe

I use swapd, that creates swap files when needed; in this way you don't stress everytime the same memory region, and you have no risk of underestimating needed swap capacity.

So: swap files are good, especially if dinamically created, by a daemon you install and forget there working for you

chal

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
    • http://
Swap Partition Vs. Swap File
« Reply #8 on: December 23, 2005, 03:31:36 pm »
I'm using a 512mb sandisk sd card. Anyway, I had used it when it was new for a home on sd Cacko rom, which worked fine, but was a little slow (before the newer kernel) so I tried tKc home on sd, and had problems. Then it kinda fizzled out on me and wouldn't work right for anything. I tried formatting it as fat to see if it would be usable for something, but it only compounded the problem. Then I bought a Kingston 256 that would never format as ext 2 correctly and kept trying to fix it, but eventually it was almost unusable.

What has all this got to do with swap? Well, I decided to try and see if I could at least get some swap out of these white elephants. I had qswap, qtopia memory applet and swapd and decided to try them all and see which one worked the best and if i could get one to run on my corrupted sd card.
 
I put swapd on both of them and put one on my z and one on my wife's and they are at least usable for something. Some progs that were loading slow are now snapping open in about 1 second. This is an awesome program. I was using qswap to set up 32 mb on my cf card, but that's where most of my progs are installed to and I wanted to keep the swap in a different location. This is much better and they were cards that I couldn't use for data.

You guys talking about swap gave me a prod to start trying something with it, so thanks.

PDAs
2 SL5500s
tKc Rom
Lexar 1GB CF card
Viking 512GB  CF card
PC 1. Mandriva 2009
PC 2. Windows XP
[/font]