How to set up your XO to swap to an SD card

John Gilmore gnu at toad.com
Sun Aug 10 05:21:53 EDT 2008


> > Have you tried with a swap partition? Swap is robust now on a
> > SD card, immune to suspend/resume and power cycle.
>
> External swap area sounds cool.  How does one set it up?  I'll give it a
> whirl.

Use a recent joyride.  Get a throwaway 1GB SD card.  Available for
$3-$20 depending where you go.  I say throwaway because swapping to it
will tend to burn it up faster than its "usual" lifetime for photos
and such.  You will still be able to use half a gig on the card for
file storage; the other half will be for swap space.  Plug it into the
SD card slot on the XO.  You'll have to keep it plugged in the whole
time while you're swapping to it; you can't remove it the way you
remove a USB stick or a non-swap SD card.  If/when it starts to fail
after a few years, you can copy any still-interesting user files off
it, throw it away, and put in a new $1 1GB SD card (or something
larger).

Go to a terminal (either the activity, or Ctrl-Alt-F1).  Become root.
Type "mount", make sure the SD card is mounted at /dev/mmcblk0p1,
in a "vfat" filesystem.

Go into the Journal, find the SD card hiding behind the Frame at the
bottom, hover over it, pick Unmount.  Go back to the terminal.

Type "mount", make sure /dev/mmcblk0p1 is not mounted any more.  Type
"yum install parted" since the partition editor is not in the distro
any more.  Run "/sbin/parted /dev/mmcblk0".  Type "print" to see the
current configuration.  On mine it looked like this:

Number  Start  End    Size    Type     File system  Flags
 1      127kB  1018MB 1018MB  primary  fat16

Type "resize 1 0 512" to shrink this filesystem down to 512MB.  If it
asks you whether to use FAT32, just say no.  Then type "mkpartfs
primary linux-swap 512 1018".  That'll make a second partition for
swapping to, and format it as a Linux swap partition.  Type "print"
and it should look roughly like this:

Number  Start  End     Size   Type     File system  Flags
 1      32.3kB 512MB   512MB  primary  fat16
 2      512MB  1018MB  506MB  primary  linux-swap

Type "quit".  Now you're back to the shell.  Type "/sbin/swapon
/dev/mmcblk0p2".  You're done.

The Hal daemon is smart enough to mount filesystems when it sees an SD
card appear, but it's not smart enough to start using freshly
available swap space.  For the moment, you'll have to do "/sbin/swapon
/dev/mmcblk0p2" each time after you reboot the XO.  Similarly, it
won't do the "/sbin/swapoff" if you want to eject it.  I'm sure
somebody will eventually come up with a Hal script or something to
automate that part.

You can see how much swap space you have / are using by running "top"
in a terminal window; it's about the fourth line down.

	John



More information about the Devel mailing list