I can't dd IF / OF a RAW file into a ZVOL, keeps writing file, not ZVOL?

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
This is clearly my fault, apologies, but 99% of my posts are my fault sadly!

I've done this in the past but I'm not sure what I'm doing wrong.

root@freenas[/mnt/SSDVM/VM]# dd if=/mnt/ARRAY/data/hass.raw of=/mnt/SSDVM/VM/HassIO
^C177121+0 records in
177121+0 records out
90685952 bytes transferred in 4.324300 secs (20971245 bytes/sec)
root@freenas[/mnt/SSDVM/VM]# ls /mnt/SSDVM/VM
HassIO

Note that it's written a file called "HassIO" it hasn't written into the ZVOL?

EIZ68Et.png



My wild guess here, is that it's unhappy it's "beneath" the filesystem of SSDVM / VM ?? I'm just not sure.
Either way, DD is writing a FILE not INTO the ZVOL which is no good, for my purposes and I know I've done this and got it working before, I just can't recall how.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
I have also just confirmed, even with no virtual machines, attached to the ZVOL as a disk, (somehow interrupting it) it still writes a file, not a ZVOL.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Oh my! so my destination is not an output FILE it's a device, this makes total sense Dan, thank you! I'll take a crack.
Silly me........
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
not an output FILE it's a device
Well, in Unix everything is a file, but I think this is the issue. But that's just a (somewhat-informed) guess on my part.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Well, in Unix everything is a file, but I think this is the issue. But that's just a (somewhat-informed) guess on my part.

Well you've helped me out, thank you!
Although I am now back in a situation I had a while back.
If I try to DD into a ZVOL which is set up as sparse, I get this error :
"end of device"

If I set it up, not as sparse, it consumes a full 36GB, regardless of compression being used on the ZVOL.
If you see the pic, up the top, my UbuntuServer ZVOL using 3.92GB, despite the partition being 80GB.

Any idea, how I can now get the contents of this ZVOL (or the RAW, or the VMDK, I just don't care) - into a ZVOL but only use the 3 or 4GB of actual data it has inside it?
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Using CloneZilla and mounting a new, blank, sparse ZVOL with 36GB allocated, will also result in destination disk too small sadly.
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
Using "dd" does not seem like the best tool from what you said. I am guessing that for a device file, "dd" does not try to "append" data to it. The tool seems to take the size as given.

However, if the source file is not sparse, but a simple file system that has little to no un-used space, your best bet would be to make the sparse zVol available to a client OS, and then use "dd" inside the client OS to the zVol device. That SHOULD grow the zVol as needed to meet the requested writes.

That said, I don't know if you can perform the task on natively on TrueNAS...
 
Top