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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-23-2016, 08:10 AM
|
#1
|
Member
Registered: Aug 2012
Posts: 789
Rep:
|
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% /
|
|
|
10-23-2016, 03:01 PM
|
#2
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912
|
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 03:03 PM.
|
|
|
10-23-2016, 03:27 PM
|
#3
|
Member
Registered: Aug 2012
Posts: 789
Original Poster
Rep:
|
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.
|
|
|
10-23-2016, 03:41 PM
|
#4
|
Moderator
Registered: Aug 2002
Posts: 26,176
|
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.
|
|
|
10-23-2016, 10:30 PM
|
#5
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912
|
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,...
|
|
|
10-24-2016, 06:25 AM
|
#6
|
Member
Registered: Aug 2012
Posts: 789
Original Poster
Rep:
|
Thank you jpollard and michaelk,
Is the behavior I am witnessing to be expected?
|
|
|
10-24-2016, 06:42 AM
|
#7
|
Moderator
Registered: Aug 2002
Posts: 26,176
|
As far as I know yes.
|
|
|
All times are GMT -5. The time now is 12:05 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|