-1

I want to create create a qcow2 image for a virtual disk size of 7G so I'm doing virsh_pool=/home/test/abc and then

qemu-img create “${virsh_pool}/foo.qcow2” 7G

But it gives me an error like

Formatting '“”/home/test/abc”/foo.qcow2”', fmt=raw size=7516192768
qemu-img: “”/home/test/abc”/foo.qcow2”: Could not create file: No such file or directory

When I do

qemu-img create /home/test/abc/foo.qcow 7G

It gets created but not the above way that I wan to do. What am I missing or doing wrong in this way?.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Rajat Singh
  • 653
  • 6
  • 15
  • 29

2 Answers2

0

Try this (copy and paste it):

d="${virsh_pool}"
if [[ -d "$d" ]]
then
    qemu-img create "$d/foo.qcow2" 7G
else
    printf 'ERROR\n' >&2
fi
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
-1

Try without quotes:

qemu-img create ${virsh_pool}/foo.qcow2 7G

Rajat Singh
  • 653
  • 6
  • 15
  • 29
Nill
  • 16
  • 3
  • ` Formatting '/home/test/abc/abc.qcow2', fmt=raw size=7516192768 qemu-img: /home/test/abc/foo.qcow2: Could not create file: No such file or directory ` – Rajat Singh Aug 30 '19 at 15:48
  • Please *do* use quotes, but use the *right* ones. Variable references should (almost) always have plain ASCII double-quotes around them. That is, use `"${virsh_pool}/foo.qcow2"`, not `“${virsh_pool}/foo.qcow2”` (fancy Unicode quotes), `${virsh_pool}/foo.qcow2` (no quotes), or even `'${virsh_pool}/foo.qcow2'` (single-quotes). – Gordon Davisson Aug 30 '19 at 19:38