Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Howto: Raspbian tips and tricks

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 149 times
Been thanked: 212 times

Howto: Raspbian tips and tricks

#1 Post by Hallvor »

Why a Raspberry Pi?

The Raspberry pi is a very inexpensive credit card sized ARM single board computer. What I write below is based on the B-model, which I have, costing only 35 USD.

Image

There are several major advantages with the Raspberry Pi.

* Dirt cheap.
* Uses only 3,5 W of electricity.
* Completely silent, since it does not have a fan.
* Plays full HD video files.

The Raspberry pi was not designed for being a media center, but the ability to play full HD video files has made quite a few people use it as one, and custom made distributions like RaspBMC demonstrates this.


Unboxing and setup

I ordered my Raspberry Pi from Element 14, and unfortunately it turned out it had a rough trip. The packaging was not the best, and the little knob by the power supply and some pins were slightly bent. Fortunately everything worked despite of the damage.

For power supply I used an old mobile phone charger purchased for a Sony Ericsson. The Raspberry Pi B-model must have a 5V power supply and at least 700ma.

The SDHC card to store the OS on was a Sandisk 16GB Class 4. The Raspberry Pi can be choosy as to what cards it runs on, and fortunately it worked out OK.

The OS I chose for it was Raspbian. A custom and stripped down Debian Wheezy OS with the LXDE desktop environment. I downloaded the image here: http://www.raspberrypi.org/downloads

You can use DD to transfer the image to the card in GNU/Linux. Instructions are found here:

http://elinux.org/RPi_Easy_SD_Card_Setup

If you have a Windows computer available you can use the Win32DiskImager application as shown here: http://blog.modmypi.com/2012/05/raspber ... guide.html

The card reader on my Debian box did not work correctly, so I *cough* used the Windows method *cough*. :)

I then plugged the SDHC card in, attached a HDMI cable from the TV, and finally plugged in the power supply. Lights started blinking on the board and text was flying over the TV screen. It worked!

On first boot you will be greeted by the raspi-config utility

Image

As you can see it offers an easy way to expand the root partition to fill the entire SDHC card, changing the time zone, language, etc.

Additional configurations can be found in /boot/config.txt

I had big black borders around the image, and fixed the issue by disabling overscan in the raspi-config utility.

While you are at it, it is a good idea to change the password.... The default username is pi and the password is raspberry. The Raspberry Pi comes with sudo enabled by default, and you might for the sake of habit and/or convenience want to enable the root account with sudo passwd root.

To view the current state and screen resolution, you can issue the following command:

Code: Select all

# /opt/vc/bin/tvservice -s
In my case I get this:

Code: Select all

state: HPD high|HDMI mode|HDCP off|composite off (0x12001a), 1920x1080 @ 60Hz, progressive
Full HD!

To list the possible resolutions on your screen, type this for CEA modes:

Code: Select all

# /opt/vc/bin/tvservice –m CEA
And this for a list of DMT supported modes:

Code: Select all

# /opt/vc/bin/tvservice –m DMT
View this page for more options on video settings:

http://elinux.org/RPi_config.txt

My own /boot/config.txt file looks like this:

Code: Select all

#Disable overscan
disable_overscan=1

#Normal PAL
sdtv_mode=2

#16:9 aspect ratio
sdtv_aspect=3

#Force the monitor to HDMI mode so that sound will be sent over HDMI cable
hdmi_drive=2

#Set HDMI group 1 (CEA), 2 for DMT
hdmi_group=1

#Set graphics mode number (hdmi_mode=16   1080p 60Hz)
hdmi_mode=16
Edit it like you want with:

Code: Select all

# nano /boot/config.txt
Save with Control + X and click Enter to exit.


The desktop – playing multimedia

The desktop itself is quite basic with just a few applications installed and also a few games. Here is what the desktop will look like after installation:

Image

Keep in mind that the Raspberry Pi is a very weak computer. In fact most smartphones are faster than it. So don't expect to run VLC with all the bells and whistles. It will not play the movie, but it will cause a horrible slowdown and make the system unresponsive.

The only player that will utilize the GPU acceleration is the omxplayer. It should be installed by default, but it is also so basic that it is CLI only.

Still, you don't have to open the CLI every time you want to watch a movie. You can easily add a menu shortcut and execute the player every time you click a media file:

First

Code: Select all

# nano /usr/share/applications/omxplayer.desktop
Add these values:

Code: Select all

[Desktop Entry]
Type=Application
Name=OMXPlayer
Categories=AudioVideo;Player;
Exec=lxterminal --command "omxplayer -o hdmi %f"
Terminal=false
Icon=/usr/share/icons/nuoveXT2/96x96/categories/applications-multimedia.png
Save and exit.

