Raspberry Pi 2 Model B に Raspbian を入れるのにえらい手間取った

Raspberry Pi 2 が普通に入手できるようになっていたので入手。
使う SD カードは Transcend microSDXCカード 64GB Class10 UHS-I対応 TS64GUSDU1E を選んだんだけど
これが意外なほど手間取った。


Linux では parted を使うのがオススメ!とか書いてあったんだけどいろいろやってみたけど
NOOBS の画面が起動しなかったり、上手く出てもその後 SD への書き込みがエラーっぽくなったりして
64 GB とか選ばなければよかったのかもと諦めかけた。


とりあえず途中に一度、MBR がないよと言われて NOOBS に MBR を作ってもらって再度転送というステップがはさまるものの、以下のような流れで無事に Raspbian 起動までいけた。


// SD カードのデバイスファイルを確認
takel@hatenadiary ~ $ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 60.1G 0 disk
└─mmcblk0p1 179:1 0 60G 0 part

// fdisk でパーティーションをきる
takel@hatenadiary ~ $ sudo fdisk /dev/mmcblk0

Command (m for help): p

Disk /dev/mmcblk0: 64.5 GB, 64490569728 bytes
255 heads, 63 sectors/track, 7840 cylinders, total 125958144 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/mmcblk0p1 32768 125958143 62962688 7 HPFS/NTFS/exFAT

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/mmcblk0: 64.5 GB, 64490569728 bytes
255 heads, 63 sectors/track, 7840 cylinders, total 125958144 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

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): 1
First sector (2048-125958143, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-125958143, default 125958143): 15278079

Command (m for help): p

Disk /dev/mmcblk0: 64.5 GB, 64490569728 bytes
255 heads, 63 sectors/track, 7840 cylinders, total 125958144 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/mmcblk0p1 2048 15278079 7638016 83 Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): p

Disk /dev/mmcblk0: 64.5 GB, 64490569728 bytes
255 heads, 63 sectors/track, 7840 cylinders, total 125958144 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/mmcblk0p1 2048 15278079 7638016 c W95 FAT32 (LBA)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

// FAT でフォーマットする
takel@hatenadiary ~ $ sudo mkfs.vfat /dev/mmcblk0
mkfs.fat 3.0.26 (2014-03-07)

// NOOBS を展開する
takel@hatenadiary ~ $ unzip /home/takel/Downloads/NOOBS_v1_4_1.zip -d /media/takel/6644-FE53
Archive: /home/takel/Downloads/NOOBS_v1_4_1.zip
(省略)

// ここで Raspberry pi 2 に SD を挿入して NOOBS を起動。
// MBR がないから作るかと聞かれたので作ってもらう。
// SD の中身が空になったので NOOOBS を転送しなおすようにと言われたのでそのようにする。


// 念のためどうなってるか見てみるが、
// もう仕切り直されてて FAT32 なのに 64GB 確保してるみたいな謎な状態
takel@hatenadiary ~ $ sudo fdisk /dev/mmcblk0
Command (m for help): p

Disk /dev/mmcblk0: 64.5 GB, 64490569728 bytes
255 heads, 63 sectors/track, 7840 cylinders, total 125958144 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: 0x000415d0

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 125958143 62974976 c W95 FAT32 (LBA)

Command (m for help): q

// 入れ直す
takel@hatenadiary ~ $ unzip /home/takel/Downloads/NOOBS_v1_4_1.zip -d /media/takel/5859-BC57/
Archive: /home/takel/Downloads/NOOBS_v1_4_1.zip
(省略)

// これで無事に NOOBS 起動して Raspbian がインストールできた。


いろいろ試してた時にクラスタサイズを 32K にするんだとか、
ヴォリュームラベルを boot にするんだとか、
boot フラグを立てるんだとかもろもろ書いてあったけどどれもダメだった。

とりあえず上記の方法で上手く行っちゃったけど
$ sudo lilo -M /dev/mmcblk0 mbr
MBR も書けたかもしれない(試してない)