Use an SD card as swap space on the XO laptop
I posted this over at the OLPC News Forums, and decided to share it with Hackszine readers as well.
Most of the time, the 256MB in the XO Laptop is sufficient. But I use yum to install software, and it can be very memory hungry. I often run out of RAM when installing more than a few packages at once (or a single package that decides it needs a bunch of other packages to work properly). There are two things I suggest before using yum: 1) quit all activities except terminal and cross your fingers or 2) enable some swap space and not worry.
The quick and dirty way to enable swap space is to put an SD card that you don't care about into the XO, and run one of these commands:
Note that this will destroy whatever's on the SD card, and in the long run is not good for it because it puts a lot of wear and tear on it.
On the default operating system that came with your XO:
su mkswap /dev/mmcblk0 swapon /dev/mmcblk0 exit
On a joyride, Update.1, or later:
sudo mkswap /dev/mmcblk0 sudo swapon /dev/mmcblk0
You can replace swapon /dev/mmcblk0 with swapoff /dev/mmcblk0 when you are done and want to remove the SD card, or shut down the machine then remove the SD card. Don't remove it while you're using it as a swap drive or the system will probably crash.
As with anything that has "su" or "sudo" in it, if you mistype something, you may damage the operating system. One safety tip I can suggest is that you type the command like this:
swapon /dev/mmc[TAB][TAB]
That invokes tab filename completion, where it will either type out mmcblk0 for you, or show you a bunch of options. If you see anything other than mmcblk0, or mmcblk0p1/2/3, you might have mistyped the command. (The p1, p2, etc variants may appear if the SD card has multiple partitions on it).
I use this all the time to give myself some extra memory. It is slow because it's swapspace on an SD card, but it's much better than running out of memory while running yum. (The consequence of running out of memory is that you end up with improperly installed software). This is also handy if you are going to run a ton of activities at once, or if you are planning to use memory-intensive apps that you install with Yum, such as openoffice, gnumeric, etc.
Posted by Brian Jepson |
Jan 25, 2008 05:23 AM
Linux, olpc |
Permalink
| Comments (5)
Recent Entries
- Minty soldering jig
- Selecting row number in MySQL
- iPhone 3G software unlock
- Python on Android
- Controlling Sony camcorders with the Arduino
- Gradient text effect in CSS
- Retro gaming emulators that include (legal) ROMs?
- Das DereLicht - ham radio transmitter from a CFL bulb
- Using Google App Engine as a personal CDN
- Route-me - Open Source mapping library for iPhone
Comments
Newest comments listed first.
| Posted by: Rick on January 26, 2008 at 9:23 PM |
It did not work right away for me, swapon failed.
I had to do a mkswap /dev/mmcblk0 first
| Posted by: Brian Jepson on January 27, 2008 at 3:03 PM |
Thanks, Rick! I've updated the instructions (I mkswap'd this SD card a while back and forgot this essential step)
| Posted by: Andrew Burgess on February 15, 2008 at 12:44 PM |
You must disable suspend or your machine will
crash when suspending (suspend is enabled in
joyride builds and the soon to be released
update.1
Simply
echo 1 > /etc/ohm/inhibit-suspend
will do it.
You don't use a partition table, there is a bug
where shutting down with swap running can mash the
partition table of your sd card. So you need to
swapoff before shutting down or get very familiar
with repartitioning :-)
I like a partition table because bigger sd cards
can be partitioned 1G swap and the rest ext2
HTH
| Posted by: Brian Jepson on February 15, 2008 at 12:49 PM |
Thanks, Andrew! These are very good tips.
I have become very familiar with the repartitioning routine you describe. At one time, I tried formatting an SD card as an ext3 filesystem for supplementary storage, but it would get trashed so often that I decided to use it as swap. I haven't experienced a crash when suspending with the SD card in, but I suppose it's only a matter of time.
Has anyone tried modifying the shutdown scripts to umount and swapoff any SD card that happens to be in use before the bug kicks in?
| Posted by: helmingstay on March 31, 2008 at 4:30 PM |
here are relevant links to 2 major bugs between suspend and SD cards:
http://dev.laptop.org/ticket/6532
http://dev.laptop.org/ticket/4013
Bloggers
Welcome to the Hacks Blog!
Categories
- Ajax
- Amazon
- Android
- AppleTV
- arduino
- Astronomy
- Baseball
- BlackBerry
- Blogging
- Body
- Cars
- Cryptography
- Data
- Design
- Education
- Electronics
- Energy
- Events
- Excel
- Excerpts
- Firefox
- Flash
- Flickr
- Flying Things
- Food
- Gaming
- Gmail
- Google Earth
- Google Maps
- Government
- Greasemonkey
- Hacks Series
- Hackszine Podcast
- Halo
- Hardware
- Home
- Home Theater
- iPhone
- iPod
- IRC
- iTunes
- Java
- Kindle
- Knoppix
- Language
- LEGO
- Life
- Lifehacker
- Linux
- Linux Desktop
- Linux Multimedia
- Linux Server
- Mac
- Mapping
- Math
- Microsoft Office
- Mind
- Mind Performance
- Mobile Phones
- Music
- MySpace
- MySQL
- NetFlix
- Network Security
- olpc
- Online Investing
- OpenOffice
- Outdoor
- Parenting
- PCs
- PDAs
- Perl
- Philosophy
- Photography
- PHP
- Pleo
- Podcast
- Podcasting
- Productivity
- PSP
- Retro Computing
- Retro Gaming
- Science
- Screencasts
- Security
- Shopping
- Skype
- Smart Home
- Software Engineering
- Sports
- SQL
- Statistics
- Survival
- TiVo
- Transportation
- Travel
- Ubuntu
- User Interface
- Video
- Virtualization
- Visual Studio
- VoIP
- Web
- Web Site Measurement
- Windows
- Windows Server
- Wireless
- Word
- World
- Xbox
- Yahoo!
- YouTube
Archives
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
Recent Posts
- Minty soldering jig
- Selecting row number in MySQL
- iPhone 3G software unlock
- Python on Android
- Controlling Sony camcorders with the Arduino
- Gradient text effect in CSS
- Retro gaming emulators that include (legal) ROMs?
- Das DereLicht - ham radio transmitter from a CFL bulb
- Using Google App Engine as a personal CDN
- Route-me - Open Source mapping library for iPhone
www.flickr.com
|






Leave a comment