LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-23-2016, 09:10 AM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Rep: Reputation: Disabled
Comparing file sizes between Linux, Windows, and Samba


On Centos 6, I used Samba to map /var/www over to Windows.

Code:
[root@devserver www]# testparm /etc/samba/smb.conf
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[www]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
        server string = Samba Server Version %v
        log file = /var/log/samba/log.%m
        max log size = 50
        client signing = required
        idmap config * : backend = tdb
        hosts allow = 127., 192.168.1.

[www]
        comment = Apache WWW Directory
        path = /var/www
        read only = No
        create mask = 0775
        force create mode = 0775
        force directory mode = 0775
Windows shows it as being 49G maximum size and 47.4G filled. Centos, however, only shows it 3.8G filled.

Code:
[root@devserver www]# du -sh /var/www
3.8G    /var/www
So, next, I just looked at a single subdirectory /var/www/test. Windows (File Explorer) shows size as 3.47M and Size on disk as 877M, however, Centos shows it as 6.5M.

Code:
[Michael@devserver www]$ du -sh ./test
6.5M    ./test
What is going on? Is it because of different file systems (as seen, Centos is using ext4, however, Windows is using NTFS). What can be done about it?

Code:
[Michael@devserver www]$ df -T ./test
Filesystem           Type 1K-blocks     Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                     ext4  51475068 46950440   1903188  97% /
 
Old 10-23-2016, 04:01 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Actually, Windows is using CIFS to access the file, not NTFS.

I would guess that there is some units conversion that doesn't match. It is possible Windows is computing sizes based on what it has/would use for metadata blocks... but that requires Windows to assume the server is using NTFS (only sorta reasonable).

Exporting /var/www to windows is not a good idea. You can introduce security issues (everything in Windows is executable), as well as pass invalid data (both ways) due to file formats being different. An HTML file on Linux uses line terminators of just a newline, and the file terminates after the number of used bytes. Windows uses CRLF line terminators, and a control-Z file terminator. Other things can also happen (invalid characters) since Windows doesn't really use UTF-8... I've had apostrophes get some really oddball character values which can make some things invalid, and there are other characters that are different too.

What is usually done is to export a middle area. Then files from that middle area are converted to Linux form and then stored in the web directories with the correct access/owner/security label (depending on what your distribution is).

This also protects Windows from data going the other way and causing problems for it (such as a hack to the web server permitting a virus or other malware being installed and accessed from Windows).

Oh, and the middle area only includes files from /var/www/html, not anything else. CGI programs from Windows will not work on Linux (though some perl/python could), it is not recommended to make such assumptions.

Last edited by jpollard; 10-23-2016 at 04:03 PM.
 
Old 10-23-2016, 04:27 PM   #3
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Original Poster
Rep: Reputation: Disabled
Thanks jpollard,

I don't know whether it is CIFS or NTFS, but left/right/bla clicking it said NTFS.

Good point about the security issues. Most (and hopefully all) are not public facing, and the only reason I implemented is to allow a windows IDE to inspect the code.
 
Old 10-23-2016, 04:41 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,948

Rep: Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530
Quote:
49G maximum size and 47.4G filled
/dev/mapper/VolGroup-lv_root ext4 51475068 46950440 1903188 97% /
Even though your sharing a single directory the numbers windows is reporting represents the entire root filesystem.

A minor point but cifs is a networking protocol so in reality linux is accessing the filesystem not windows.
 
Old 10-23-2016, 11:30 PM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
The question started by saying it was using Samba... and that mandates that the protocol used be CIFS, but to meet the protocol requirements, I think Samba has to report it as being NTFS, even though the underlying filesystem may be EXTx, XFS, Btrfs,...
 
Old 10-24-2016, 07:25 AM   #6
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 536

Original Poster
Rep: Reputation: Disabled
Thank you jpollard and michaelk,

Is the behavior I am witnessing to be expected?
 
Old 10-24-2016, 07:42 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,948

Rep: Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530
As far as I know yes.
 
  


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
Comparing Directories (diff..?) with its File's Sizes, Ignoring Filenames? mrm5102 Linux - Newbie 2 04-23-2012 09:42 AM
Large file sizes listed incorrectly in a samba share Pain++ Linux - Software 3 05-02-2008 07:01 AM
File system dosen't have expected sizes for Windows to like it RonCum Ubuntu 2 10-01-2007 09:23 AM
samba limit on file sizes about 2GB adler321 Linux - Software 7 09-22-2004 08:59 AM
Comparing file sizes using a bash script. IanChristie Programming 5 12-19-2003 11:14 PM


All times are GMT -5. The time now is 02:22 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration