Welcome to mirror list, hosted at ThFree Co, Russian Federation.

resize-vagrant-disk.sh - github.com/ValveSoftware/Proton.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0ffe1ecd00fa7a6bc55619db1c24678103ea8f4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash

#this script resizes the build VM disk image.  the generic/debian9 box that we
#use only ships a 32G disk, which is only just large enough to hold the Steam
#runtime, two Wine build trees, and final Proton dist/ folder.

set -e

NOTE_STYLE="\e[31m\e[1m"
RESET_STYLE="\e[0m"

NEW_LIBVIRT_DISK_SIZE=128G

function note {
    echo -e "$NOTE_STYLE""$1""$RESET_STYLE"
}

function usage {
    note "To automatically resize a libvirt disk to $NEW_LIBVIRT_DISK_SIZE:"
    echo ""
    echo -e "\t$0 --libvirt-disk <libvirt disk path>"
    echo ""
    note "You may find the disk path with \"virsh vol-list default\"."
    echo ""
    note "Or, if you've already manually resized the disk (e.g. VirtualBox users):"
    echo ""
    echo -e "\t$0 --resize-vm-partition"
    exit 1
}

#to be run from within the VM
if [ "$1" == "--fdisk" ]; then
    sudo sfdisk -d /dev/sda > /tmp/sda.sfdisk

    #remove start and size params from sda3 line, sfdisk will automatically use the rest of the disk
    sed -e "s/^.dev.sda3.*$/\/dev\/sda3 : type=83/" < /tmp/sda.sfdisk | sudo sfdisk --force /dev/sda

    exit

#to be run from within the VM
elif [ "$1" == "--resize2fs" ]; then
    #resize2fs automatically uses the whole partition
    sudo resize2fs /dev/sda3

    exit

#libvirt disk image to resize
elif [ "$1" == "--libvirt-disk" ]; then
    if [ -z "$2" ]; then
        note "You must give a disk path to --libvirt-disk"
        echo ""
        usage
        exit 1
    fi
    LIBVIRT_DISK_PATH="$2"

    note "Going to resize disk $LIBVIRT_DISK_PATH"
    note "Shutting down VM"
    vagrant halt

    note "Resizing the VM disk image"
    virsh vol-resize "$LIBVIRT_DISK_PATH" "$NEW_LIBVIRT_DISK_SIZE" --pool default

#just resize the partition in the VM
elif [ "$1" == "--resize-vm-partition" ]; then
    : #noop

else
    if [ -n "$1" -a "$1" != "--help" -a "$1" != "-h" ]; then
        note "Unknown argument: $1"
        exit 1
    fi
    usage
    exit 1
fi

note "Starting the VM"
vagrant up
vagrant rsync

note "Repartitioning the disk"
vagrant ssh -c "/home/vagrant/proton/resize-vagrant-disk.sh --fdisk"

note "Restarting the VM"
#seems to be necessary for resize2fs to pick up on the new partition size
#maybe there's a way to do that without rebooting?
vagrant halt
vagrant up

note "Resizing the filesystem"
vagrant ssh -c "/home/vagrant/proton/resize-vagrant-disk.sh --resize2fs"

note "Here's the output from \"df -h /dev/sda3\":"
vagrant ssh -c "df -h /dev/sda3"

note "Shutting down the VM"
#just to be sure everything is in a clean state
vagrant halt

note "Done!"