> > Well, this is silly. If you use dd to truncate a file this way you > > lose the trailing byte :)
dd if=/dev/zero of=x seek=newsize bs=1 count=0 I just noticed you can use count=0 to avoid the extra byte. So, this seems to be the easiest way to truncate a file in Linux. > I use trivial programs written in some other language to do the > truncating. For example, python: > > file('xxx').truncate(10*1024*1024*1024) > > But do note that files created this way are sparse - and we have had > *drastic* performance problems with files that are sparse. I just learned about sparse files[1]! Thanks. I guess those languages (perl/python) just make a truncate system call. But I also guess it's not an issue truncating a root_fs because the whole file actually exists. Usually,people create the ext3 filesystem over an existing file full of zeros created with dd. Which also means you can create a filesystem over a sparse file. I didn't know that. [EMAIL PROTECTED]:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda6 15G 3.5G 10G 26% / [EMAIL PROTECTED]:~$ dd if=/dev/zero of=x bs=1 count=0 seek=10485760000 [EMAIL PROTECTED]:~$ ls -lha x -rw-r--r-- 1 n n 9.8G Mar 15 16:03 x [EMAIL PROTECTED]:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda6 15G 3.5G 10G 26% / [EMAIL PROTECTED]:~$ mkfs.ext3 x /dev/sda6 15G 3.7G 9.8G 28% / Thanks. Regards, Nelson.- [1]http://mldonkey.berlios.de/modules.php?name=Wiki&pagename=sparse%20files -- Homepage : http://geocities.com/arhuaco The first principle is that you must not fool yourself and you are the easiest person to fool. -- Richard Feynman. ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ User-mode-linux-user mailing list User-mode-linux-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user