A menu icon should now be in place, and you can right click on media files and click Open with Omxplayer! Even full HD movies play just fine!

(You may want to ask why I didn't just install XBMC on top. The fact is I did compile it from source and ran it with xinit (without a GUI in the background). Apart from a few freezes and general low responsiveness, movies were choppy after a few hours of uptime and the CPU was constantly at some 80% even if nothing happened on the screen. (XBMC kept drawing frames regardless.) Being used to the awesomeness of Debian, going back was a no-brainer. ;))


Edit 22.08.12:

Fonts and web browsing

Font rendering may be in the eye of the beholder, but I did not like the font rendering of Raspbian one bit. Fortunately it was easy to fix:

Code: Select all

dpkg-reconfigure fontconfig-config
I turned autohinting on. Sub pixel hinting was left on auto. Then reboot and see the difference.

Midori is the default web browser. Maybe I did something wrong in turning on the adblock. I don't know. But the system spiked to 100% CPU and the system became totally unresponsive when I visited an online newspaper.

I had much better luck with NetSurf, that was also installed by default. It had good page rendering as well and did not eat up all my CPU. Dillo was even leaner and faster, but some pages were not rendered properly. I still consider both of them excellent choices for the Raspberry Pi.
Last edited by Hallvor on 2012-11-14 18:56, edited 8 times in total.
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: Howto: Raspbian tips and tricks

#2 Post by nadir »

Cool. And thanks.

Let me babble a bit.
I think it really should be stressed that vga monitors will not work. To me and some others is was not clear that a thing like dpi (?) monitors exist at all.

Hence i use it via ssh:
For the Debian image (stable) you will need to:
then rename the file 'boot_enable_ssh.rc' on the FAT32 partition of the SD card to be 'boot.rc'.
For Raspian it will work the usual Debian way (ssh will autostart during boot without any changes).

Speaking of Raspian:
I for one am not in measuring speed and such, but i think one really will want the Raspian image. To me it looks more snappy (while i mainly use ssh-connections, no gui at all).

I sometimes use
tightvncserver
after installing it i run the command as user on the raspberry pi, to start the VNC server, then connect (via remmina); default here is 192.168.1.25:1 ; username and password.
From a cli only server i can connect with directvnc (me thinks framebuffer is needed for it, and i recall it to be difficult to start at all).

I also need to run:

Code: Select all

modprobe snd_bcm2835
to be able to play sounds (not that sure, sounds strange to someone like me).

I use the raspberry for:
- gitolite server
- lamp for testing stuff, was a bit of trouble on the Debian image, didn't work on raspbian yet
- playing my music, mounted via sshfs, with xmms2
- training programming
- storing private files i don't want to store elsewhere (my calendar, my ssh and gpg keys backup, my notes, etc), mainly via gitolite

micro-SD cards with Adapter from Aldi, a discounter to be found in a couple of European countries, work well for me. Branch is Medion.

All as short i know.

Thanks again. Good and helpfull info.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 149 times
Been thanked: 212 times

Re: Howto: Raspbian tips and tricks

#3 Post by Hallvor »

You are welcome, nadir. I spent a few hours trying to figure everything out when I got it. I have the memory of a gold fish and someone out there might find the above useful, so why not write it down somewhere.

About your sound problem I have no idea. But I do have to force audio through HDMI with the -o HDMI parameter in omxplayer (like you can see above) when playing movies from the internal SDHC card. Or else I think we have a silent movie and need a piano. :lol:

Yes, I think Raspbian is the best choice at the moment. You'll get a little more performance out of the hardware. And on such low specs it makes a lot of difference.
http://www.memetic.org/raspbian-benchma ... -vs-armhf/
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: Howto: Raspbian tips and tricks

#4 Post by nadir »

Some raspberry recipes:
http://www.irongeek.com/i.php?page=secu ... pi-recipes
I would love to test i2p these days. Metasploit is beyond me, and the two other ones: i don't even know what that is :-).

and yes: written down somewhere is very handy (goldfish and such ... age... etc).
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

Lamilla45
Posts: 1
Joined: 2013-01-19 06:23

Re: Howto: Raspbian tips and tricks

#5 Post by Lamilla45 »

Last edited by Lamilla45 on 2014-10-16 12:14, edited 1 time in total.

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: Howto: Raspbian tips and tricks

#6 Post by nadir »

To be able to watch videos i enabled turbo mode, by running raspi-config and enabling it
If i understand correct that is CPU-overlocking
It works good.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 149 times
Been thanked: 212 times

Re: Howto: Raspbian tips and tricks

#7 Post by Hallvor »

nadir wrote:To be able to watch videos i enabled turbo mode, by running raspi-config and enabling it
If i understand correct that is CPU-overlocking
It works good.
I am getting more and more impressed by it. When I got it last summer, the performance was so bad that browsing the web on it was unbearable, with the CPU spiking to 100%. Now it is not a problem at all. It is simply amazing how much power it is possible to squeeze out of such a tiny and slow device.
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

User avatar
nadir
Posts: 5961
Joined: 2009-10-05 22:06
Location: away

Re: Howto: Raspbian tips and tricks

#8 Post by nadir »

Hallvor wrote:
nadir wrote:To be able to watch videos i enabled turbo mode, by running raspi-config and enabling it
If i understand correct that is CPU-overlocking
It works good.
I am getting more and more impressed by it. When I got it last summer, the performance was so bad that browsing the web on it was unbearable, with the CPU spiking to 100%. Now it is not a problem at all. It is simply amazing how much power it is possible to squeeze out of such a tiny and slow device.
I am amazed too.
But the turbo-mode screwed my SD-card twice, so i gave up on it.
Reconfiguring it takes really long (installing all packages is the worst part, else i just copy stuff around).

If i knew a safe way to back it up ...
I thought to unplug the SD-card and use dd to safe it on my PC /root/backup
But i am not good with dd (not good means: close to non-existent knowledge).
Can you help me with that?
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.

User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 149 times
Been thanked: 212 times

Re: Howto: Raspbian tips and tricks

#9 Post by Hallvor »

nadir wrote:
Hallvor wrote:
nadir wrote:To be able to watch videos i enabled turbo mode, by running raspi-config and enabling it
If i understand correct that is CPU-overlocking
It works good.
I am getting more and more impressed by it. When I got it last summer, the performance was so bad that browsing the web on it was unbearable, with the CPU spiking to 100%. Now it is not a problem at all. It is simply amazing how much power it is possible to squeeze out of such a tiny and slow device.
I am amazed too.
But the turbo-mode screwed my SD-card twice, so i gave up on it.
Reconfiguring it takes really long (installing all packages is the worst part, else i just copy stuff around).

If i knew a safe way to back it up ...
I thought to unplug the SD-card and use dd to safe it on my PC /root/backup
But i am not good with dd (not good means: close to non-existent knowledge).
Can you help me with that?
Did you overvolt as well, or just overclock? I know that overvolting tends to fry the SD-card. I have a SanDisk class 4 card, and haven't had any problems with overclocking. My Pi has been overclocked for several months now.

Sorry, I am not good with dd either.
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

RichardBronosky
Posts: 1
Joined: 2013-02-25 02:26

Re: Howto: Raspbian tips and tricks

#10 Post by RichardBronosky »

The dd part is pretty easy. I don't know how you created the SD without dd in the first place, but you ought to be able to swap the paths used by that command.

For me, this is how I create the SD:

Code: Select all

# on Linux:
dd bs=1m if=~/raspbian/2013-02-09-wheezy-raspbian.img of=/dev/sdb
#on Mac
dd bs=1m if=~/raspbian/2013-02-09-wheezy-raspbian.img of=/dev/disk2
The way I make a backup of the SD is:

Code: Select all

# on Linux:
dd bs=1m of=~/raspbian/backup.img if=/dev/sdb
#on Mac
dd bs=1m of=~/raspbian/backup.img if=/dev/disk2
Notice that I changed "if" (input file) to "of" (output file) and vice versa. It is possible to pipe dd into gzip. You need to keep in mind that unlike a tar file, a gzip file does not know the destination filename** for its content, so it just strips the gz off the end of the source file. There for I suggest you give it double extensions like so:

Code: Select all

# on Linux:
dd bs=1m if=/dev/sdb | gzip > ~/raspbian/backup.img.gz
#on Mac
dd bs=1m if=/dev/disk2 | gzip > ~/raspbian/backup.img.gz
** not entirely true (see -N option in the gunzip man page) but the default behavior is to favor the name of the compressed file over the optional name stored in the archive. In the case of creating a gzip file from a pipe, it isn't going to have a stored filename unless you do some kind of heroic fifo work that's over my head.

User avatar
Hallvor
Global Moderator
Global Moderator
Posts: 2042
Joined: 2009-04-16 18:35
Location: Kristiansand, Norway
Has thanked: 149 times
Been thanked: 212 times

Re: Howto: Raspbian tips and tricks

#11 Post by Hallvor »

RichardBronosky: Thanks for this useful info.
[HowTo] Install and configure Debian bookworm
Debian 12 | KDE Plasma | ThinkPad T440s | 4 × Intel® Core™ i7-4600U CPU @ 2.10GHz | 12 GiB RAM | Mesa Intel® HD Graphics 4400 | 1 TB SSD

ocpaul20
Posts: 10
Joined: 2011-10-01 08:24

Re: Howto: Raspbian tips and tricks

#12 Post by ocpaul20 »

at the risk of being stoned, I would like to suggest folks look at a raspberry pi clone called the cubieboard (cubieboard.org). I have one and installed Raspbian on it as it is also based on allwinner a10 but has an additional SATA socket, 1Ghz processor and 1Gb ram. It is slightly more expensive but I got mine in China for 400RMB + shipping but they have distributors in most countries.

confuseling
Posts: 2121
Joined: 2009-10-21 01:03

Re: Howto: Raspbian tips and tricks

#13 Post by confuseling »

The Raspberry Pi foundation are a non-profit, and have actually directly stated that they want to kick-start mass production / use of single board computers generally, not just their own. I've seen a few people mention the Beaglebone Black as well.

I just got a Pi myself - seems to me valuable to have a popular, unified platform, with well-honed specialist tools and distributions. Though that said having some experience of Debian it's been extremely simple to set up.

Anyway, the point is, no stonings for you, they welcome the clones, as should we all I suspect :-)
The Forum's search box is terrible. Use site specific search, e.g.
https://www.google.com/search?q=site%3A ... terms+here

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: Howto: Raspbian tips and tricks

