diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go index b593ac589554..954ace3074ab 100644 --- a/lxd/storage/drivers/utils.go +++ b/lxd/storage/drivers/utils.go @@ -641,7 +641,7 @@ func copyDevice(inputPath string, outputPath string) error { _ = from.Close() } - to, err := os.OpenFile(outputPath, unix.O_DIRECT|unix.O_RDONLY, 0) + to, err := os.OpenFile(outputPath, unix.O_DIRECT|unix.O_WRONLY, 0) if err == nil { cmd = append(cmd, "oflag=direct") _ = to.Close() diff --git a/lxd/storage/utils.go b/lxd/storage/utils.go index a924e3dfdf20..2cd1e3823cd2 100644 --- a/lxd/storage/utils.go +++ b/lxd/storage/utils.go @@ -791,7 +791,7 @@ func ImageUnpack(imageFile string, vol drivers.Volume, destBlockFile string, sys _ = from.Close() } - to, err := os.OpenFile(dstPath, unix.O_DIRECT|unix.O_RDONLY, 0) + to, err := os.OpenFile(dstPath, unix.O_DIRECT|unix.O_WRONLY, 0) if err == nil { cmd = append(cmd, "-t", "none") _ = to.Close()