Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?


More than 3 years have passed since last update.



  • Raspberry Pi 3
  • 2016-05-27-raspbian-jessie-lite.img
  • USBストレージ(USBのSDカードリーダにmicroSD..意味あるのか?!)


ファームウェアの更新・設定 (microSDにて)

  • まずは通常通りに、microSDに、Raspbianを書き込んで作業はじめる
# APTレポジトリデータベース更新.
sudo apt-get update
# Raspbian liteでは、rpi-updateをインストール.
sudo apt-get install rpi-update -y
# 'next'ブランチから、ファームウェア等々、更新.
sudo BRANCH=next rpi-update
# 今回使用したもの
# > *** If no errors appeared, your firmware was successfully updated to 193f081a0ed502b62483aa707a79cf245db9b028
# USBブートモードを有効に.
echo program_usb_boot_mode=1 | sudo tee -a /boot/config.txt
# 現在の otpの値を確認.
vcgencmd otp_dump | grep 17:
# > 17:1020000a
# 再起動
sudo reboot
# otpの値を確認
vcgencmd otp_dump | grep 17:
# > 17:3020000a となっていればOK


  1. USBストレージをらずぱいに挿す ( => /dev/sda になるはず)

    pi@raspberrypi:~ $ ls -l /dev/sda
    ls: cannot access /dev/sda: No such file or directory
    pi@raspberrypi:~ $ ls -l /dev/sda
    brw------- 1 root root 8, 0 Aug  4 19:57 /dev/sda
    pi@raspberrypi:~ $ 
  2. sudo parted /dev/sda

    mktable msdos
    mkpart primary fat32 0% 100M
    mkpart primary ext4 100M 100%
  3. パーティションフォーマット(mkfs)

    sudo mkfs.vfat -n BOOT -F 32 /dev/sda1
    sudo mkfs.ext4 /dev/sda2
  4. 実行例

    pi@raspberrypi:~ $ sudo parted /dev/sda
    GNU Parted 3.2
    Using /dev/sda
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) mktable msdos                                                    
    Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
    Yes/No? Yes                                                               
    (parted) mkpart primary fat32 0% 100M                                     
    (parted) mkpart primary ext4 100M 100%                                    
    (parted) print                                                            
    Model: Generic STORAGE DEVICE (scsi)
    Disk /dev/sda: 3905MB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags: 
    Number  Start   End     Size    Type     File system  Flags
     1      1049kB  99.6MB  98.6MB  primary  fat32        lba
     2      99.6MB  3905MB  3805MB  primary  ext4         lba
    (parted) quit                                                             
    Information: You may need to update /etc/fstab.
    pi@raspberrypi:~ $ sudo mkfs.vfat -n BOOT -F 32 /dev/sda1       
    mkfs.fat 3.0.27 (2014-11-12)
    pi@raspberrypi:~ $ sudo mkfs.ext4 /dev/sda2
    mke2fs 1.42.12 (29-Aug-2014)
    Creating filesystem with 929024 4k blocks and 232464 inodes
    Filesystem UUID: 2cf0a8cc-917b-4bb5-9e37-982695d7c4e6
    Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (16384 blocks): done
    Writing superblocks and filesystem accounting information: done 
    pi@raspberrypi:~ $ 
  5. 今使ってるRaspbianのシステムをUSBへコピー

    sudo mkdir /mnt/target
    sudo mount /dev/sda2 /mnt/target/
    sudo mkdir /mnt/target/boot
    sudo mount /dev/sda1 /mnt/target/boot/
    sudo apt-get update; sudo apt-get install rsync
    sudo rsync -ax --progress / /boot /mnt/target
    # Raspbian Liteにて。
    real    6m57.916s
    user    0m23.290s
    sys 0m26.180s
  6. sshホストキーの再生成

    cd /mnt/target
    sudo mount --bind /dev dev
    sudo mount --bind /sys sys
    sudo mount --bind /proc proc
    sudo chroot /mnt/target
    rm /etc/ssh/ssh_host*
    dpkg-reconfigure openssh-server
    sudo umount dev
    sudo umount sys
    sudo umount proc
  7. /boot/cmdline.txt/etc/fstabの編集

    • mmcblk0p => sda みたいにする
    sudo sed -i "s,root=/dev/mmcblk0p2,root=/dev/sda2," /mnt/target/boot/cmdline.txt
    sudo sed -i "s,/dev/mmcblk0p,/dev/sda," /mnt/target/etc/fstab
  8. ファイルシステムのアンマウントして、らずぱい電源オフ. (ちゃんとオフになるのを待つように)

    cd ~
    sudo umount /mnt/target/boot 
    sudo umount /mnt/target
    sudo poweroff 
  9. USBストレージで起動

    • 電源を抜いて、
    • SDカードを抜いて、
    • 電源をさす。
    • => すべてがうまく行っている場合は、Piが数秒後に起動を開始するはずだ。


Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away