From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CEMnB-0007GW-PI for qemu-devel@nongnu.org; Mon, 04 Oct 2004 02:57:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CEMnB-0007GE-9x for qemu-devel@nongnu.org; Mon, 04 Oct 2004 02:57:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CEMnB-0007G2-7l for qemu-devel@nongnu.org; Mon, 04 Oct 2004 02:57:53 -0400 Received: from [64.233.170.197] (helo=mproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CEMg8-000319-8M for qemu-devel@nongnu.org; Mon, 04 Oct 2004 02:50:36 -0400 Received: by mproxy.gmail.com with SMTP id 75so867207rnk for ; Sun, 03 Oct 2004 23:50:32 -0700 (PDT) Message-ID: Date: Mon, 4 Oct 2004 02:50:31 -0400 From: Karl Magdsick Subject: Re: [Qemu-devel] remark about http://www.freeoszoo.org In-Reply-To: <20041003192154.GA10119@xi.wantstofly.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <20041002131621.GA90530@aseed.antenna.nl> <20041003192154.GA10119@xi.wantstofly.org> Reply-To: Karl Magdsick , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lennert Buytenhek Cc: qemu-devel@nongnu.org Free OS Zoo suggests using dd with the seek= option in the _specific_ case of Linux, which appears to be safe. My comment was explicitly a note of caution in the _general_ case. I did not intend to slander the suggestions posted on the Free OS Zoo page. My comments were meant merely as a word of caution about over-generalizing the suggestions of the Free OS Zoo people. Perhaps I should have been more clear about the "in the general case" part of my statement. I meant "general" in the sense of making as few extra assumptions as possible, not in the sense of "common". Unless I had specific knowledge about sparse file support on my filesystem and the behavior of fseek, lseek, llseek, etc. seeking past the end of a file that cannot become sparse on my system, I would not risk personal information on assumptions about the behavior of my system. Documentation of this behavior is spotty at best. (Solaris and Linux manpages, as well as the latest edition of Advanced Programming in the UNIX Environment, implicitly assume that sparse files are available across the board.) In the specific case where you are using a filesystem that supports sparse files (ext2, ext3, ufs, ffs, ntfs, etc.), seeking past the end of the file is well documented and will create a sparse file, and everything will be dandy. HFS+ does not support sparse files, but OS X zeroes out blocks as the seeks force their allocation on HFS+ partitons. The latest Debian-testing for x86 will cause seeks past the end of files on VFAT filesystems to fail, but this is not evident from the documentation. Therefore, for 99% of QEMU users, the suggested method is probably safe. I hereby apologise to anyone that feels I have over-stated the risks involved in using dd to seek past the end of a file on arbitrary filesystems and arbitrary OSes. In the specific cases of ext2/ext3 on Linux, NTFS on WinXP (cygwin or CoLinux), and HFS+/UFS on OS X, dd will most likely behave correctly with the suggested inputs. (I have no personal experience with dd on WinXP.) In the case of vfat filesystems on Linux, the suggested method will fail in a safe manner, leaking no information. Sorry for any confusion, -Karl On Sun, 3 Oct 2004 21:21:54 +0200, Lennert Buytenhek wrote: > On Sun, Oct 03, 2004 at 01:47:00PM -0400, Karl Magdsick wrote: > > > To prevent this, in the dd command, use if=/dev/zero and change the > > count to be the suggested seek value. Do not specify a seek value. > > This will cause dd to take longer to create a disk image, but it will > > zero out the contents of the file, rather than asking the OS to create > > a file from whatever garbage is left on disk. > > You think that "dd if=/dev/null of=blah bs=1024k count=1 seek=1024" > creates a file that can have anything else than just zeroes in it, > hm? > > Just try it. And then please apologise to the freeoszee people. > > > --L