Compare commits
5 Commits
70b0087b89
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3111605ce1 | ||
|
|
4a08cb45d4 | ||
|
|
31649a6948 | ||
|
|
55514aca5b | ||
|
|
b571133f3f |
27
restore.sh
27
restore.sh
@@ -44,7 +44,8 @@ do
|
||||
read -p "Target drive is " targetDrive
|
||||
targetDrive=/dev/$targetDrive
|
||||
done
|
||||
echo "Encrypted? (Y/n) "
|
||||
#encrypted?
|
||||
echo "Encrypted? (Y/N)"
|
||||
while read -r -n 1 answer ; do
|
||||
if [[ $answer = [YyNn] ]]; then
|
||||
[[ $answer = [Yy] ]] && encryptedDevice=true && echo "WARNING You will be asked for password later" #read -p "Password: " encryptedPassword
|
||||
@@ -55,6 +56,7 @@ done
|
||||
|
||||
#get swap size
|
||||
swapSize=$(free -m | grep "Mem" | awk '{print $2}')
|
||||
echo ""
|
||||
read -p "Enter extra amount of swap (empty == 512):" swapExtra
|
||||
[[ -z "$swapExtra" ]] && swapExtra=512
|
||||
let "swapSize += swapExtra" #add 512 mbs to swap for swap, not only hibernation
|
||||
@@ -100,19 +102,18 @@ echo w
|
||||
|
||||
##mkfs's
|
||||
echo "==> Making filesystems..."
|
||||
echo "mkswap"
|
||||
echo "=> swap"
|
||||
mkswap $targetDrive"1"
|
||||
echo "mkfs.vfat"
|
||||
echo "=> /boot"
|
||||
mkfs.vfat $targetDrive"2"
|
||||
|
||||
echo "mkfs.ext4"
|
||||
if $encryptedDevice
|
||||
then
|
||||
echo "=> rootfs"
|
||||
if $encryptedDevice ; then
|
||||
cryptsetup luksFormat -v $targetDrive"3"
|
||||
cryptsetup open $targetDrive"3" targetLuks
|
||||
mkfs.ext4 /dev/mapper/targetLuks
|
||||
mkfs.ext4 -q /dev/mapper/targetLuks
|
||||
else
|
||||
mkfs.ext4 $targetDrive"3"
|
||||
mkfs.ext4 -q $targetDrive"3"
|
||||
fi
|
||||
|
||||
sleep 15
|
||||
@@ -120,16 +121,14 @@ sleep 15
|
||||
##get disk's uuid
|
||||
echo "==> Got UUIDs!"
|
||||
UUIDS=($(blkid $targetDrive"1" $targetDrive"2" $targetDrive"3" -o value -s UUID))
|
||||
if $encryptedDevice
|
||||
then
|
||||
if $encryptedDevice ; then
|
||||
UUIDS[3]=UUIDS[2]
|
||||
UUIDS[2]=`blkid /dev/mapper/targetLuks -o value -s UUID`
|
||||
fi
|
||||
|
||||
##mount disks
|
||||
echo "==> Mounting..."
|
||||
if $encryptedDevice
|
||||
then
|
||||
if $encryptedDevice ; then
|
||||
mount /dev/mapper/targetLuks /mnt
|
||||
else
|
||||
mount $targetDrive"3" /mnt
|
||||
@@ -158,7 +157,7 @@ rm /mnt/etc/fstab.orig #TODO OFC we need to check mountpoint, not only type of F
|
||||
echo "==> Result:"
|
||||
cat /mnt/etc/fstab
|
||||
##update grub linux options
|
||||
if $encryptedDevice
|
||||
if $encryptedDevice ; then
|
||||
cat /mnt/etc/default/grub | sed 's/cryptdevice=UUID=[A-Fa-f0-9-]*:cryptroot /cryptdevice=UUID='${UUIDS[3]}':cryptroot/' > /mnt/etc/default/grub
|
||||
else
|
||||
cat /mnt/etc/default/grub | sed 's/cryptdevice=UUID=[A-Fa-f0-9-]*:cryptroot //' > /mnt/etc/default/grub
|
||||
@@ -178,7 +177,7 @@ echo "==> mkinitcpio and update grub..."
|
||||
#cat /mnt/etc/mkinitcpio.conf | sed 's/encrypt //' > /mnt/etc/mkinitcpio.conf #remove cryptdevice, no encrypted fs today :c
|
||||
|
||||
#chroot env
|
||||
cat << EOF | chroot /mnt
|
||||
cat << EOF | chroot /mnt /bin/sh
|
||||
mkinitcpio -P
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
grub-install $targetDrive
|
||||
|
||||
Reference in New Issue
Block a user