LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 12-27-2012, 03:24 PM   #1
HelpMe2877
Member
 
Registered: May 2008
Location: USA
Distribution: CentOS, RHEL, Windows
Posts: 52

Rep: Reputation: 15
Directory size discrepancy


Hi all,

I have a Centos file server that I am trying to clean out a bit to make backups smaller. When I read the size of the partition while in linux it reads ~80GB used. When I read that same partition from a Windows workstation connected via SMB, it reads ~170GB used.

My question is, why would the output be so dramatically different between the two?

Thanks in advance.
 
Old 12-27-2012, 05:23 PM   #2
ShadowCat8
Member
 
Registered: Nov 2004
Location: Arcadia, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 209

Rep: Reputation: 43
Greetings,

Well, let's start with this:
  1. When you are looking at the drive itself, via 'df' from the console, you are looking at the local partitions (and remote network fileshares) that are mounted on the system.
  2. When you are looking at a network fileshare, you are looking at the size of the filesystem, which may or may not be confined to one physical partition on a drive.
  3. When looking at a linux Samba share, if the share spans more than one partition, you will see the sum (and usage) of the space of all the partitions it spans.

So, the question becomes; When you are looking at the CentOS system's Samba share, is it covering more than one partition on the local drive(s)? (e.g. If the Samba share set for /home and you have a local mount of /home/ftp, you will see the space for the root partition ('/') as well as the mounted partition ('/home/ftp') when viewing the share from outside.)

HTH. Let us know.
 
Old 01-02-2013, 10:01 AM   #3
HelpMe2877
Member
 
Registered: May 2008
Location: USA
Distribution: CentOS, RHEL, Windows
Posts: 52

Original Poster
Rep: Reputation: 15
sorry for the late reply.

no, the centos system doesn't have any mount points. it is actually the fileserver that the windows workstation mounts to.
 
Old 01-29-2013, 05:01 PM   #4
ShadowCat8
Member
 
Registered: Nov 2004
Location: Arcadia, CA
Distribution: Gentoo, Arch, (RedHat4.x-9.x, FedoraCore 1.x-4.x, Debian Potato-Sarge, LFS 6.0, etc.)
Posts: 209

Rep: Reputation: 43
Okay,

Sorry about the delay in response, but I have been real busy since the holiday season. However...

I have found the answer... and it was something that I have suspected for years, but now I have direct proof: Windows is guessing! hehe

I found the answer on this page at stackoverflow.com:
Quote:
Originally Posted by Joey @ StackOverflow.com
The easiest way to reliably get at the free disk space is using WMI. When trying to parse the output of dir you get all kinds of funny problems, at the very least with versions of Windows in other languages. You can use wmic to query the free space on a drive:
Code:
C:\> wmic logicaldisk where "DeviceID='C:'" get FreeSpace
This will output something like:
Code:
FreeSpace
197890965504
You can force this into a single line by adding the /format:value switch:
Code:
C:\> wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value


FreeSpace=197890965504
There are a few empty lines there (around three or four), though which don't lend themselves well for processing. Luckily the for command can remove them for us when we do tokenizing:
Code:
for /f "usebackq delims== tokens=2" %x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%x
The nice thing here is that since we're only using the second token all empty lines (that don't have a second token) get ignored.

Remember to double the % signs when using this in a batch file:
Code:
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%%x
You can now use the free space which is stored in the environment variable %FreeSpace%.

Getting percentages now is a little tricky since batch files only support 32-bit integers for calculation. However, you probably don't need to calculate this to the byte; I think megabytes are quite enough:
Code:
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%%x
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get Size /format:value`) do set Size=%%x
set FreeMB=%FreeSpace:~0,-6%
set SizeMB=%Size:~0,-6%
set /a Percentage=100 * FreeMB / SizeMB
echo C: is %Percentage% % free
This should work unless your volumes get larger than 20 TiB.
So, there you have it: Windows, especially through Windows Networking and/or Samba, is just guessing at sizes. If you want to be accurate from the Windows side, you can create your own batch script utilizing the WMI. Or, you can be lazy and figure that the linux system is telling you the truth (which it certainly should be) and go from there.

HTH. Let us know.

Last edited by ShadowCat8; 01-29-2013 at 05:40 PM. Reason: Offset commands and variables from the regular text
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] fdisk/cfdisk size discrepancy catkin Linux - General 11 12-18-2012 03:07 AM
Solaris 8 - file size and partition size discrepancy noir911 Solaris / OpenSolaris 1 02-10-2009 04:43 PM
directory size includes size of .. leostar_10 Linux - Newbie 4 12-03-2007 04:12 PM
hard disk size discrepancy rattlesocks Linux - Software 2 05-05-2007 08:38 AM
Hard Drive Size Discrepancy? Deathwind Linux - General 6 05-12-2004 07:50 AM


All times are GMT -5. The time now is 03:56 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration