You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

#!/bin/sh
OLDFST="$(lsblk -no FSTYPE /dev/$1)"
OLDLBL="$(lsblk -no LABEL /dev/$1)"
OLDUID="$(lsblk -no UUID /dev/$1)"
NEWFST="$(lsblk -no FSTYPE /dev/$2)"
NEWLBL="$(lsblk -no LABEL /dev/$2)"
NEWUID="$(lsblk -no UUID /dev/$2)"
[ ! -e /dev/$1 ] && echo "Device /dev/$1 does not exist." && exit 1
[ ! -e /dev/$2 ] && echo "Device /dev/$2 does not exist." && exit 1
clear
echo -e " --DEVICE-- -FS- -----LABEL------ ----------------UUID----------------\nOLD:\nNEW:"
tput cup 1 5; echo -e /dev/$1
tput cup 1 16; echo -e $OLDFST
tput cup 1 21; echo -e $OLDLBL
tput cup 1 38; echo -e $OLDUID
tput cup 2 5; echo -e /dev/$2
tput cup 2 16; echo -e $NEWFST
tput cup 2 21; echo -e $NEWLBL
tput cup 2 38; echo -e $NEWUID
echo ''
read -n 1 -p 'CANCEL WITH CTRL+C OR PRESS ANY KEY TO CONTNUE...'
[[ $3 != nozero ]] && dcfldd if=/dev/zero of=/dev/$2 bs=4M
mkfs -t $OLDFST -L "$OLDLBL" -U $OLDUID /dev/$2
mkdir -p /mnt/partcopy-{old,new}
mount /dev/$1 /mnt/partcopy-old
mount /dev/$2 /mnt/partcopy-new
rsync -avPH --numeric-ids /mnt/partcopy-old/ /mnt/partcopy-new
umount /dev/$2
umount /dev/$1
rmdir /mnt/partcopy-{old,new}