Last active
July 22, 2016 16:17
-
-
Save ryross/e25e6ec9619469f090a8d9001af02f4b to your computer and use it in GitHub Desktop.
Clone ODROID SSD
This file contains hidden or 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
## Instructions to clone odroid external ssd over to a new external ssd | |
# You shouldn’t see any errors when running this process, if you do. Stop immediately and ask me. | |
# run lsblk to see all the hard drives. You should see a line starting with mmcblk0 and then 2 more underneath it with | |
# mmcblk0p1 and mmcblk0p2. That’s the sd card disk and the sd card partitions. You’ll also see a line starting with | |
# sda (and/or sdb if there are two usb drives). We want to use the sd* one. | |
lsblk | |
#pull out some of the values from lsblk so we can automate the rest of the script | |
read new_partition new_drive mountpoint <<< `lsblk -e 179 -l -o NAME,PKNAME,FSTYPE,MOUNTPOINT |grep 'vfat\s*/media/odroid' | awk {'print $1" "$2" "$4'}` | |
# after you run this command, verify that it matches the mount point and partition of the usb drive you identified | |
# in the first step. if you’re not 100% sure here, ask me. | |
echo "about to unmount $mountpoint on $new_partition. Disk: $new_drive" | |
export new_drive="/dev/$new_drive" | |
export new_partition="/dev/$new_partition" | |
umount $mountpoint | |
# if the echo line above outputs "about to unmount on . Disk:" then we couldn't find which disk to use automatically. If you're cloning an SSD to an SSD, the first SSD is most likely /dev/sda and second one is /dev/sdb. You probably want to use the drive /dev/sdb and partition /dev/sdb1. | |
# to do that uncomment these lines and run them. You'll want to find the partition that's mounted and unmount it. You unmount by running umount (not unmount) and then pass in the mountpoint. If you have trouble finding the mount point, let me know. | |
# export new_drive="/dev/sdb” | |
# export new_partition="/dev/sdb1” | |
# repartition the file ssd | |
sudo parted --script $new_drive mklabel gpt | |
sudo parted --align optimal $new_drive mkpart primary ext4 0% 100% | |
# after running the last command, you may see: | |
# “Information: You may need to update /etc/fstab.” | |
# If that’s all you see then that’s fine. If there’s any other output from that command, let me know. | |
# switch the file system to ext4. | |
sudo mkfs -F -t ext4 -L rootfs $new_partition | |
# make a place for the ssd to mount to, and mount it | |
sudo mkdir -p /mnt/clone | |
sudo mount $new_partition /mnt/clone | |
# transfer all the files over from the sd card to the new ssd | |
sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt/clone | |
export root_dev=`mount |grep "on / " | awk {'print $1'}` | |
export current_uuid=`blkid -o value $root_dev | sed -n '2p'` | |
export new_uuid=`blkid -o value $new_partition | sed -n '2p'` | |
# update mount the new partition as the root partition | |
sudo sed -i "s/${current_uuid}/${new_uuid}/" /mnt/clone/etc/fstab | |
echo "Now clone the SD Card and edit boot.ini to use UUID $new_uuid" | |
sudo umount /mnt/clone/ | |
# I think that should be it! Now you can safely unplug the clone ssd | |
# now clone the sd card. Once you do, we'll need to update boot.ini. Hit me up and I'll help you with that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment