8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[更新中] #RaspberryPi に #Gentoo Linuxをセットアップする

Last updated at Posted at 2014-05-12

参考

セットアップ

SDカードにパーティションを切る

今回は16GBのSDHCカードを使用した(Amazonで売ってるこれ)

GreenLeft / # fdisk -l /dev/sdb

Disk /dev/sdb: 15.8 GB, 15811477504 bytes, 30881792 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
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048       67583       32768    c  W95 FAT32 (LBA)
/dev/sdb2           67584    14747647     7340032   83  Linux
/dev/sdb3        14747648    15796223      524288   82  Linux swap / Solaris
/dev/sdb4        15796224    30881791     7542784    c  W95 FAT32 (LBA)
GreenLeft / # mkfs.vfat -F 16 /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)
GreenLeft / # mkfs.ext4 /dev/sdb2
mke2fs 1.42.7 (21-Jan-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
458752 inodes, 1835008 blocks
91750 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1879048192
56 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

GreenLeft / # mkswap /dev/sdb3
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=143d8bce-e8e0-46cb-8256-a1d3f5b78eb9
GreenLeft / # mkfs.vfat -F 32 /dev/sdb4
mkfs.fat 3.0.26 (2014-03-07)

Macからマウントされたときに分かりやすいよう、VFATなパーティションにはラベルを付ける

GreenLeft / # emerge -pv mtools

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-fs/mtools-4.0.15  USE="-X" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB
GreenLeft / # mlabel -i /dev/sdb1 ::RPI-BOOT
GreenLeft / # mlabel -i /dev/sdb4 ::RPI-MEDIA
GreenLeft / # mlabel -s -i /dev/sdb1 ::
 Volume label is RPI-BOOT   
GreenLeft / # mlabel -s -i /dev/sdb4 ::
 Volume label is RPI-MEDIA  
GreenLeft / # mount /dev/sdb2 /mnt/gentoo/
GreenLeft / # cd /mnt/gentoo
GreenLeft gentoo # mkdir -p boot media
GreenLeft gentoo # mount /dev/sdb1 boot/
GreenLeft gentoo # mount /dev/sdb4 media/
GreenLeft / # cd /
GreenLeft / # curl -LO -s ftp://ftp.iij.ad.jp/pub/linux/gentoo/releases/arm/autobuilds/current-stage3-armv6j_hardfp/stage3-armv6j_hardfp-20140113.tar.bz2.DIGESTS
GreenLeft / # curl -LO -s ftp://ftp.iij.ad.jp/pub/linux/gentoo/releases/arm/autobuilds/current-stage3-armv6j_hardfp/stage3-armv6j_hardfp-20140113.tar.bz2
GreenLeft / # curl -LO -s ftp://ftp.iij.ad.jp/pub/linux/gentoo/releases/arm/autobuilds/current-stage3-armv6j_hardfp/stage3-armv6j_hardfp-20140113.tar.bz2.CONTENTS
GreenLeft / # sha1sum --check stage3-armv6j_hardfp-20140113.tar.bz2.DIGESTS
stage3-armv6j_hardfp-20140113.tar.bz2: OK
stage3-armv6j_hardfp-20140113.tar.bz2.CONTENTS: OK
sha1sum: WARNING: 6 lines are improperly formatted
GreenLeft / # curl -LO -s ftp://ftp.iij.ad.jp/pub/linux/gentoo/snapshots/portage-latest.tar.xz.md5sum
GreenLeft / # curl -LO -s ftp://ftp.iij.ad.jp/pub/linux/gentoo/snapshots/portage-latest.tar.xz
GreenLeft / # md5sum portage-latest.tar.xz.md5sum
ac9e1b3f7698b064c4bb82fb61610172  portage-latest.tar.xz.md5sum
GreenLeft / # md5sum --check portage-latest.tar.xz.md5sum
portage-latest.tar.xz: OK
GreenLeft gentoo # cd /mnt/gentoo
GreenLeft gentoo # tar xfp /stage3-armv6j_hardfp-20140113.tar.bz2
GreenLeft gentoo # tar xf /portage-latest.tar.xz -C usr/
GreenLeft src # pwd
/usr/src
GreenLeft src # git clone --depth=1 git://github.com/raspberrypi/firmware.git raspberrypi-firmware
Cloning into 'raspberrypi-firmware'...
remote: Counting objects: 1910, done.
remote: Compressing objects: 100% (1473/1473), done.
remote: Total 1910 (delta 358), reused 1702 (delta 302)
Receiving objects: 100% (1910/1910), 50.56 MiB | 2.86 MiB/s, done.
Resolving deltas: 100% (358/358), done.
Checking connectivity... done
GreenLeft gentoo # pwd
/mnt/gentoo
GreenLeft gentoo # cp -Rp /usr/src/raspberrypi-firmware/boot/ .
GreenLeft gentoo # cp -Rp /usr/src/raspberrypi-firmware/modules/ lib/
GreenLeft gentoo # cat boot/cmdline.txt
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
GreenLeft gentoo # cat boot/config.txt
arm_freq=900
core_freq=333
sdram_freq=450
over_voltage=2
framebuffer_depth=24
hdmi_drive=2
GreenLeft gentoo # grep -E '^root' etc/passwd
root::0:0:root:/root:/bin/bash
GreenLeft gentoo # grep -Ev '^\s*($|#)' etc/fstab
/dev/mmcblk0p1          /boot           auto            defaults        1 2
/dev/mmcblk0p2          /               ext4            defaults        0 1
/dev/mmcblk0p3          none            swap            sw              0 0
/dev/mmcblk0p4          /media          auto            defaults        0 1
localhost ~ # passwd
New password: 
Retype new password: 
passwd: password updated successfully
localhost ~ # cd /etc/init.d/
localhost init.d # ln -fs net.lo net.eth0 
localhost init.d # /etc/init.d/net.eth0 start
 * Bringing up interface eth0
 *   Caching network module dependencies
need firewalld
 *   No configuration specified; defaulting to DHCP
 *   dhcp ...
 *     Running udhcpc …                                            [ ok ]
 *     received address 172.x.y.z/16                               [ ok ]
localhost ~ # /etc/init.d/sshd start
ssh-keygen: generating new host keys: RSA1 RSA DSA
 * Starting sshd …                                                 [ ok ]
localhost ~ # locale-gen 
 * Generating 2 locales (this might take a while) with 1 jobs
 *  (1/2) Generating en_US.UTF-8 ... [ ok ]
 *  (2/2) Generating ja_JP.UTF-8 ... [ ok ]
 * Generation complete
localhost ~ # cat /etc/env.d/02locale 
LC_ALL=C
LANG=C
localhost ~ # env-update 
>>> Regenerating /etc/ld.so.cache...

Wi-Fi

これを使う

[mazgi@Ardbeg] $ ssh -lroot 172.30.255.19 'mkdir -p /lib/firmware'
[mazgi@Ardbeg] $ scp ~/Downloads/RT2870_Firmware_V22/rt2870.bin root@172.30.255.19:/lib/firmware/
rt2870.bin                                 100% 8192     8.0KB/s   00:00    
localhost ~ # /etc/init.d/swclock start
 * Setting the local clock based on last shutdown time ...         [ ok ]
localhost ~ # rc-update del hwclock boot
 * service hwclock removed from runlevel boot
localhost ~ # rc-update add swclock boot
 * service swclock added to runlevel boot
localhost ~ # grep -E '^#*s[0-9]+:' /etc/inittab
# s0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt100
# s1:12345:respawn:/sbin/agetty -L 9600 ttyS1 vt100
8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?