Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BACKUP=kvm-backup-2018-1.tar.xz
- setopt extendedglob
- VGNAME=$(vgs --noheadings -o vg_name) && [[ -n $VGNAME ]] && vgremove -fv $VGNAME
- if [[ -z $DISK ]]; then
- typeset -a devs
- devs=( $(blkid -o export -s TYPE | awk -vRS="" -vFS="\n" '/TYPE=(ext|ntfs|btrfs|xfs)/{print $1}') )
- if (( $#devs!= 1 )); then
- print "failed to detect block device, consider using DISK=/dev/sdX"
- else
- DISK=${${devs[1]##*=}%%[[:digit:]]##}
- fi
- fi
- if [[ ! -b $DISK ]]; then
- print "$DISK is not a block device"
- else
- cd /root
- sgdisk -Z $DISK
- sgdisk -n 0:0:+1024M $DISK
- sgdisk -n 0:0:+100M $DISK
- sgdisk -n 0:0:0 $DISK
- sgdisk -c 1:vm_swap $DISK
- sgdisk -c 2:vm_boot $DISK
- sgdisk -c 3:vm_root $DISK
- sgdisk -t 1:8200 $DISK
- sgdisk -t 2:ef02 $DISK
- partprobe $DISK
- mkswap -L vm_swap ${DISK}1
- mkfs.btrfs -f -L vm_root ${DISK}3
- swapon LABEL=vm_swap
- mount LABEL=vm_root /mnt/gentoo
- cd /mnt/gentoo
- wget --user=vps --password=VtufcblboT http://megaseed.kz/vps/$BACKUP
- tar --numeric-owner -xvpf $BACKUP -C /mnt/gentoo
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement