Score:0

Issue using dd to write 1GB file to zfs dataset on FreeBSD 13

cn flag

Hey guys I am turning up a little FAMP stack on an Azure VM. 4 Xeon cores 16GB ram. Second SSD is using ZFS and the boot drive is UFS2 (Default). When I dd if=/dev/zero of=testfile bs=1024 count=1024000 to my home directory which is located on the boot drive I can see a full 1GB file. When performing the same action on my ZFS dataset it appears to only be writing 512b. Not sure what is going on here. I can copy larger files from the UFS2 partitions to the ZFS datasets with no problem.

Any suggestions would be great as this is a concern for me before I release this into production.

[Thanks]

drookie avatar
za flag
So you're saying that zfs is unable to store files larger than one 512 bytes block. DEFINITELY WORTH REPORTING, lol.
Zork avatar
cn flag
No, if you read my post you will see I can copy files from the UFS2 drive to the ZFS SSSD with no issue. Just when I use DD it doesn't work :)
Score:5
ca flag

When writing an all-zero file on a ZFS dataset with compression enabled, it will be collapsed into a completely sparse file with minimum space consumption - 512B, as you saw. When reading the file back, it will be "re-hydrated" with all the originally written zeroes.

As a side note, you can do something similar even with classical filesystem as EXT4 or XFS: try issuing truncate -l 1G <filename> and you will end with a 1G file using only 512B (or 4K) of real space.

Rather than disabling compression, try copying something from /dev/urandom and you will see the expected space usage.

Andrew Henle avatar
ph flag
*When writing an all-zero file on a ZFS dataset with compression enabled* And the performance is downright **amazing**. ;-)
Score:-1
cn flag

I turned of lz4 compression and the dd works just fine. Apparently this has something to do with dd if=/dev/zero. I am not thinking this will be a concern going forwards so most likely going to turn compression back on.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.