Sponsored Content
Top Forums Shell Programming and Scripting Disk usage with links pointing to files on same FS Post 302885953 by rbatte1 on Wednesday 29th of January 2014 05:26:41 AM
Old 01-29-2014
When you say "all" directories, do you want to descend the top level directories from your current position and report them too? If so, leave off the -s flag. It may be useful to pipe this into a sort as below:-
Code:
du -kx | sort -n

You can choose if you want to include the -L flag. I think that links to files will just count the link where links to a directory will count the content of the directory. Of course, you are not considering hard links within your filesystem, however in my testing, I have found that if I have:-
Code:
robin @ /tmp/robin>ls -l
total 8
drwxr-xr-x 2 robin robingrp 4096 Jan 29 10:18 1
drwxr-xr-x 2 robin robingrp 4096 Jan 29 10:19 2
lrwxrwxrwx 1 robin robingrp    1 Jan 29 10:19 3 -> 2
robin @ /tmp/robin>ls -li 1 2
1:
total 183340
528470 -rw-r--r-- 2 robin robingrp 187740160 Jan 29 10:18 bigfile

2:
total 183340
528470 -rw-r--r-- 2 robin robingrp 187740160 Jan 29 10:18 bigfile
robin @ /tmp/robin>

..... you can see that directories 1 & 2 contain the same file hard linked (same inode number) and directory 3 is symbolically linked.

I then get this output:-
Code:
robin @ /tmp/robin>du -k
183344  ./2
4       ./1
183352  .
robin @ /tmp/robin>

..... so the file is only reported once. i must admit I don't know why it is reported under directory 2 rather than 1, but it's something to be aware of.
You can also see that 3 doesn't list at all.

This is on RHEL6, but other operating systems may vary. It might be that it reports the space used under 1 as the same as 2, but the total doesn't match up.

I hope that this helps.


Robin
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Pointing one hard drive name to another disk

Pointing one hard drive name to another disk -------------------------------------------------------------------------------- I have 2 disk drives - s2d9 & s2d11 on a solaris Unix system It was mapped so that anything that tried to call s2d9 would be pointed to s2d11 since s2d9 was bad.... (2 Replies)
Discussion started by: andy57s
2 Replies

2. UNIX for Dummies Questions & Answers

disk usage

how to i find out the disk usage on a server. say in windows examples its like C:/ D:/ and checking out the disk space. how can i find in Unix. can i just use df -k or should i go to each volume group and find that way. plz respond (2 Replies)
Discussion started by: karthikosu
2 Replies

3. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

4. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

5. UNIX for Dummies Questions & Answers

How to trace the big files causing high disk usage

Hi All, One very urgent issue and I need your help. I have two V490 servers installed with Sun Solaris 10. I have traced out that the disk usage is running out of space for both the servers. Currently the /dev/md/dsk/d10 device is 91% in one server and another is 56% and it is increasing... (1 Reply)
Discussion started by: ailnilanjan
1 Replies

6. UNIX for Dummies Questions & Answers

du - Disk Usage for only files and NOT directories.

Hello, Could any one help me how to find the Disk Usage for all the files in the running directory and the sub directories without the disk usage of the directory. I mean to say, i need only the file names without the size of the directories. See, i used this command du -a .|sort... (3 Replies)
Discussion started by: RRVARMA
3 Replies

7. Red Hat

Disk usage showing 100% after deleting files also | Red Hat Linux 3.2.2-5

My Redhat Linux system is always showing 100& disk usage. I have removed almost all the files, but no use and I am always getting 100% disk usage.!! Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda2 36337384 36066352 0 100% / I can... (7 Replies)
Discussion started by: sanoop
7 Replies

8. Shell Programming and Scripting

Perl Script to find the disk usage and to delete the files which is consuming more space

Hi All, I have written a script to check the file system usage and to delete the files which is consuming more space.Please check whether the script is corrcet #Script Starts here #!/usr/local/bin/perl #Program to find the disk space and to delete the older files #Checks the type of OS... (8 Replies)
Discussion started by: arunkarthick
8 Replies

9. UNIX for Advanced & Expert Users

Comparing two files and writing mismatched rows along with mismatched columns. Pointing out the mism

I got a requirement where I need to compare two files wrt to each columns and write the corresponding difference in another file along with some identification showing mismatched columns. Pointing out the mismatched columns is my main problem statement. For example we have files like: File 1 ... (8 Replies)
Discussion started by: piyush pankaj
8 Replies

10. UNIX for Beginners Questions & Answers

Disk usage monitoring and record the disk used in last 24 hour

HI I am Trying to edit the below code to send email every day with difference of disk utilized in for last 24 hours but instead getting same usage everyday. can you please help me to point out where my calculation is going wrong. Thank you. ================= #!/bin/bash TODAY="at $(date... (0 Replies)
Discussion started by: Mi4304
0 Replies
FS_MARK(1)							   User Commands							FS_MARK(1)

NAME
fs_mark - Benchmark synchronous/async file creation SYNOPSIS
fs_mark [OPTIONS] -d DIRECTORY [-d DIRECTORY ...] DESCRIPTION
fs_mark is meant to give some low level bashing to file systems. The write pattern that it concentrates on is heavily synchronous IO across multiple directories, drives, etc. OPTIONS
-h Print usage and exit. -k Keep files after each iteration. -F Run until filesystem is full. -SSyncmethod Method to be used for synchronizing changes to disk: 0: No Sync 1: fsyncBeforeClose 2: sync/1_fsync 3: PostReverseFsync 4: syncPostReverseFsync 5: PostFsync 6: syncPostFsync -Dnumber Use number subdirectories. -Nnumber Use number files in each subdirectory in round robin mode. -ddirectory Use directory. Can be specified multiple times. -llogfile Log to logfile. -Lnumber Repeat the benchmark number of iterations. -nnumber Use number of files per iteration. -pnumber Use number of total bytes file names. -rnumber Use number of random bytes in file names. -sbyte_count Use number of bytes as size of each file. -tnumber Use number of threads. -wnumber Use number (of bytes per write() syscall. AUTHORS
fs_mark was written by Ric Wheeler <ric@redhat.com>. This manual page was written by Martin Steigerwald <ms@teamix.de>, for the Debian project (but may be used by others). fs_mark: Benchmark synchronous/async file creation March 2012 FS_MARK(1)
All times are GMT -4. The time now is 02:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy