On Tuesday 15 March 2005 21:37, Nuutti Kotivuori wrote:
> Nelson Castillo wrote:
> > Well, this is silly. If you use dd to truncate a file this way you
> > lose the trailing byte :)
> >
> > I really want to know : Is there another way to truncate a file in
> > Linux?
> >
> > This would be a silly way to avoid wasting a byte to truncate a file
> > to have 2 bytes with dd.
> >
> > ~$ echo 12345 > x
> > ~$ dd if=x skip=1 bs=1 count=1 > t
> > ~$ dd if=t seek=1 of=x count=1 bs=1
> > ~$ cat x
> > 12
> >
> > Regards,
> > Nelson.-
>
> 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.
Well, I've heard that sparse swap files are a big problem. In general, you 
defer the space allocation, and I guess that depending on the filesystem this 
can give problems.
> So I would recommend just writing zeros.
>
> -- Naked


-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
http://www.user-mode-linux.org/~blaisorblade




-------------------------------------------------------
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

Reply via email to