User Tools

Site Tools


raspberry_pi_3_boot_to_usb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
raspberry_pi_3_boot_to_usb [2016/12/14 16:35] walkeradminraspberry_pi_3_boot_to_usb [2016/12/14 16:43] walkeradmin
Line 85: Line 85:
 </file> </file>
 \\  \\ 
- +Your <color red>parted</color> print output should look similar to the one above. 
- +\\  
- +\\  
- +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:
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
 \\  \\ 
 \\  \\ 
 +<file>
 sudo mkdir /mnt/target sudo mkdir /mnt/target
 sudo mount /dev/sda2 /mnt/target/ sudo mount /dev/sda2 /mnt/target/
Line 117: Line 105:
 sudo apt-get update; sudo apt-get install rsync sudo apt-get update; sudo apt-get install rsync
 sudo rsync -ax --progress / /boot /mnt/target sudo rsync -ax --progress / /boot /mnt/target
 +</file> 
 +\\  
 +Regenerate ssh host keys: 
 +\\  
 +\\  
 +<file>
 cd /mnt/target cd /mnt/target
 sudo mount --bind /dev dev sudo mount --bind /dev dev
Line 129: Line 122:
 sudo umount sys sudo umount sys
 sudo umount proc sudo umount proc
 +</file>
 +\\ 
 +Edit <color red> /boot/cmdline.txt</color> so that it uses the USB storage device as the root file\\ 
 +system instead of the SD card.
 +\\ 
 +\\ 
 +    sudo sed -i "s,root=/dev/mmcblk0p2,root=/dev/sda2," /mnt/target/boot/cmdline.txt
 +\\ 
 +\\ 
 +The same needs to be done for <color red>fstab:</color>
 +\\ 
 +\\ 
 +    sudo sed -i "s,/dev/mmcblk0p,/dev/sda," /mnt/target/etc/fstab
 +\\ 
 +\\ 
 +Finally, unmount the target file systems, and power the Pi off.
 +\\ <file>
 +cd ~
 +sudo umount /mnt/target/boot 
 +sudo umount /mnt/target
 +sudo poweroff 
 +</file>
 +\\ 
 +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:
 +\\ 
 +\\ 
 +<file>
 +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
 +</file>
 +\\ 
 +<file>
 +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
 +</file>
 +\\ 
 +exit
 +\\ 
 +<file>
 +sudo umount dev
 +sudo umount sys
 +sudo umount proc
 +</file>
 +\\ 
 +<file>
 sudo sed -i "s,root=/dev/mmcblk0p2,root=/dev/sda2," /mnt/target/boot/cmdline.txt 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 sudo sed -i "s,/dev/mmcblk0p,/dev/sda," /mnt/target/etc/fstab
 +</file> 
 +\\  
 +<file>
 cd ~ cd ~
 sudo umount /mnt/target/boot  sudo umount /mnt/target/boot 
 sudo umount /mnt/target sudo umount /mnt/target
-sudo poweroff  +</file> 
 +\\  
 +\\  
 +sudo poweroff 
 \\  \\ 
 \\  \\ 
  
raspberry_pi_3_boot_to_usb.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1