a. 從官方網站下載 - http://www.raspberrypi.org/downloads
b. 從我的映像站下載
2. 解開 2013-02-09-wheezy-raspbian.zip
unzip 2013-02-09-wheezy-raspbian.zip
此時會解開出一個 2013-02-09-wheezy-raspbian.img 的影像檔,我們可以使用之前所介紹掛載 sdcard.img 的方式來掛載此檔以觀察其內容。
3. 掛載 2013-02-09-wheezy-raspbian.img 檔案
a. 請先切換至 root 權限 (su)
b. # losetup /dev/loop0 2013-02-09-wheezy-raspbian.img
此指令是將 2013-02-09-wheezy-raspbian.img "連接" 至 /dev/loop0 這個裝置
# losetup -a -> 觀察連接的結果,其輸出如下:
/dev/loop0: [0805]:999425 (/home/herman/raspberry/2013-02-09-wheezy-raspbian.img)
我們可以得知 /dev/loop0 已經跟 2013-02-09-wheezy-raspbian.img 連接在一起。接著我們可以執行 fdisk -lu 來觀察 /dev/loop0 這個裝置,請執行底下指令:
# fdisk -lu /dev/loop0
其輸出如下:
Disk /dev/loop0: 1939 MB, 1939865600 bytes
255 heads, 63 sectors/track, 235 cylinders, total 3788800 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: 0x00017b69
Device Boot Start End Blocks Id System
/dev/loop0p1 8192 122879 57344 c W95 FAT32 (LBA)
Partition 1 does not end on cylinder boundary.
/dev/loop0p2 122880 3788799 1832960 83 Linux
Partition 2 does not end on cylinder boundary.
c. 將 2013-02-09-wheezy-raspbian.img 的第一分割區"連接"至 /dev/loop1,其指令如下:
losetup -o `expr 8192 \* 512` /dev/loop1 /dev/loop0
我們可以執行 losetup -a 來觀察連接結果,其輸出如下:
/dev/loop0: [0805]:999425 (/home/herman/raspberry/2013-02-09-wheezy-raspbian.img)
/dev/loop1: [0005]:1312 (/dev/loop0), offset 4194304
接著將 2013-02-09-wheezy-raspbian.img 的第二分割區"連接"至 /dev/loop2,其指令如下:
losetup -o `expr 122880 \* 512` /dev/loop2 /dev/loop0
我們可以執行 losetup -a 來觀察連接結果,其輸出如下:
/dev/loop0: [0805]:999425 (/home/herman/raspberry/2013-02-09-wheezy-raspbian.img)
/dev/loop1: [0005]:1312 (/dev/loop0), offset 4194304
/dev/loop2: [0005]:1312 (/dev/loop0), offset 62914560
這表示 /dev/loop1 及 /dev/loop2 都連接至正確的分割區,接著就可以進行掛載。
d. 將 /dev/loop1 掛載至 /mnt/sdcard1 目錄
# mount /dev/loop1 /mnt/sdcard1
將 /dev/loop2 掛載至 /mnt/sdcard2 目錄
# mount /dev/loop2 /mnt/sdcard2
若無 /mnt/sdcard1 /mnt/sdcard2 目錄的話,請先執行底下建立:
# mkdir -p /mnt/sdcard1 /mnt/sdcard2
掛載完後請執行 df -h 來觀察是否已掛載成功,其輸出如下:
檔案系統 Size Used Avail Use% 掛載點
/dev/loop1 56M 17M 40M 30% /mnt/sdcard1
/dev/loop2 1.8G 1.4G 315M 82% /mnt/sdcard2
e. 切換至 /mnt/sdcard1 /mnt/sdcard2 目錄來觀察其內容。
cd /mnt/sdcard1
ls -l
我們可以看到此分割區為 bootloader 及 kernel 之目錄,其輸出如下:
-rwxr-xr-x 1 root root 17764 2012-10-29 01:40 bootcode.bin
-rwxr-xr-x 1 root root 142 2012-12-16 01:43 cmdline.txt
-rwxr-xr-x 1 root root 1180 2012-12-16 01:43 config.txt
-rwxr-xr-x 1 root root 2020 2012-10-29 01:40 fixup_cd.dat
-rwxr-xr-x 1 root root 5282 2012-10-29 01:40 fixup.dat
-rwxr-xr-x 1 root root 137 2012-12-17 03:51 issue.txt
-rwxr-xr-x 1 root root 2104952 2012-10-29 01:40 kernel_cutdown.img
-rwxr-xr-x 1 root root 9522048 2012-10-29 01:40 kernel_emergency.img
-rwxr-xr-x 1 root root 2695192 2012-10-29 01:40 kernel.img
-rwxr-xr-x 1 root root 523144 2012-10-29 01:40 start_cd.elf
-rwxr-xr-x 1 root root 2347828 2012-10-29 01:40 start.elf
cd /mnt/sdcard2
ls -l
我們可以看到此分割區為 rootfs 之目錄,其輸出如下:
drwxr-xr-x 2 root root 4096 2012-12-16 02:16 bin
drwxr-xr-x 2 root root 4096 2012-12-16 01:43 boot
drwxr-xr-x 3 root root 4096 2012-12-16 02:16 dev
drwxr-xr-x 95 root root 4096 2012-12-17 03:39 etc
drwxr-xr-x 3 root root 4096 2012-12-17 03:39 home
drwxr-xr-x 12 root root 4096 2012-12-16 02:05 lib
drwx------ 2 root root 16384 2012-12-16 01:28 lost+found
drwxr-xr-x 2 root root 4096 2012-12-16 01:31 media
drwxr-xr-x 2 root root 4096 2012-09-03 01:08 mnt
drwxr-xr-x 3 root root 4096 2012-12-16 01:42 opt
drwxr-xr-x 2 root root 4096 2012-09-03 01:08 proc
drwx------ 2 root root 4096 2012-12-16 01:31 root
drwxr-xr-x 7 root root 4096 2012-12-17 03:37 run
drwxr-xr-x 2 root root 4096 2012-12-16 02:16 sbin
drwxr-xr-x 2 root root 4096 2012-06-20 17:23 selinux
drwxr-xr-x 2 root root 4096 2012-12-16 01:31 srv
drwxr-xr-x 2 root root 4096 2012-11-27 17:13 sys
drwxrwxrwt 2 root root 4096 2012-09-03 01:08 tmp
drwxr-xr-x 10 root root 4096 2012-12-16 01:31 usr
drwxr-xr-x 11 root root 4096 2012-12-16 01:31 var
4. 解除掛載
a. 解除掛載 目錄
# umount /mnt/sdcard1
# umount /mnt/sdcard2
使用 df -h 來觀察是否已解除掛載
b. 解除 loop 連接
# losetup -d /dev/loop2
# losetup -d /dev/loop1
# losetup -d /dev/loop0
使用 losetup -a 來觀察是否已解除連接
** 將 2013-02-09-wheezy-raspbian.img 下載至 sdcard **
1. 首先將 SD card 放入讀卡機,並接上電腦,然後執行 dmesg 觀察最後面輸出之
SD card 的代號,例如:
[11237833.478264] sd 4:0:0:0: [sdb] 7673856 512-byte logical blocks: (3.92 GB/3.65 GiB)
[11237833.478885] sd 4:0:0:1: [sdc] Attached SCSI removable disk
[11237833.479635] sd 4:0:0:2: [sdd] Attached SCSI removable disk
[11237833.480265] sd 4:0:0:3: [sde] Attached SCSI removable disk
[11237833.481313] sd 4:0:0:0: [sdb] Write Protect is off
[11237833.481317] sd 4:0:0:0: [sdb] Mode Sense: 03 00 00 00
[11237833.482161] sd 4:0:0:0: [sdb] No Caching mode page present
[11237833.482165] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[11237833.486012] sd 4:0:0:0: [sdb] No Caching mode page present
[11237833.486017] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[11237833.488435] sdb: sdb1 sdb2
[11237833.491524] sd 4:0:0:0: [sdb] No Caching mode page present
[11237833.491529] sd 4:0:0:0: [sdb] Assuming drive cache: write through
[11237833.491533] sd 4:0:0:0: [sdb] Attached SCSI removable disk
從上面訊息我們可以得知 SD card 是 /dev/sdb 這個裝置,其容量為 3.92 GB = 4 GB
2. 將 2013-02-09-wheezy-raspbian.img 植入 SD card
請先切換至 root 權限,再執行:
# dd if=2013-02-09-wheezy-raspbian.img of=/dev/sdb bs=1024k
經過 N 分鐘後會完成植入流程,N 自 5 ~ 8 不等,看記憶卡的速度。執行完畢後之輸出如下:
1850+0 records in
1850+0 records out
1939865600 bytes (1.9 GB) copied, 656.276 s, 3.0 MB/s
3. 掛載實體 SD card
# mount /dev/sdb1 /mnt/sdcard1
# mount /dev/sdb2 /mnt/sdcard2
使用 df -h 來觀察其輸出,如下所示:
檔案系統 Size Used Avail Use% 掛載點
/dev/sdb1 56M 17M 40M 30% /mnt/sdcard1
/dev/sdb2 1.8G 1.4G 315M 82% /mnt/sdcard2
4. 觀察 SD card
cd /mnt/sdcard1 目錄觀察
cd /mnt/sdcard2 目錄觀察
5. 修改開機參數
cd /mnt/sdcard1
vi config.txt
將
#hdmi_safe=1 改為
hdmi_safe=1
接著我們就可以拿 SD card 至 raspberry pi 板子上開機。
沒有留言:
張貼留言