Raspberry Pi

From Holyheads Wiki
(Difference between revisions)
Jump to: navigation, search
(Trying to educe number of disk writes (SD card))
(Trying to educe number of disk writes (SD card))
Line 68: Line 68:
 
*** <code>/var/spool</code>
 
*** <code>/var/spool</code>
 
*** <code>/var/log</code>
 
*** <code>/var/log</code>
*** <code>/tmp</code>
 
 
** edited <code>/etc/insserv</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:
 
** edited <code>/etc/insserv</code> to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:
 +
** moved <code>/tmp</code> to <code>/run</code> (a non-persistent tmpfs already present in Raspbian).
  
 
  $local_fs_orig  +mountall +mountall-bootclean +mountoverflowtmp +umountfs
 
  $local_fs_orig  +mountall +mountall-bootclean +mountoverflowtmp +umountfs
Line 77: Line 77:
 
:: <code>/etc/init.d/persist-ramdisk</code> depends on $local_fs_orig, and the other init-scripts keep their dependency to $local_fs. This ensures that /var/log and /var/spool are ok when starting & stopping other init scripts.
 
:: <code>/etc/init.d/persist-ramdisk</code> depends on $local_fs_orig, and the other init-scripts keep their dependency to $local_fs. This ensures that /var/log and /var/spool are ok when starting & stopping other init scripts.
  
But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').
+
Before moving <code>/tmp</code>:
I need to do more digging...
+
::But still, <code>iostat</code> shows quite some data written to the SD card, according to <code>iotop</code> its ''jbd2'', the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with ''noatime'').
 +
::I need to do more digging...
 +
 
 +
After moving <code>/tmp</code>:
 +
: It looks like the unwanted writes to SD are gone. I'll watch it for some time...
  
 
===Useful stuff and Q&A===
 
===Useful stuff and Q&A===

Revision as of 00:51, 6 January 2014

Contents

Cockbook

My collection of hints, tips and tricks (supporting my memory and maybe also helping others).

External USB drives

  • Install ntfs-3g if you need write access to ntfs file systems
  • How to increase performance?

udevil

  • exmaple for manual mounting:
udevil mount /dev/sda1
  • my build-steps (maybe there's a simpler way, but this worked...):
    • download 0.4.3/udevil_0.4.3-1_all.deb from https://github.com/IgnorantGuru/udevil/tree/pkg, e.g. using wget
    • extract deb-package via ar vx udevil_0.4.3-1_all.deb
    • extract data archive tar xzvf data.tar.gz
    • change to tar usr/share/devil/src
    • untar tar xvfJ udevil-current.tar.xz
    • cd udevil-0.4.3
    • mv distros/debian
    • execute dpkg-buildpackage
    • If all required packages are installed, this results in udevil_0.4.3-1_armhf.deb. If the build fails due to missing packages, install the missing packages, and re-do the dpkg-buildpackage step
    • Install via sudo dpkg -i udevil_0.4.3-1_armhf.deb

Samba server / NAS

  • Slow disc performance?
    • see 'Slow USB drives' above
    • use Raspbian, etc without GUI to get as much CPU power for file-transfer as possible (OpenELEC or RaspBMC constantly use about 10-20% CPU load when idle, use top to check!)

Trying to educe number of disk writes (SD card)

I'm using RRD with a cron job (currently observing pi's temperature and frequency). I hope that my SD card has proper wear-leveling (and currently my 8 GB card is less than half full), so that the frequent writing should not be a problem. But still, I want to reduce the number of writes to the SD card (in order to not bust it's lifetime).

Here's what I've done:

  • Edit /etc/default/cron and set EXTRA_OPTS="-L 0" to disable logging (don't need these)
  • Avoid entries like pam_unix(cron:session): session closed for user pi in /var/log/auth.log
    • Edit /etc/pam.d/cron and comment the line @include common-session-noninteractive ([1])
or
  • I've implemented a persist tmpfs as discussed in http://www.a-netz.de/2013/02/persistent-storage-with-ramdisks/ and http://www.observium.org/wiki/Persistent_RAM_disk_RRD_storage (and, I guess, many other sites)
    • moved all the .rrd files as well as the created images to my persistent-ramdisk location
    • moved some directories with frequent writes to my persistent-ramdisk location and added corresponding sym-links
      • /var/spool
      • /var/log
    • edited /etc/insserv to add the persist-ramdisk as a requirement to $local_fs; the original definition can still be accessed as $local_fs_orig:
    • moved /tmp to /run (a non-persistent tmpfs already present in Raspbian).
$local_fs_orig  +mountall +mountall-bootclean +mountoverflowtmp +umountfs
# we need the sym-link data in /var/log and /var/spool to be available
$local_fs       $local_fs_orig +persist-ramdisk
/etc/init.d/persist-ramdisk depends on $local_fs_orig, and the other init-scripts keep their dependency to $local_fs. This ensures that /var/log and /var/spool are ok when starting & stopping other init scripts.

Before moving /tmp:

But still, iostat shows quite some data written to the SD card, according to iotop its jbd2, the ::journaling part of ext4 (pi is 'idle', only some services run, and the ext4 partition is mounted with noatime).
I need to do more digging...

After moving /tmp:

It looks like the unwanted writes to SD are gone. I'll watch it for some time...

Useful stuff and Q&A

  • Q: Does Raspberry support WOL?
A: No: the Ethernet chip is connected via USB (http://www.raspberrypi.org/forum/viewtopic.php?f=53&t=39714)
  • Q: The new password is to short, or too simple
A: Try adjusting the PAM settings in /etc/pam.d/common-password:
  • remove the 'obscure' setting for pam_unix.so, and add your desired minimum length (e.g. minlen=2)
 password        [success=1 default=ignore]      pam_unix.so sha512 minlen=2
!! This is not recommended if your box is connected to the internet or if it contains private data noone should know!!
But it's nice for testing (if you cannot or do not want to use auto-login.)
  • Q: How to configure static IP?
A: In /etc/network/interfaces:
 iface eth0 inet static
   address 192.168.0.31
   netmask 255.255.255.0
   gateway 192.168.0.1
  • Q: How to read core temperature, etc?
A: vcgencmd:
 vcgencmd measure_temp
 vcgencmd measure_clock arm
  • External USB HDD spin down
    • hdparm does not work with my WD Elements (SG_IO: bad host status: 0x7)
    • hd-idle works:
hd-idle -a sda -i 600
for details, see for example http://blog.is-a-geek.org/festplatten-in-den-standby-modus-versetzen-unter-ubuntu-desktopserver-mit-hd-idle (German)
  • Q: How to avoid update of a certain package?
A: Put package on hold ([2] (German)):
echo <paketname> "hold" | dpkg --set-selections
  • Q: How many bytes are written to my (SD) disc?
A: Use iostat http://www.mybinarylife.net/2012/08/linux-iostat-command.html
A: Use iotop http://guichaz.free.fr/iotop/
A: Raw data of the kernel can be found in files /proc/diskstats and /sys/block/DEVNAME/stat https://www.kernel.org/doc/Documentation/iostats.txt

Things I want to (or might) try sometime

  • Explore overclocking limits of my RaspBerry - currently I'm using medium set via raspi-config
--> Raspberry Pi Stress Tests
  • NAS/Samba
  • try adjusting 'socket options' in (/etc/samba/smb.conf) to increase NAS performance: some websites recommend to disable the 'socket options', some recommend to set:
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
  • adjust memory split - smaller GPU memory for server
  • ext4 vs ntfs for storage drive
  • nfs [3] vs samba

Some links

Project sites

Blogs, forums, etc

Misc

Manuals

Personal tools