Skip to content

Commit 328b926

Browse files
committed
Bypass default encryption policy when expanding sandbox vhdx
This fixes the following error when running on machines with a policy to enforce bitlocker encryption on fixed drives ``` failed to create scratch layer: failed to expand sandbox vhdx size to #### bytes: FSCTL_EXTEND_VOLUME \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}: The media is write protected. ``` Fixed: #2464 Signed-off-by: Matthew Endsley <[email protected]>
1 parent 59e0e2f commit 328b926

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

internal/wclayer/expandscratchsize.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/Microsoft/hcsshim/internal/hcserror"
1313
"github.com/Microsoft/hcsshim/internal/oc"
1414
"go.opencensus.io/trace"
15+
"github.com/Microsoft/go-winio/vhd"
1516
)
1617

1718
// ExpandScratchSize expands the size of a layer to at least size bytes.
@@ -75,7 +76,7 @@ func attachVhd(path string) (syscall.Handle, error) {
7576
if err != nil {
7677
return 0, &os.PathError{Op: "OpenVirtualDisk", Path: path, Err: err}
7778
}
78-
err = attachVirtualDisk(handle, 0, 0, 0, 0, 0)
79+
err = vhd.AttachVirtualDisk(handle, vhd.AttachVirtualDiskFlagBypassDefaultEncryptionPolicy, nil)
7980
if err != nil {
8081
syscall.Close(handle)
8182
return 0, &os.PathError{Op: "AttachVirtualDisk", Path: path, Err: err}

0 commit comments

Comments
 (0)