raspberry_pi_3_boot_to_usb
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
raspberry_pi_3_boot_to_usb [2016/12/14 16:20] – created walkeradmin | raspberry_pi_3_boot_to_usb [2023/03/09 22:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
\\ | \\ | ||
This is taken from the following URL: [[https:// | This is taken from the following URL: [[https:// | ||
- | \\ | + | \\ <color red></ |
\\ | \\ | ||
I have documented it here as I use this guide a lot, and I don't want to lose it :) | I have documented it here as I use this guide a lot, and I don't want to lose it :) | ||
+ | \\ | ||
+ | \\ | ||
+ | This tutorial explains how to boot your Raspberry Pi 3 from a USB mass storage device such as a | ||
+ | flash drive or USB hard disk. Be warned that this feature is experimental and may not work with | ||
+ | all USB mass storage devices. | ||
+ | | ||
+ | <color red>USB Hard Drives seem particularly fussy.</ | ||
+ | \\ | ||
+ | ===== Program USB Boot Mode ===== | ||
+ | \\ | ||
+ | Before a Pi will network boot, it needs to be booted with a config option to enable USB boot mode. | ||
+ | Enabling this config option requires special <color red> | ||
+ | \\ | ||
+ | \\ | ||
+ | Go to the [[https:// | ||
+ | \\ | ||
+ | \\ | ||
+ | First, prepare the /boot directory with experimental boot files | ||
+ | \\ | ||
+ | < | ||
+ | If on raspbian lite you need to install rpi-update before you can use it: | ||
+ | |||
+ | sudo apt-get update; sudo apt-get install rpi-update | ||
+ | sudo BRANCH=next rpi-update | ||
+ | </ | ||
+ | \\ | ||
+ | Then enable USB boot mode with this code: | ||
+ | \\ | ||
+ | echo program_usb_boot_mode=1 | sudo tee -a / | ||
+ | \\ | ||
+ | This adds program_usb_boot_mode=1 to the end of / | ||
+ | Reboot the Pi with sudo reboot, then check that the OTP has been programmed with: | ||
+ | \\ | ||
+ | \\ | ||
+ | vcgencmd otp_dump | grep 17: | ||
+ | 17:3020000a | ||
+ | \\ | ||
+ | Ensure the output <color red> | ||
+ | \\ | ||
+ | \\ | ||
+ | If you wish, you can remove the <color red> | ||
+ | \\ | ||
+ | \\ | ||
+ | <color red>NOTE - If you use the SAME boot SD Card each time to make a bootable disk, you only need to perform the steps above ONCE</ | ||
+ | \\ | ||
+ | \\ | ||
+ | ==== Prepare the USB storage device | ||
+ | \\ | ||
+ | Now that your Pi is USB boot-enabled, | ||
+ | Start by inserting the USB storage device (which will be completely erased) into the Pi.\\ | ||
+ | Rather than downloading the Raspbian image again, we will copy it from the SD card on the Pi.\\ | ||
+ | The source device (sd card) will be <color red>/ | ||
+ | should be <color red>/ | ||
+ | \\ | ||
+ | \\ | ||
+ | We will start by using Parted to create a 100MB FAT32 partition, followed by a Linux ext4 partition that will take up the rest of the disk. | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | sudo parted /dev/sda | ||
+ | |||
+ | (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: SanDisk Ultra (scsi) | ||
+ | Disk /dev/sda: 30.8GB | ||
+ | Sector size (logical/ | ||
+ | Partition Table: msdos | ||
+ | Disk Flags: | ||
+ | |||
+ | Number | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | \\ | ||
+ | Your <color red> | ||
+ | \\ | ||
+ | \\ | ||
+ | Create the boot and root file systems: | ||
+ | \\ | ||
+ | \\ | ||
+ | sudo mkfs.vfat -n BOOT -F 32 /dev/sda1 | ||
+ | sudo mkfs.ext4 /dev/sda2 | ||
+ | \\ | ||
+ | \\ | ||
+ | Mount the target file system and copy the running raspbian system to it: | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | sudo mkdir /mnt/target | ||
+ | sudo mount /dev/sda2 / | ||
+ | sudo mkdir / | ||
+ | sudo mount /dev/sda1 / | ||
+ | sudo apt-get update; sudo apt-get install rsync | ||
+ | sudo rsync -ax --progress / /boot /mnt/target | ||
+ | </ | ||
+ | \\ | ||
+ | Regenerate ssh host keys: | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | cd /mnt/target | ||
+ | sudo mount --bind /dev dev | ||
+ | sudo mount --bind /sys sys | ||
+ | sudo mount --bind /proc proc | ||
+ | sudo chroot /mnt/target | ||
+ | rm / | ||
+ | dpkg-reconfigure openssh-server | ||
+ | exit | ||
+ | sudo umount dev | ||
+ | sudo umount sys | ||
+ | sudo umount proc | ||
+ | </ | ||
+ | \\ | ||
+ | Edit <color red> / | ||
+ | system instead of the SD card. | ||
+ | \\ | ||
+ | \\ | ||
+ | sudo sed -i " | ||
+ | \\ | ||
+ | \\ | ||
+ | The same needs to be done for <color red> | ||
+ | \\ | ||
+ | \\ | ||
+ | sudo sed -i " | ||
+ | \\ | ||
+ | \\ | ||
+ | Finally, unmount the target file systems, and power the Pi off. | ||
+ | \\ < | ||
+ | cd ~ | ||
+ | sudo umount / | ||
+ | sudo umount /mnt/target | ||
+ | sudo poweroff | ||
+ | </ | ||
+ | \\ | ||
+ | Disconnect the power supply from the Pi, remove the SD card, and reconnect the power supply. If all has gone well, the Pi should begin to boot after a few seconds. | ||
+ | \\ | ||
+ | \\ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== NOTE ==== | ||
+ | \\ | ||
+ | \\ | ||
+ | Once you have done a couple, and you are comfortable with the sequence, you can copy and paste the commands in batches: | ||
+ | \\ | ||
+ | \\ | ||
+ | < | ||
+ | sudo mkdir /mnt/target | ||
+ | sudo mount /dev/sda2 / | ||
+ | sudo mkdir / | ||
+ | sudo mount /dev/sda1 / | ||
+ | sudo apt-get update; sudo apt-get install rsync | ||
+ | sudo rsync -ax --progress / /boot /mnt/target | ||
+ | </ | ||
+ | \\ | ||
+ | < | ||
+ | cd /mnt/target | ||
+ | sudo mount --bind /dev dev | ||
+ | sudo mount --bind /sys sys | ||
+ | sudo mount --bind /proc proc | ||
+ | sudo chroot /mnt/target | ||
+ | rm / | ||
+ | dpkg-reconfigure openssh-server | ||
+ | </ | ||
+ | \\ | ||
+ | exit | ||
+ | \\ | ||
+ | < | ||
+ | sudo umount dev | ||
+ | sudo umount sys | ||
+ | sudo umount proc | ||
+ | </ | ||
+ | \\ | ||
+ | < | ||
+ | sudo sed -i " | ||
+ | sudo sed -i " | ||
+ | </ | ||
+ | \\ | ||
+ | < | ||
+ | cd ~ | ||
+ | sudo umount / | ||
+ | sudo umount /mnt/target | ||
+ | </ | ||
+ | \\ | ||
+ | \\ | ||
+ | sudo poweroff | ||
\\ | \\ | ||
\\ | \\ | ||
raspberry_pi_3_boot_to_usb.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1