#14 Post by llivv »

If anyone has tested the pi's card reader speed ( using different class SD's )
it would be nice to know what class is the most cost effective for the pi's card reader.
I plan to do a test with 4 different class cards when I get time.
The pi site says that all SDHD cards should work and show a tested list.
Some have also tested a few sandisk SDXC that work too (as always) YMMV.
Even though some of sandisks SDXC cards can be read,
I doubt they are being read anywhere near rated read spec.
Anyone else interested in this spec?
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

confuseling
Posts: 2121
Joined: 2009-10-21 01:03

Re: Howto: Raspbian tips and tricks

#15 Post by confuseling »

There's this:

http://www.raspberrypi.org/phpBB3/viewt ... f=2&t=4076

And this:

http://elinux.org/RPi_SD_cards

(although I read somewhere the latter may be quite outdated, haven't really looked into it).

The consensus as far as it goes seems to be that Class 10 are normally highly optimised for sequential writes, so random can really suffer. I've read a fair few people say they got better numbers from Class 6 (hardly scientific I know, so I wouldn't take my word for it...).

I think the reality is it isn't going to be fast no matter what you do, so try to find one of the right size and a reasonable price where people have posted numbers / reports that it works OK, and just run with it...
The Forum's search box is terrible. Use site specific search, e.g.
https://www.google.com/search?q=site%3A ... terms+here

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: Howto: Raspbian tips and tricks

