From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,427935f8a93f9524 X-Google-Attributes: gidfa528,public X-Google-ArrivalTime: 2002-01-31 12:40:27 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hardy.tc.umn.edu!news.nodak.edu!not-for-mail From: mooney@dogbert.cc.ndsu.NoDak.edu (Tim Mooney) Newsgroups: comp.unix.tru64 Subject: Re: du command on AdvFS Date: 31 Jan 2002 20:30:50 GMT Organization: North Dakota Higher Education Computing Network (NDHECN) Message-ID: References: <110fcff.0201281702.7e624109@posting.google.com> NNTP-Posting-Host: dogbert.cc.ndsu.nodak.edu Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: news.ndsu.nodak.edu 1012509050 11737 134.129.106.23 (31 Jan 2002 20:30:50 GMT) X-Complaints-To: abuse@nodak.edu NNTP-Posting-Date: 31 Jan 2002 20:30:50 GMT X-Newsreader: trn 4.0-test74 (May 26, 2000) Originator: mooney@dogbert.cc.ndsu.NoDak.edu (Tim Mooney) Xref: archiver1.google.com comp.unix.tru64:6661 In article <110fcff.0201281702.7e624109@posting.google.com>, Priscilla wrote: > I'm trying to find out why the du -sk command is sometimes reporting > the wrong disk usage on my directories. In my latest trial, I drilled down > and found specifically one file that was way off that was causing the whole > directory report to be off. > > /archive> du -sk smith.cf > 100992 smith.cf > > /archive> ls -l smith.cf > -rw-rw-r-- 1 prod tspi 372203552 Jan 24 11:03 smith.cf It's likely a sparse file. du -ks is showing you the actual amount of space the file is using, while ls is showing you how much space it would be using if there weren't big gaps in it. du is showing you how much Swiss cheese you actually have (when you account for the holes), while ls is just showing you a big block of cheese, without telling you there are big sections that don't contain any cheese. Note that AdvFS quota files are sparse files (assuming you don't have completely consecutive numeric ids), so you'll see this same behavior there. > I tar'd the whole directory over to another fileset and now the file > size (and directory usage) are correctly reported. :-) And now you have a file that's no longer sparse, so ls and du can agree. Of course, it's possibly wrecked the file (especially if the file was some type of database file), so you may be worse off than you were before. When you're going to move or archive sparse files, be sure you use a tool that correctly handles sparse files. The traditional UNIX backup tools (dump or ufsdump, and vdump for AdvFS) correctly handle sparse files. The traditional UNIX archive tools (tar, cpio, pax) generally do *not*. GNU tar has an option, `--sparse', that you can pass it, and it will correctly handle sparse files (the option may not even be needed anymore, it may handle them automatically, but old habits die hard so I still supply that option). Tim -- Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu Information Technology Services (701) 231-1076 (Voice) Room 242-J6, IACC Building (701) 231-8541 (Fax) North Dakota State University, Fargo, ND 58105-5164