Your First Bite of Raspberry Pi
To Swap or Not to Swap
SD cards are getting better every year when it comes to wear leveling and write cycles. The concern is always that excessive use of the SD card will wear it out, and it will become read-only. Because the RPi also suffers from limited and non-expandable RAM, the issue of swap space is highly debated.
Raspbian comes installed by default with a swap file active—not a swap partition, but a swap file. Whether this swap file will wear out your SD card is still up for debate. I tend to be paranoid about such things, so I searched for an alternative. Because I have the 512MB units, I have a little more RAM to work with, so I decided to use zRam to compress some of the system RAM and use it as swap space. How does that work? Basically, zRam allows the system to use RAM as swap space, but in a compressed mode that allows it to appear as more RAM+swap than the system actually contains.
zRam already is compiled into the Raspbian kernel, so if you want to try my method, it just takes a little scripting. I absolutely love the script I found at the eXtremeSHOK.com Web site. That site is off-line at the time of this writing, so I've included the script below. Create a file called /etc/init.d/zram, which contains the following:
#!/bin/bash
### BEGIN INIT INFO
#Provides: zram
#Required-Start:
#Required-Stop:
#Default-Start: 2 3 4 5
#Default-Stop: 0 1 6
#Short-Description: Increased Performance In Linux With zRam
#(Virtual Swap Compressed in RAM)
#Description: Adapted for Raspbian (Rasberry pi) by eXtremeSHOK.com
#using https://raw.github.com/gionn/etc/master/init.d/zram
### END INIT INFO
start() {
mem_total_kb=$(grep MemTotal /proc/meminfo | grep -E --only-matching '[[:digit:]]+')
modprobe zram
sleep 1
#only using 50% of system memory, comment the line
#below to use 100% of system memory
mem_total_kb=$((mem_total_kb/2))
echo $((mem_total_kb * 1024)) > /sys/block/zram0/disksize
mkswap /dev/zram0
swapon -p 100 /dev/zram0
}
stop() {
swapoff /dev/zram0
sleep 1
rmmod zram
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
RETVAL=1
esac
Then you need to make the init script executable and force it to start automatically. The following commands accomplish that:
sudo chmod +x /etc/init.d/zram
sudo update-rc.d zram defaults
Basically, as written, the script will use half the available RAM as compressed swap space. Again, all credit goes to the folks at eXtremeSHOK.com for creating the init script. I've been very happy with the performance, and it enabled me to get rid of the swap file altogether.
What's Next?
Hopefully this intro to the Raspberry Pi will make the device a little less intimidating for folks like me who were hesitant. With its ability to run XBMC, function as a complete desktop system and yet barely sip electricity, the RPi is a great device for countless projects. And at $35, it's absolutely dirt cheap.
We expect to see many, many Raspberry Pi projects around the Linux Journal offices. Hopefully you'll see a few around your place as well. If you have any particularly cool projects or case mods, send a photo to ljeditor@linuxjournal.com. We'd love to see what you're all up to.
Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- New Products
- Tech Tip: Really Simple HTTP Server with Python
- Developer Poll
- git-annex assistant
11 min 41 sec ago - direct cable connection
34 min 11 sec ago - Agreed on AirDroid. With my
44 min 27 sec ago - I just learned this
48 min 37 sec ago - enterprise
1 hour 18 min ago - not living upto the mobile revolution
4 hours 10 min ago - Deceptive Advertising and
4 hours 45 min ago - Let\'s declare that you have
4 hours 46 min ago - Alterations in Contest Due
4 hours 47 min ago - At a numbers mindset, your
4 hours 48 min ago



Comments
raspberry
I have a raspberry pi and a old screen from my phone and plenty other screens from other devices and some random screens. Could someone give me a link or instructions on how to do so. spelmaskiner
Anne, best wishes from the
Anne, best wishes from the Corporate Email SolutionJust wanted to drop a comment and say I am new to your blog and really like what I am reading. Thanks for the great content. Look forward to coming back for more......
I like your point which you
I like your point which you given in your blogs specially Case Option: Buy One, Case Option: Steal from the Nursery, Case Option: 3-D Printing, Case Option: Regular Printing. http://www.usacoverage.com
http://www.lovewigs88.com You
http://www.lovewigs88.com
Your blog is a great one. What really impresses me is that you are correctly mentioned that there are thousands of tools that are available to create a website or launch one but what matters is that you choose the right one, the one that gives you all that is actually needed
One question about linux in
One question about linux in Modelos de Currículo
first bite
Here in dotMobi we found ourselves repeatedly switching UAs and reloading pages in our testing of our own products lipo 6 black, lipo 6 unlimited and dhea
No, better check this out
No, better check this out smscredit this 100 more better then your page, lol!
raspberry
The van has always been difficult to start but when I asked a mechanic I was told some vehicles are just like that lipo 6 black ultra
good sd card?
Seems like a nice little toy, but I don't really like the fact that it does not boot from USB. Can you recommend a good SD-Card?
http://www.comedians-in-deutschland.de
is that usb card come inside
is that usb card come inside an cereal box ? ... i really think that they sould put those in brasilian cereal ... i would be so happy ahahah
have a nice day !!
Madeira plastica | plastic lumber | korando |
zadi
The observation or line!
Electrical current
Electrical current and therefore power supply capacity is measured in Amps or mA.
Power supplies are rated in Watts which is V x A = W, there is no unit of time involved.
Energy has a time component W x s = Joules.
If you consider a battery is rated at a Voltage it is able to provide then a simplification of the power that it can supply is in Amp-Hours or Ah / mAh. Power supplies by definition do not have an Ah rating as they don't run out....execpt in a power cut etc.
missie
in the line, in the horizont, in the tv online
Can you help me?
Do you think you could perhaps make a simpler explanation on the steps to split the brain to allocate the preffered RAM to GPU
Swap on a network filesystem
Have you given any thought/consideration to swapping on NFS or the like? I wonder if that would address your concerns about limited memory...
Dear Shawn, Please note that
Dear Shawn,
Please note that current is not measured in mAh but in mAh/h, or just mA. But who cares?
Best regards
/Janne
Power and current
I care, Janne, because I have a selection of power supplies that can deliver this voltage, but would like to know the max. current expected before fitting one. Why blow a functioning PS unnecessarily.
test
thank you about this blog
arab eye