Author Topic: Creating a Swap File  (Read 5929 times)

qx773

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Creating a Swap File
« on: February 10, 2004, 11:32:40 pm »
Netfront v3.0 or the JavaScript software apparently use more memory than Opera.  I ran out of memory while trying to use Ameritrade\'s portfolio page.  If you have an SD or MMC memory card, you can create a 32MB swap file on it, like the following from the terminal:

cd /mnt/card
dd if=/dev/zero of=swapfile bs=32M count=1


or

cd /mnt/cf
dd if=/dev/zero of=swapfile bs=32M count=1


for a compact flash card.  Using a higher block size like 64M results in an error message.  It seems like some kind of signed 16 bit representation is getting in the way.  You can use small block sizes and counts greater than one to get past this limit.

Then, format the swapfile:

mkswap swapfile
su root
swapon swapfile
exit
free


The free command will show you how much, if any, swap memory is activated.

imrambi

  • Newbie
  • *
  • Posts: 30
    • View Profile
    • http://
Creating a Swap File
« Reply #1 on: February 10, 2004, 11:49:19 pm »
You could download the Memory Applet that will create swaps upto 8megs

slocaus

  • Full Member
  • ***
  • Posts: 243
    • View Profile
    • http://
Creating a Swap File
« Reply #2 on: February 11, 2004, 01:49:55 am »
Or do a 16M with dd (32M gives a \"dd: Memory Exhausted error\") on my 5500.  Then use the Memory Applet to activate / deactivate it.  
Handheld:. Sl-5500 tkcROM 1.0 (defunct) * apps on ext2 Lexar 256 SD
Desktop:. Mandrakelinux 10.2 Cooker * kernel 2.6.11
Both computers run linux, proud to be MS Free

havoc

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • http://www.galacticslacker.com/
Creating a Swap File
« Reply #3 on: February 28, 2004, 12:35:21 am »
I\'ve got my swap partition on my SD card, but I can\'t seem to find a place in /etc/rc.d to have it \"swapon -a\" at boot.  Have the files never run!

I\'m getting frustrated....

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Creating a Swap File
« Reply #4 on: February 28, 2004, 06:46:28 am »
the rc.d scripts never actually finish running. Make sure you place it before SXXOpie or SXXQtopia (or whatever the scripts are called which start the GUI).

or

you could stick it in /etc/init.d/opie (or qtopia or whatever it\'s called) which is the script which the above entries call.


Si
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

hamiltonpruim

  • Newbie
  • *
  • Posts: 22
    • View Profile
    • http://
Creating a Swap File
« Reply #5 on: February 28, 2004, 08:21:06 am »
I\'d appreciate some advice for what I\'m trying to do, too. I\'ve successfully used fdisk to partition my (64Mb) SD into 40Mb FAT16 and 24Mb Swapfile, and I can mount the FAT16 partition. However, the card appears RO (although mount says RW) and even after mkswap /dev/mmcda2 and swapon /dev/mmcda2 it doesn\'t seem to recognise the swapfile. As I am new to linux, I am probably doing somthing stoopid, but any ideas, please?

(oops just seen the forum is 7x0 and mine is 5600, but that shouldn\'t make a difference, should it?)

Hamilton

qx773

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Creating a Swap File
« Reply #6 on: March 01, 2004, 11:51:25 pm »
What does the free program tell you about how much swap is being used?  It should not be necessary to create a separate partition for a swap file.  SD cards have a physical write protection switch like floppy disks, so you have to make sure that the switch is not loose.  What are the contents of your /etc/fstab file?

newkirk

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
    • http://myzaur.us
Creating a Swap File
« Reply #7 on: March 03, 2004, 03:39:21 am »
I keep trying to create a 32mb swapfile on internal flash with:
cd /home
dd if=/dev/zero of=swapfile bs=32M count=1
mkswap swapfile
swapon swapfile

and swapon always returns:
swapon: swapfile: invalid argument

(on pdaXrom as root)

I\'ve tried with and without /etc/fstab entry, with different sizes, all to no avail.

What am I doing wrong?

j
newkirk @ myzaur.us
pdaxrom @ newkirk.us
SL-5600, SL-C860
Socket & Ambicom WiFis
Billionton bluetooth
Lexar 256mb CF & SD

Anonymous

  • Guest
Creating a Swap File
« Reply #8 on: March 03, 2004, 03:56:31 am »
qx733...... you were right...  free reports the swapfile (sorry but I am a linux noobie), it seems to get used, too!   Removing the SD I could see the read protect, flicking it up and down seems to have sorted that, too. All I have to do now is (edit the fstab file?) make it run like that on startup......

Hamilton

qx773

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Creating a Swap File
« Reply #9 on: March 03, 2004, 10:09:52 pm »
I recommend that you not create a swap file in your internal flash memory.  If you burn out your internal flash memory, then there is no replacement for it short of replacing your entire handheld computer or getting out the tweezers and needle-nose solidering iron and attempting to desolder a surface-mounted chip to replace the internal flash memory.  External flash cards are cheap, some less than $1 per megabyte.  Using flash memory for a swapfile will cause more rapid aging of the flash memory than using it just as a file system.  In the future, perhaps we will have ferroelectric memory cards or ovonic unified memory cards that will have much higher write endurance than flash memory cards.

From the clues I have been able to piece together, it appears that the bs=32M parameter causes the dd program to create a buffer of equal size in SDRAM before it writes the contents of the buffer to the output file.  So, it might be better to use a smaller buffer size and a larger count like:

dd if=/dev/zero of=swapfile bs=1M count=32

You might not have 32MB of free space in your internal flash memory.  The du command will tell you how much disk space has been used.

Regarding getting the swap file to work on boot-up:  If you already have a separate partition for the swap space, then you can run \"su root\" to become the system administrator and then edit the /etc/fstab file.  I do not recall off the top of my head the syntax for that.  Someone else here probably knows, or you can read a reference manual.

If you use a swap file, instead of a swap partition, then you might have to run \"su root\" to gain full system access on the command line and edit the /root/etc/rc.d/rc.sysinit file and uncomment the section that runs the rc.local script.  The Zaurus computers with the default ROM are somewhat non-standard in the places where they place some configuration files like rc.sysinit.  Then put the \"swapon /path/filename\" command in the rc.local file.  Someone else on the board mentioned how to make /root writable with the mount command.

qx773

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Creating a Swap File
« Reply #10 on: March 03, 2004, 10:20:01 pm »
The df program might actually be better for determining how much free space is left on your partitions.  The du program will tell you about the disk usage of the current directory and any subdirectories.

Anonymous

  • Guest
Creating a Swap File
« Reply #11 on: March 08, 2004, 11:20:00 pm »
Thanks all for advice.  I\'m familiar with the commands (I\'m a linux sysadmin) but couldn\'t figure out why it wasn\'t working.  (I expect that it\'s because /home is jffs2)

When I performed the precise same sequence but on SD instead of /home it worked as expected.  The problem was/is that pdaXrom won\'t let me partition with / larger than 50mb.  My usage calls for large space for installing apps and tools, but I don\'t need much storage space (/home).  Since the size issue was driving me to install packages to SD, I wanted to put swapfile in /home since it was still essentially vacant.

Hopefully I\'ll be able to successfully repartition with 100mb for / eventually...

j

edwinbradford

  • Newbie
  • *
  • Posts: 46
    • View Profile
Creating a Swap File
« Reply #12 on: September 18, 2004, 03:30:02 pm »
Quote
Someone else on the board mentioned how to make /root writable with the mount command.

It's at https://www.oesf.org/forums/inde...?showtopic=1543

Quote
The 5600 ROM is a readonly JFFS2 partition, so to make the 5600 ROM writable just run this command as root:

mount / -o rw,remount

Then replace the files you need to change and run this command to protect the ROM again:

mount / -o ro,remount

No reboot required

I'm a novice but tried it and it works.