Last active
March 14, 2017 16:39
-
-
Save yangxuan8282/879ec27a07a7c3b5225901c5dfe9e4be to your computer and use it in GitHub Desktop.
bash scripts migrating NOOBs to Raspbian, run it with `curl -SL https://git.io/vy1Ln | bash`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# FROM https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=106529 | |
# RUN `bash migrate_noobs.sh` | |
# ABOUT migrating NOOBs to Raspbian | |
# you need prepare 2 SD cards, card A running NOOBs that you want to migrate, put this card in pi card slot | |
# card B plug into card reader, insert this into pi usb port, all data in this card will be erased | |
# and remove all other storage | |
BOOT_PARTITION=`mount|grep ' /boot '|cut -d' ' -f 1` | |
ROOT_PARTITION=`mount|grep ' / '|cut -d' ' -f 1` | |
SDCARD=/dev/sda | |
sudo umount "$SDCARD"1 "$SDCARD"2 || /bin/true | |
sudo fdisk "$SDCARD" <<EOF | |
o | |
n | |
p | |
1 | |
+63M | |
t | |
c | |
n | |
p | |
2 | |
w | |
EOF | |
sudo mkfs.vfat "$SDCARD"1 | |
sudo mkfs.ext4 -F "$SDCARD"2 | |
sudo dd if=$BOOT_PARTITION of="$SDCARD"1 | |
sudo mount "$SDCARD"2 /mnt | |
sudo rsync -aAXv --progress --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt | |
sudo sed -i "s|$BOOT_PARTITION|/dev/mmcblk0p1|g" /mnt/etc/fstab | |
sudo sed -i "s|$ROOT_PARTITION|/dev/mmcblk0p2|g" /mnt/etc/fstab | |
sudo umount /mnt | |
sudo mount "$SDCARD"1 /mnt | |
sudo sed -i "s|$ROOT_PARTITION|/dev/mmcblk0p2|g" /mnt/cmdline.txt | |
sudo umount /mnt | |
echo " | |
✔ Done, Enjoy your Raspbian ❤ | |
" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment