树莓派漂流记(更新中)
Pubdate:2013-04-10 21:09:20 Categories: linux 2037 ViewsTags: linux
2013年4月10日
昏天黑地地搞了一段时间的树莓派,今天推倒重来了。决定把整个过程事无巨细都记下来,搞一个流水帐,或者叫编年史。
先简单回顾一下之前的过程。
树莓派这东西,关注很久了,但是一直没买,没有琢磨好用它来做什么。最近因为路由器上的openwrt折腾得不爽,还是想搞一个装Gentoo的树莓派。
东西到手后,马上兴致勃勃地操练起来,google "Raspberry Pi gentoo"。按网上的教程装好基本系统。但遗憾的是,根本启动不了。无奈先把之前做的拷出来。下载了个树莓派官方的镜像,试试硬件无问题。然后又下载了一个Gentoo的镜像,也能启动,但不提示login,把最初做的那个拷回来,就可以启动了,怀疑之前的分区顺序什么的有问题。
下一步,emerge distcc
但是distcc信赖的python居然编译了一天还在configure阶段。灰心了。决定找其他编译方式,druggo提议我完全用PC编译,但我没找到完美方法,用qemu-user配置麻烦,据说也很慢,还有用手机编译的。于是再次硬着头皮在PI上编译,居然很快把python编译完了。估计是系统时间问题,在什么地方死循环了。原来在PC上也碰到过。这样就顺利地七七八八地编译,做一些细节上的打磨。结果就是不能正常启动了。提示login:,但进不去。网络也没起来。错误提示也看不清,用手机拍下来看,模模糊糊好像是sh报错,找不以gcc的一个什么库。没想起什么好法子。因为记不清楚之前搞过什么,决定推倒重来。
这次直接用那个gentoo的镜像。
dd if=gentoo.img of=/dev/mmcblk0 bs=1M
启动还是不提示login:,远程ssh又不知道密码。
困了,睡觉了。明日再战。
2013年4月11日
拨卡,插到PC上,
Edit the line for root so it looks like the example below.
#cat /etc/shadow
root::10770:0:::::
ssh 不成功
add to /etc/shadow the root password hash generated by:
# openssl passwd -1
shadow里的root一行变为
root:XXX:10770:0:::::
ssh 登录成功。
把我2T的移动硬盘插上。准备把/usr、/home和/var搞到那上面。
#mount /dev/sda1 /mnt/dev/sda1
#cd /usr
#tar cf - * |(cd /mnt/dev/sda1; tar xf -)
/var也如法炮制。
编辑/etc/fstab如下:
# cat /etc/fstab
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 0
/dev/mmcblk0p2 none swap sw 0 0
/dev/mmcblk0p3 / ext4 defaults 0 0
/dev/sda1 /usr ext4 defaults 0 0
/dev/sda5 /var ext4 defaults 0 0
/dev/sda2 /home ext4 defaults 0 0
下载最新的portage:
#cd /usr
#wget http://mirrors.163.com/gentoo/snapshots/portage-latest.tar.bz2
#tar xvjf portage-latest.tar.bz2
#rm portage-latest.tar.bz2
改正时间设置:
#ls /mnt/gentoo/usr/share/zoneinfo
#cp /mnt/gentoo/usr/share/zoneinfo/Asia/Shanghai /mnt/gentoo/etc/localtime
#echo "Asia/Shanghai">/etc/timezone
#rc-update add swclock boot
#rc-update del hwclock boot
启动校时:
# /etc/init.d/ntp-client restart
* Setting clock via the NTP client 'ntpdate' ...
* Failed to set clock [ !! ]
修改ntp-client设置:
# cat /etc/conf.d/ntp-client
# /etc/conf.d/ntp-client
# Command to run to set the clock initially
# Most people should just leave this line alone ...
# however, if you know what you're doing, and you
# want to use ntpd to set the clock, change this to 'ntpd'
NTPCLIENT_CMD="ntpdate"
# Options to pass to the above command
# This default setting should work fine but you should
# change the default 'pool.ntp.org' to something closer
# to your machine. See http://www.pool.ntp.org/ or
# try running `netselect -s 3 pool.ntp.org`.
NTPCLIENT_OPTS="-s -b -u 192.168.1.1 \
3.cn.pool.ntp.org"
#/etc/init.d/ntp-client restart
修改profile:
#eselect profile list
...
[21] default/linux/arm/13.0/armv6j
...
#eselect profile set 21
# emerge distcc -av
!!! Unable to parse profile: '/etc/make.profile'
!!! ParseError: Profile contains unsupported EAPI '5': '/usr/portage/profiles/eapi-5-files/eapi'
!!! Your current profile is invalid. If you have just changed your profile
!!! configuration, you should revert back to the previous configuration.
!!! Allowed actions are limited to --help, --info, --search, --sync, and
!!! --version.
portage不够新?emerge --sync之后还不行, 如下方法解决:
#eselect profile set 0
#emerge -u portage
#eselect profile set 21
distcc 是原来就装了的。设置一下:
#cat /etc/conf.d/distccd
# /etc/conf.d/distccd: config file for /etc/init.d/distccd
DISTCCD_OPTS=""
# this is the distccd executable
DISTCCD_EXEC="/usr/bin/distccd"
# this is where distccd will store its pid file
DISTCCD_PIDFILE="/var/run/distccd/distccd.pid"
# set this option to run distccd with extra parameters
# Default port is 3632. For most people the default is okay.
DISTCCD_OPTS="${DISTCCD_OPTS} --port 3632"
# Logging
# You can change some logging options here:
# --log-file FILE
# --log-level LEVEL [critical,error,warning, notice, info, debug]
#
# Leaving --log-file blank will log to syslog
# example: --log-file /dev/null --log-level warning
# example: --log-level critical
DISTCCD_OPTS="${DISTCCD_OPTS} --log-level critical"
# SECURITY NOTICE:
# It is HIGHLY recomended that you use the --listen option
# for increased security. You can specify an IP to permit connections
# from or a CIDR mask
# --listen accepts only a single IP
# --allow is now mandatory as of distcc-2.18.
# example: --allow 192.168.0.0/24
# example: --allow 192.168.0.5 --allow 192.168.0.150
# example: --listen 192.168.0.2
DISTCCD_OPTS="${DISTCCD_OPTS} --allow 192.168.1.0/24"
#DISTCCD_OPTS="${DISTCCD_OPTS} --listen 192.168.0.2"
# set this for niceness
# Default is 15
DISTCCD_OPTS="${DISTCCD_OPTS} -N 15"
# cat /etc/distcc/hosts # --- /etc/distcc/hosts ----------------------- # See the "Hosts Specification" section of # "man distcc" for the format of this file. # # By default, just test that it works in loopback mode. #192.168.1.3,cpp,lzo 192.168.1.3 192.168.1.2 localhost
#emerge syslog-ng
#/etc/init.d/syslog-ng start
2013年4月12日
emerge gentoolkit
emerge system -av
一堆block
#emerge vim
#emerge openrc
#emerge gentoolkit
#emerge sysvinit util-linux
2013年4月13日
3点多就被老婆的呼噜+恶梦惊醒。梦见一个同学去世了。起床。
把/etc/inittab中的这一行去掉注释:
c1:12345:respawn:/sbin/agetty 38400 tty1 linux
本地有登录提示了。
#emerge genlop
建个普通用户:
#useradd -G users,wheel,audio -s /bin/bash lq
做一个备份系统的脚本,备份一下以防又推倒重来:
#cat backuppi
tar cvpjf /home/lq/backup/backuppi-`date +%F-%H-%m`.tbz2 / --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys --exclude=/home --exclude=/usr/portage --exclude=/var/tmp
# chmod u+x backuppi
#./backuppi
才288M。
udev 升级到200看来还有些麻烦:
# rc-update del udev-postmount
#emerge world -uNDv
开了其他两台机器帮Pi编译。
# cat /usr/sbin/distcc-watch
#!/bin/bash
# This script will only print non-blank results from distccmon-text
N=1 # seconds to sleep in between checks
while true; do
task=`DISTCC_DIR="/var/tmp/portage/.distcc/" distccmon-text`
taskshort=`echo $task | tr -d ' '`
len=${#taskshort}
if [ $len -ne 0 ];then
echo "$task"
fi
sleep $N
done
#distcc-watch
#emerge lxde-meta
哈哈,开足马力吧。
2013年4月14日
开着一台笔记本和pi编译了一夜,早上醒来,emerge lxde-meta完了,emerge world还没有完。
# genlop -c
Currently merging 56 out of 70
* sys-devel/gcc-4.6.3
current merge time: 5 hours, 26 minutes and 55 seconds.
ETA: 2 hours, 15 minutes and 24 seconds.
感觉笔记本的效率太低了。修改/etc/make.conf,原来是j5,加到j15:
# cat /etc/make.conf
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-O2 -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard"
CXXFLAGS="${CFLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="armv6j-hardfloat-linux-gnueabi"
MAKEOPTS="-j15"
FEATURES="parallel-fetch buildpkg distcc"
GENTOO_MIRRORS="http://mirrors.163.com/gentoo/"
#GENTOO_MIRRORS="http://intelminer.com/gentoo"
#SYNC="rsync://intelminer.com/gentoo-portage"
ACCEPT_LICENSE="*"
EMERGE_DEFAULT_OPTS="--quiet-build=n --autounmask-write --keep-going"
PORTAGE_NICENESS="15"
PKGDIR="/var/binary"
#emerge samba
#emerge mplayer
配置nfs共享portage,参见另文。
最初次的应用,很兴奋啊。
不幸随之而来。正当这些热火朝天地干着的时候,kernel panic出现了。
重启。修改make.conf:
MAKEOPTS="-j10"
#emerge world -uNDv
# emerge vixie-cron
# /etc/init.d/vixie-cron start
# rc-update add vixie-cron default
# emerge usbutils
# emerge bluez
发现kmod的提示:
* Messages for package sys-apps/kmod-12-r1:
* Unable to find kernel sources at /usr/src/linux
* Unable to calculate Linux Kernel version for build, attempting to use running version
*
* /System.map not found.
* You must manually update the kernel module dependencies using depmod.
*
中间发现udev-200的一个提示:
* Messages for package sys-fs/udev-200:
* Unable to find kernel sources at /usr/src/linux
* Unable to calculate Linux Kernel version for build, attempting to use running version
* CONFIG_BLK_DEV_BSG: is not set when it should be.
* Please check to make sure these options are set correctly.
* Failure to do so may cause unexpected problems.
* The new predictable network interface names are used by default, see: * http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames * * Example command to get the information for the new interface name before booting * (replace <ifname> with, for example, eth0): * # udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null * * You can use kernel commandline net.ifnames=0 to disable this feature. * * You need to restart udev as soon as possible to make the upgrade go * into effect. * The method you use to do this depends on your init system. * Old versions of installed libraries were detected on your system. * In order to avoid breaking packages that depend on these old libs, * the libraries are not being removed. You need to run revdep-rebuild * in order to remove these old dependencies. If you do not have this * helper program, simply emerge the 'gentoolkit' package. * * # revdep-rebuild --library '/lib/libudev.so.0' && rm '/lib/libudev.so.0' * * For more information on udev on Gentoo, upgrading, writing udev rules, and * fixing known issues visit: * http://wiki.gentoo.org/wiki/Udev/upgrade * http://www.gentoo.org/doc/en/udev-guide.xml
看看现在支持不?
# zcat /proc/config.gz |grep CONFIG_BLK_DEV_BSG
# CONFIG_BLK_DEV_BSG is not set
# CONFIG_BLK_DEV_BSGLIB is not set
# revdep-rebuild --library '/lib/libudev.so.0' && rm '/lib/libudev.so.0'
还是要升级内核了,准备在PC上编译。
又是比较凶险的说。
# git clone --depth 1 git://github.com/raspberrypi/linux.git
# scp 192.168.1.11:/proc/config.gz .
#gunzip config.gz
#cp config linux/.config
# cd linux
# ARCH=arm CROSS_COMPILE=/usr/bin/armv6j-hardfloat-linux-gnueabi- make oldconfig
# ARCH=arm CROSS_COMPILE=/usr/bin/armv6j-hardfloat-linux-gnueabi- make -j3
distcc不知为什么失灵了。pi自己在编译gcc
2013年4月15日
早上起来,pi还在编译gcc,Ctrl-c,reboot,啊哈,居然起来了。eth0也没变。决定内核暂不升级。
#emerge xorg-server
#emerge bluez
* Messages for package sys-auth/consolekit-0.4.5_p20120320-r1:
* Unable to find kernel sources at /usr/src/linux
* Unable to calculate Linux Kernel version for build, attempting to use running version
* CONFIG_AUDITSYSCALL: is not set when it should be.
* Please check to make sure these options are set correctly.
* Failure to do so may cause unexpected problems.
插上蓝牙适配器。
# /etc/init.d/bluetooth start
#rc-update add bluetooth default
44:2A:60:EE:D2:18 Apple Wireless Keyboard
# emerge pygobject
# ./simple-agent
Traceback (most recent call last):
File "./simple-agent", line 8, in <module>
import dbus
ImportError: No module named dbus
2013年4月16日
配置蓝牙键盘失败。
2013年4月20日
配置samba:
# useradd -d /usr/samba -s /sbin/nologin samba
# passwd samba
# smbpasswd -a samba
# cat /etc/samba/smb.conf|grep '^[^#;]'
[global]
workgroup = MYGROUP
server string = GentooPi
security = user
load printers = yes
log file = /var/log/samba/log.%m
max log size = 50
dns proxy = no
[homes]
comment = Home Directories
browseable = yes
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[public]
comment = Public Stuff
path = /home/samba
public = yes
writable = yes
printable = no
#write list = @staff
2013年4月23日
#emerge xorg-server
然后startx,一次成功,真是意外。
emerge layman
layman -a xmw
emerge omxplayer
:(报错。
emerge mplayer 巨慢。
2013年4月24日
emerge alsa-utils
没有认到声音设备。
2013年4月29日
sudo modprobe snd_bcm2835
能播放了,但没声音。
2013年4月30日
emerge transmission
其他机器访问报403。
2013年5月5日
# cat /var/transmission/config/settings.json
{
"alt-speed-down": 50,
"alt-speed-enabled": false,
"alt-speed-time-begin": 540,
"alt-speed-time-day": 127,
"alt-speed-time-enabled": false,
"alt-speed-time-end": 1020,
"alt-speed-up": 50,
"bind-address-ipv4": "0.0.0.0",
"bind-address-ipv6": "::",
"blocklist-enabled": false,
"blocklist-url": "http://www.example.com/blocklist",
"cache-size-mb": 4,
"dht-enabled": true,
"download-dir": "/var/transmission/downloads",
"download-queue-enabled": true,
"download-queue-size": 5,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/dev/null/Downloads",
"incomplete-dir-enabled": false,
"lpd-enabled": false,
"message-level": 2,
"peer-congestion-algorithm": "",
"peer-limit-global": 240,
"peer-limit-per-torrent": 60,
"peer-port": 51413,
"peer-port-random-high": 65535,
"peer-port-random-low": 49152,
"peer-port-random-on-start": false,
"peer-socket-tos": "default",
"pex-enabled": true,
"pidfile": "/var/run/transmission/transmission.pid",
"port-forwarding-enabled": true,
"preallocation": 1,
"prefetch-enabled": 1,
"queue-stalled-enabled": true,
"queue-stalled-minutes": 30,
"ratio-limit": 2,
"ratio-limit-enabled": false,
"rename-partial-files": true,
"rpc-authentication-required": false,
"rpc-bind-address": "0.0.0.0",
"rpc-enabled": true,
"rpc-password": "{c7f2b768a4d304a50bd82de26779313ac2a1579dmVqsXwn2",
"rpc-port": 9091,
"rpc-url": "/transmission/",
"rpc-username": "",
"rpc-whitelist": "127.0.0.1",
"rpc-whitelist-enabled": false,
"scrape-paused-torrents-enabled": true,
"script-torrent-done-enabled": false,
"script-torrent-done-filename": "",
"seed-queue-enabled": false,
"seed-queue-size": 10,
"speed-limit-down": 100,
"speed-limit-down-enabled": false,
"speed-limit-up": 100,
"speed-limit-up-enabled": false,
"start-added-torrents": true,
"trash-original-torrent-files": false,
"umask": 18,
"upload-slots-per-torrent": 14,
"utp-enabled": true
}
改完这个后,transmission可以正常访问了。我终于有了常开树莓派的理由了。
2013年5月17日
前些日子配置了btsync,过程见另文。
出现死机的频率还是比较多的。
还是要配置看门狗的。
在/etc/conf.d/modules中加入bcm2708_wdog这个模块。
# emerge watchdog
# cat /etc/watchdog.conf|grep '^[^#;]'
ping = 192.168.1.11
interface = eth0
file = /var/log/messages
change = 1407
max-load-1 = 24
watchdog-device = /dev/watchdog
temperature-device = /sys/class/thermal/thermal_zone0/temp
max-temperature = 80000
realtime = yes
priority = 1
# /etc/init.d/watchdog start
* Caching service dependencies ... [ ok ]
* Starting watchdog ... [ ok ]
GentooPi lq # rc-update add watchdog default
* service watchdog added to runlevel default
2013年5月19日
watchdog中的ping参数会造成pi的频繁重启,去掉之。
更改为:
$ cat /etc/watchdog.conf|grep '^[^#;]'
file = /var/log/messages
max-load-1 = 24
watchdog-device = /dev/watchdog
temperature-device = /sys/class/thermal/thermal_zone0/temp
max-temperature = 80000
realtime = yes
priority = 1
2013年7月28日
#emerge mldonkey
#cat /etc/conf.d/mldonkey
# /etc/conf.d/mldonkey
# Config file for mldonkey control script
# Change the following vars only if you know
# what you're doing, there's no checking for
# invalid data yet!
# owner of mlnet process (don't change, must be existing)
#USER="p2p"
USER="samba"
# mldonkey's working dir (must be existing)
MLDONKEY_DIR="/home/samba/downloads"
# logfile (/dev/null for nowhere)
LOG="/var/log/mldonkey.log"
# set to true, if you have enabled logging to syslog in MLDonkey with
# set log_to_syslog true
USE_LOGGER=true
# bandwidth control, values in kb/s
LOW_DOWN="6"
LOW_UP="2"
HIGH_DOWN="30"
HIGH_UP="10"
# nice level, 0<x<19, more nice -> less cpuspeed consumed
NICE="19"
# mldonkey server ip, usually localhost
#SERVER="192.168.1.11"
SERVER="loclahost"
# port for webinterface, usually 4080
PORT="4080"
修改download.ini.
allowed_ips = [
"127.0.0.1";
"192.168.1.0/24";]
Comments(0)