From 3fdcb30f352dec80bafbb6ee43286d8a4432f41a Mon Sep 17 00:00:00 2001 From: LinirZamir Date: Tue, 21 Mar 2023 13:42:42 -0400 Subject: [PATCH] Update copy-rootfs-ssd.sh --- copy-rootfs-ssd.sh | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/copy-rootfs-ssd.sh b/copy-rootfs-ssd.sh index 5a3e026..f8c0940 100755 --- a/copy-rootfs-ssd.sh +++ b/copy-rootfs-ssd.sh @@ -1,7 +1,25 @@ #!/bin/bash -# Mount the SSD as /mnt -sudo mount /dev/nvme0n1p1 /mnt -# Copy over the rootfs from the SD card to the SSD + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +device_type=$1 +device_path="" + +if [ "$device_type" == "nvme" ]; then + device_path="/dev/nvme0n1p1" +elif [ "$device_type" == "usb" ]; then + device_path="/dev/sda1" +else + echo "Invalid device type. Supported types: nvme, usb" + exit 1 +fi + +# Mount the device as /mnt +sudo mount $device_path /mnt +# Copy over the rootfs from the SD card to the device sudo rsync -axHAWX --numeric-ids --info=progress2 --exclude={"/dev/","/proc/","/sys/","/tmp/","/run/","/mnt/","/media/*","/lost+found"} / /mnt -# We want to keep the SSD mounted for further operations -# So we do not unmount the SSD +# We want to keep the device mounted for further operations +# So we do not unmount the device