#16 Post by llivv »

confuseling wrote: And this:

http://elinux.org/RPi_SD_cards

(although I read somewhere the latter may be quite outdated, haven't really looked into it).
There's a new section with new data. thanks confuseling :wink:
what's your favorite raspberry pi topping?
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

confuseling
Posts: 2121
Joined: 2009-10-21 01:03

Re: Howto: Raspbian tips and tricks

#17 Post by confuseling »

I'm running Raspbian Wheezy as a seedbox at the moment. Going to set it up with a software RAID JBOD as backup / file server, probably running dokuwiki and squid.

I haven't even plugged it into a screen yet (perhaps never will...), but it does what I need it to do perfectly so far. For the price I think it's great, and I'm glad to provide a tiny bit of support to the Foundation too by having bought one.
The Forum's search box is terrible. Use site specific search, e.g.
https://www.google.com/search?q=site%3A ... terms+here

ntrcessor
Posts: 1
Joined: 2014-12-05 04:56

Re: Howto: Raspbian tips and tricks

#18 Post by ntrcessor »

I noticed someone posted that VGA monitors don't work with the Pi, but in fact they do. You just need an HDMI to VGA adapter. (Which I have, plus I have a slitter) so you can mirror the display on 2 monitors. Note: The splitter I have does not "trick" the raspbian into thinking I have a huge display, so no you cannot use it to do "twinview" or xinerama. The splitter just repeats the same out on both vga outs. Usefule when doing a presentation so you don't have to turn around to see the display behind you.

I'm using a self powered usb-hub which has greatly increased the number of devices I have hooked up. I bought it for Home Automation, but I'm playing with other functions before I decide if I'm going to do that. It seems a bit slow for the original purpose I bought it for. It's a neat toy, and probably great for single purpose things. but even with misterhouse being the "only" app running (other than drivers) it is still very slow. All of the other home control apps I have tried are even slower yet, so if I do use it in Home automation, I'll probably just use it as a repeating controller, or a gateway, and run mh or some other software on something a little more powerful. It's make a great "gateway" for separate powerline segments in a house to be able to repeat a command without using a phase coupler.

Post Reply