Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.09 KB | None | 0 0
  1. BACKUP=kvm-backup-2018-1.tar.xz
  2. setopt extendedglob
  3. VGNAME=$(vgs --noheadings -o vg_name) && [[ -n $VGNAME ]] && vgremove -fv $VGNAME
  4. if [[ -z $DISK ]]; then
  5.     typeset -a devs
  6.     devs=( $(blkid -o export -s TYPE | awk -vRS="" -vFS="\n" '/TYPE=(ext|ntfs|btrfs|xfs)/{print $1}') )
  7.     if (( $#devs!= 1 )); then
  8.         print "failed to detect block device, consider using DISK=/dev/sdX"
  9.     else
  10.         DISK=${${devs[1]##*=}%%[[:digit:]]##}
  11.     fi
  12. fi
  13. if [[ ! -b $DISK ]]; then
  14.     print "$DISK is not a block device"
  15. else
  16.     cd /root
  17.     sgdisk -Z $DISK
  18.     sgdisk -n 0:0:+1024M $DISK
  19.     sgdisk -n 0:0:+100M $DISK
  20.     sgdisk -n 0:0:0 $DISK
  21.     sgdisk -c 1:vm_swap $DISK
  22.     sgdisk -c 2:vm_boot $DISK
  23.     sgdisk -c 3:vm_root $DISK
  24.     sgdisk -t 1:8200 $DISK
  25.     sgdisk -t 2:ef02 $DISK
  26.     partprobe $DISK
  27.     mkswap -L vm_swap ${DISK}1
  28.     mkfs.btrfs -f -L vm_root ${DISK}3
  29.     swapon LABEL=vm_swap
  30.     mount LABEL=vm_root /mnt/gentoo
  31.     cd /mnt/gentoo
  32.     wget --user=vps --password=VtufcblboT http://megaseed.kz/vps/$BACKUP
  33.     tar --numeric-owner -xvpf $BACKUP -C /mnt/gentoo
  34. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement