You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: bash_profile
-95
Original file line number
Diff line number
Diff line change
@@ -8,106 +8,11 @@ red=$(tput setaf 1)
8
8
ylw=$(tput setaf 3)
9
9
txtrst=$(tput sgr0)
10
10
11
-
diskvol=$(mount | grep -m1 ext4 | cut -f 1 -d "")
12
-
sudo resize2fs $diskvol>/dev/null 2>&1
13
-
disksize=$(sudo blockdev --getsize64 $diskvol)
14
-
width=$(echo $COLUMNS)
15
-
16
-
if [ "$width"-gt 120 ];then
17
-
width=120
18
-
fi
19
-
20
-
test -e /mnt/c/Users/Public/vhdresize.txt && rm /mnt/c/Users/Public/vhdresize.txt
21
11
test -e /mnt/c/Users/Public/shutdown.cmd && rm /mnt/c/Users/Public/shutdown.cmd
22
-
test -e ~/vhdresize.txt && rm ~/vhdresize.txt
23
12
test -e ~/shutdown.cmd && rm ~/shutdown.cmd
24
13
figlet -t -k -f /usr/share/figlet/fonts/mini.flf "Welcome to ArchWSL2"| lolcat
25
14
echo -e "\033[33;7mDo not interrupt or close the terminal window till script finishes execution!!!\n\033[0m"
26
15
27
-
if [ "$disksize"-le 274877906944 ];then
28
-
echo -e ${grn}"ArchWSL2's VHD has a default maximum size of 256GB. Disk space errors which occur if size exceeds 256GB can be fixed by expanding the VHD. Would you like to resize your VHD? More information on this process is available at \033[36mhttps://docs.microsoft.com/en-us/windows/wsl/vhd-size\033[32m."${txtrst}| fold -sw $width
29
-
selectynin"Yes""No";do
30
-
case$ynin
31
-
Yes)
32
-
echo""
33
-
whileread -p ${mgn}"Path to virtual disk (e.g. C:\Users\silesh\wsl\ext4.vhdx) : "${txtrst} -r vhdpath;do
34
-
if [ "x$vhdpath"="x" ];then
35
-
echo -e ${red}"Path cannot be blank."${txtrst}
36
-
echo -en "\033[1A\033[1A\033[2K"
37
-
vhdpath=""
38
-
else
39
-
wsl_path=$(wslpath -a $vhdpath)
40
-
if [ !-f$wsl_path ];then
41
-
echo -e ${red}"Disk does not exist. "${txtrst}
42
-
echo -en "\033[1A\033[1A\033[2K"
43
-
vhdpath=""
44
-
else
45
-
echo"select vdisk file=\"$vhdpath\""| sudo tee -a ~/vhdresize.txt >/dev/null 2>&1
46
-
break
47
-
fi
48
-
fi
49
-
done
50
-
whileread -p ${mgn}"Size of virtual disk in MegaBytes(e.g. 512000 for 512GB) : "${txtrst} vhdsize;do
51
-
if [[ $vhdsize=~ ^-?[0-9]+$ ]];then
52
-
if [ "$vhdsize"-le 256000 ];then
53
-
echo -e ${red}"Disk size should be greater than 256000 MegaBytes."${txtrst}
54
-
echo -en "\033[1A\033[1A\033[2K"
55
-
vhdsize=0
56
-
else
57
-
echo -en "\033[1B\033[1A\033[2K"
58
-
echo"expand vdisk maximum=$vhdsize"| sudo tee -a ~/vhdresize.txt >/dev/null 2>&1
59
-
echo""
60
-
printf"%s""$(<~/vhdresize.txt)"
61
-
echo""
62
-
echo -e ${grn}"\nReview the information displayed above and confirm to proceed."${txtrst}
63
-
echo -e ${red}"Edit only your input if you want to make changes!!!"${txtrst}
64
-
selectynin"Proceed""Edit";do
65
-
case$ynin
66
-
Proceed)
67
-
break
68
-
;;
69
-
Edit)
70
-
"${EDITOR:-nano}"~/vhdresize.txt
71
-
break
72
-
;;
73
-
esac
74
-
done
75
-
echo"@echo off"| sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
76
-
echo"wsl --shutdown"| sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
77
-
echo"diskpart /s C:\Users\Public\vhdresize.txt"| sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
78
-
if env | grep "WT_SESSION">/dev/null 2>&1;then
79
-
echo"wt.exe -w 0 nt wsl.exe -d $WSL_DISTRO_NAME"| sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
80
-
else
81
-
echo"cmd /c start \"$WSL_DISTRO_NAME\" wsl.exe --cd ~ -d $WSL_DISTRO_NAME"| sudo tee -a ~/shutdown.cmd >/dev/null 2>&1
0 commit comments