10
10
shell : pwsh
11
11
run : |
12
12
$ErrorActionPreference = "Stop"
13
+
13
14
$path = "$($env:TEMP)\osfmount.exe"
14
15
& curl.exe `
15
16
--progress-bar `
@@ -22,11 +23,13 @@ runs:
22
23
if ((Get-FileHash $path -Algorithm SHA256).Hash -ne $env:OSFMOUNT_SHA256) {
23
24
throw "Failed to verify osfmount.exe"
24
25
}
26
+
25
27
# We can't just use -Wait here or it will block when the installer
26
28
# launches the GUI afterwards, and there's no way to turn that off.
27
29
$proc = Start-Process -FilePath $path -ArgumentList "/silent /norestart" -PassThru
28
30
$proc.WaitForExit()
29
31
if ($proc.ExitCode -ne 0) { throw "Failed to install osfmount.exe" }
32
+
30
33
# Close the GUI and delete the installer.
31
34
Get-Process -Name "OSFMount" -ErrorAction SilentlyContinue | Stop-Process -Force
32
35
Remove-Item $path
38
41
shell : pwsh
39
42
run : |
40
43
$ErrorActionPreference = "Stop"
41
- & "C:\Program Files\OSFmount\OSFMount.com" -a -s 4096M -m R: -o logical,format:NTFS
44
+
45
+ # List disks before creating the RAM disk.
46
+ $before = Get-Disk
47
+
48
+ # Create the uninitialized disk.
49
+ & "C:\Program Files\OSFmount\OSFMount.com" -a -t vm -s 4096M -o physical
42
50
if ($LASTEXITCODE -ne 0) { throw "Failed to create RAM disk" }
51
+
52
+ # List disks after creating the RAM disk and find the new one.
53
+ $after = Get-Disk
54
+ $newDisk = ($after | Where-Object { $before.Number -notcontains $_.Number })
55
+ if (!$newDisk) { throw "Failed to find new RAM disk" }
56
+
57
+ # Initialize the disk, create a simple volume and format it NTFS.
58
+ Initialize-Disk -Number $newDisk.Number -PartitionStyle GPT -Confirm:$false
59
+ $partition = New-Partition -DiskNumber $newDisk.Number -UseMaximumSize -DriveLetter R
60
+ Format-Volume -Partition $partition -FileSystem NTFS -NewFileSystemLabel "RAMDisk" -Confirm:$false
0 commit comments