Raspberry Pi: Difference between revisions

From Leo's Notes
This page was last edited on 13 January 2016, at 07:30.
Line 34: Line 34:
== Miscellaneous ==
== Miscellaneous ==
=== Control Status LEDs ===
=== Control Status LEDs ===
See: http://www.midwesternmac.com/blogs/jeff-geerling/controlling-pwr-act-leds-raspberry-pi
The Raspberry Pi 2 LEDs are driven by the kernel's led-GPIO drivers. This allows for the LEDs to be controlled by software rather than hardware as is the case with the older first generation Pi's. The two LEDs on the Raspberry Pi 2 are the green status light (led0) and the red power light (led1).
 
To see the available triggers that are in use and available for a particular LED:
{{highlight|lang=terminal|code=
# cat /sys/class/leds/led1/trigger
none usb-gadget usb-host [mmc0] timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on transient flash torch input
}}
 
The active trigger is in {{code|[ ]}} and can be changed by writing to the file. For example, to turn off the LED entirely:
{{highlight|lang=terminal|code=
# echo none >  /sys/class/leds/led1/trigger
# cat /sys/class/leds/led1/trigger
[none] usb-gadget usb-host mmc0 timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on transient flash torch input
}}
 
You may also edit the {{code|config.txt}} file to change the behavior on startup.
{{highlight|lang=text|code=
# Disable the ACT LED.
dtparam=act_led_trigger=none
dtparam=act_led_activelow=off
 
# Disable the PWR LED.
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off
}}
 
See Also: http://www.armadeus.com/wiki/index.php?title=GPIO_LEDS


=== Mounting <code>/var/log</code> as tmpfs ===
=== Mounting <code>/var/log</code> as tmpfs ===

Revision as of 07:30, 13 January 2016

Setup

Arch Linux

Setup the SD card to contain two partitions using fdisk:

  1. 100MB (W95 FAT32 (LBA))
  2. Data

Download ArchLinux's Raspberry Pi tarball.

# fdisk /dev/sdcard
## Set up the SD card partitions
# mkfs.vfat /dev/sdcard1
# mkfs.ext4 /dev/sdcard2
# cd /mnt
# mkdir boot root
# mount /dev/sdcard1 boot
# mount /dev/sdcard2 root
# tar -xpf ArchLinuxARM-rpi-latest.tar.gz -C root
# mv root/boot/* boot
# umount boot root

For more information, see:

Configuration

Wifi

See Wifi.


Miscellaneous

Control Status LEDs

The Raspberry Pi 2 LEDs are driven by the kernel's led-GPIO drivers. This allows for the LEDs to be controlled by software rather than hardware as is the case with the older first generation Pi's. The two LEDs on the Raspberry Pi 2 are the green status light (led0) and the red power light (led1).

To see the available triggers that are in use and available for a particular LED:

# cat /sys/class/leds/led1/trigger 
none usb-gadget usb-host [mmc0] timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on transient flash torch input

The active trigger is in [ ] and can be changed by writing to the file. For example, to turn off the LED entirely:

# echo none >  /sys/class/leds/led1/trigger
# cat /sys/class/leds/led1/trigger 
[none] usb-gadget usb-host mmc0 timer oneshot heartbeat backlight gpio cpu0 cpu1 cpu2 cpu3 default-on transient flash torch input

You may also edit the config.txt file to change the behavior on startup.

# Disable the ACT LED.
dtparam=act_led_trigger=none
dtparam=act_led_activelow=off

# Disable the PWR LED.
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off

See Also: http://www.armadeus.com/wiki/index.php?title=GPIO_LEDS

Mounting /var/log as tmpfs

Append to the /etc/fstab with the following line.

tmpfs           /var/log tmpfs nodev,nosuid,mode=0755,size=50m  0 0

This will mount /var/log as a 50MB ramdisk. If your system is using systemd, this will break systemd-journald. To fix it, you will need to create a startup script after the mount has completed that creates the journald's directory in /var/log/journal/.

Reboot the Pi for the changes to take affect, or run mount -a which will mount the ramdisk to /var/log immediately, though you'll need to restart any services that has handles to any files there.

Why would you want to do this? To limit the amount of writes that is made to the SD card to prevent premature wearing.