Raspberry Pi Model B+にArch Linux ARM(カーネル3.12.26-1-ARCH)をインストール
Raspberry Pi Type B+買いました
連休に入りました。
連休に入って、こっそりシコシコとアレをナニしてるわけなんですが、進捗ダメですと思われないために、ここらで進捗出しておこうかと…。
Raspberry Pi Type B+買いました。
旧TypeBとの違いは、そこら中で取り上げられているのですが、あまり知られていなく、ものすごく地味にムカつく違いだけ、ちょっと紹介しておきます。
穴
Type Bの場合、M3ネジが通るので、PC自作er御用達なマザボに使うネジ類が使えたわけで、Type B+の場合、何故かM3ネジが通らず、恐らく、M2.6になっている。なんでそんな微妙なサイズにしたのか…。
結局、穴をヤスリで広げてM3ネジ通すようにしたんだけど、M3ネジを止めてみると、microUSBコネクタと干渉したり、チップ抵抗に接触したりと、割と地味にファッキンな仕様になっていました。
まぁそれはさておき、、これを機に、Archをインストールすることになって、Arch ARMを覗くと、またセットアップ方法が変わってたので、自分の防備録として、残しておきたいと思った。
毎回恒例、公式リンク。一番確実なので、以下を参考に。(日本語ページは若干古いので注意)
http://archlinuxarm.org/platforms/armv6/raspberry-pi
https://wiki.archlinux.org/index.php/Raspberry_Pi
前提環境
マシン: Macbook Air 2011 Mid
OS: Arch Linux(3.15.7-1-ARCH)
SDカードの作成(PC側)
作業用ディレクトリ作成
$ mkdir raspberrypi $ cd raspberrypi $ mkdir boot $ mkdir root
最新のArchARMを取得
$ wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.tar.gz
SDカードの場所を確認
$ lsblk
SDカードの準備(以降rootユーザ) bootパーティションは100MBのFAT32形式、rootパーティションは残り容量でLinux File System形式でパーティションを作成。
$ su # fdisk /dev/sdc Welcome to fdisk (util-linux 2.24.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d Selected partition 1 Partition 1 has been deleted. Command (m for help): p Disk /dev/sdc: 29.2 GiB, 31322013696 bytes, 61175808 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x9686be27 Command (m for help): o Created a new DOS disklabel with disk identifier 0x07befaf8. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-61175807, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-61175807, default 61175807): +100M Created a new partition 1 of type 'Linux' and of size 100 MiB. Command (m for help): t Selected partition 1 Hex code (type L to list all codes): c If you have created or modified any DOS 6.x partitions, please see the fdisk documentation for additional information. Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'. Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): Using default response p. Partition number (2-4, default 2): First sector (206848-61175807, default 206848): Last sector, +sectors or +size{K,M,G,T,P} (206848-61175807, default 61175807): Created a new partition 2 of type 'Linux' and of size 29.1 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
SDカードのフォーマット bootパーティションは、FAT形式で、rootパーティションは、F2FSでフォーマットした。 ※ mkfs.f2fsは pacman -S f2fs-toolsでインストールすることで使えるようになる。
# mkfs.vfat /dev/sdc1 # mkfs.f2fs /dev/sdc2
SDカードをマウントし、ダウンロードしたArchARMをマウント先に展開
# mount /dev/sdc1 boot # mount /dev/sdc2 root # tar -xf ArchLinuxARM-rpi-latest.tar.gz -C root # sync # mv root/boot/* boot
rootfstypeをF2FSに変更し、Raspberry Piからrootパーティションを読み込めるようにする
# vi boot/cmdline.txt 変更前 elinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=noop rootwait 変更後 elinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=f2fs elevator=noop rootwait
SDカードをマウント解除
# umount boot root
作成したSDカードをRaspberry Piに挿し、電源を入れ、Raspberry PiにSSHでログイン
$ ssh root@192.168.0.6 password: root
rootパスワードを変更
# passwd
なぜか、デフォルトのGeo-IPのミラーが繋がらなかったので、USミラーを選択した
# vi /etc/pacman.d/mirrorlist
毎回恒例
# rm /etc/localtime # ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime # echo [hostname] > /etc/hostname # vi /etc/hosts
ネットワーク接続を、有線LANで、静的IPを設定
# cd /etc/netctl # cp examples/ethernet-static my_network
# vi my_network Description='A basic static ethernet connection' Interface=eth0 Connection=ethernet IP=static Address=('192.168.0.11/24'') #Routes=('192.168.0.0/24 via 192.168.1.2') Gateway='192.168.0.1' DNS=('192.168.0.1') ## For IPv6 autoconfiguration #IP6=stateless ## For IPv6 static address configuration #IP6=static #Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96') #Routes6=('abcd::1234') #Gateway6='1234:0:123::abcd'
※後から分かったことで、本バージョンから、デフォルトのDHCP接続が、netctl-ifplud@eth0.serviceではなくなっている様子。どこで設定してあるか後で調べて切っておく。
# systemctl disable netctl-ifplugd@eth0.service # systemctl enable netctl-ifplugd@my_network.service # netctl enable my_network
設定ミスってて、後から繋がらないってなると泣きそうになるので、一旦ここで再起動
# reboot
設定したIPで、再度接続
$ ssh root@192.168.0.11
Raspberry Pi用に、パッケージを最新化し、必要なパッケージをインストール。
※ここは、任意。とりあえずデスクトップな環境であれば、以下の通り。
# pacman -Syu # pacman -S sudo alsa-utils alsa-firmware alsa-lib alsa-plugins xf86-video-fbdev xf86-input-synaptics raspberrypi-firmware raspberrypi-firmware-tools git
ユーザを作成
# useradd -m -g users -G wheel -s /bin/bash morinezumiiii # passwd morinezumiiii # gpasswd -a morinezumiiii audio # gpasswd -a morinezumiiii video # gpasswd -a morinezumiiii uucp # gpasswd -a morinezumiiii tty
sudoerファイルを編集
# visudo
以降、通常ユーザで。
# exit
$ ssh morinezumiiii@192.168.0.11
Raspberry Piなアプリケーション(raspividとか)のPATHを通す
$ vi ~/.bash_profile export PATH=$PATH:/opt/vc/bin $ source ~/.bash_profile $ vcgencmd version Jul 23 2014 21:12:29 Copyright (c) 2012 Broadcom version 174cdd77563b98023955a94cb8d072d9c7095d6f (clean) (release)
ちなみに、ここ2ヶ月くらいで、ラズパイに使ったSDカード3枚くらいぶっとびました。
そもそも書き込み回数1万回程度って書いてあるSDカードにOS入れて動かすって事自体が、「んー…」な感じなんだけど、とりあえず、ファイルシステムをExt4からF2FSに、スワップ領域を無くし、ログ書き込み先をtmpfsにすることで、ほんの少しでも、延命できるかなと、淡い期待を抱いてる。
ゆくゆくは、ちゃんとramfsにするなり、ストレージは別で用意するなりしたいなぁと思う。
以上、お疲れ様でした。
$ exit