Skip to content

Commit b2c8386

Browse files
committed
disk
1 parent a27d659 commit b2c8386

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/actions/setup-imdisk/action.yaml

+19-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ runs:
1010
shell: pwsh
1111
run: |
1212
$ErrorActionPreference = "Stop"
13+
1314
$path = "$($env:TEMP)\osfmount.exe"
1415
& curl.exe `
1516
--progress-bar `
@@ -22,11 +23,13 @@ runs:
2223
if ((Get-FileHash $path -Algorithm SHA256).Hash -ne $env:OSFMOUNT_SHA256) {
2324
throw "Failed to verify osfmount.exe"
2425
}
26+
2527
# We can't just use -Wait here or it will block when the installer
2628
# launches the GUI afterwards, and there's no way to turn that off.
2729
$proc = Start-Process -FilePath $path -ArgumentList "/silent /norestart" -PassThru
2830
$proc.WaitForExit()
2931
if ($proc.ExitCode -ne 0) { throw "Failed to install osfmount.exe" }
32+
3033
# Close the GUI and delete the installer.
3134
Get-Process -Name "OSFMount" -ErrorAction SilentlyContinue | Stop-Process -Force
3235
Remove-Item $path
@@ -38,5 +41,20 @@ runs:
3841
shell: pwsh
3942
run: |
4043
$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
4250
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

Comments
 (0)