LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Comparing file sizes between Linux, Windows, and Samba (https://www.linuxquestions.org/questions/linux-newbie-8/comparing-file-sizes-between-linux-windows-and-samba-4175592028/)

NotionCommotion 10-23-2016 08:10 AM

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


jpollard 10-23-2016 03:01 PM

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.

NotionCommotion 10-23-2016 03:27 PM

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.

michaelk 10-23-2016 03:41 PM

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.

jpollard 10-23-2016 10:30 PM

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

NotionCommotion 10-24-2016 06:25 AM

Thank you jpollard and michaelk,

Is the behavior I am witnessing to be expected?

michaelk 10-24-2016 06:42 AM

As far as I know yes.


All times are GMT -5. The time now is 01:09 PM.