How to check size of a folder in dsefs - cassandra

what is the command to check the size of the folder in dsefs?
i tried df -h it's not giving me size of a particular folder, it gives me size of the whole filesystem on all the nodes.
Thank you.

To get the size of each folder.
du -sh *
Example:
$ du -sh *
124K bin
91M clients
101M demos
4.0K ds_branch.txt
4.0K ds_timestamp.txt
4.0K ds_version.txt
7.4M javadoc
8.2M lib
412K licenses
28K LICENSE.txt
4.0K README.md
800M resources
100K tools

Related

Used size in root directory is higher than the actual consumption

used size of root directory is 13G as per the df -kh. but when i checked the individual size of the files and folder of root, the size is around 3G. where is the remaining files/folders located in root directory.
Below some outputs for reference,
[root#adair01 opt]# df -kh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 66G 13G 51G 20% /
[root#adair01 var]# du -sch /*
0 /bin
225M /boot
0 /dev
41M /etc
148K /export
156K /home
0 /lib
0 /lib64
16K /lost+found
4.0K /media
0 /misc
4.0K /mnt
0 /net
1.5G /opt
du: cannot access ‘/proc/30925/task/30925/fd/4’: No such file or directory
du: cannot access ‘/proc/30925/task/30925/fdinfo/4’: No such file or directory
du: cannot access ‘/proc/30925/fd/4’: No such file or directory
du: cannot access ‘/proc/30925/fdinfo/4’: No such file or directory
0 /proc
228K /root
42M /run
0 /sbin
4.0K /srv
0 /sys
1.1M /tmp
1.2G /usr

file created through 'truncate -s' can not get expected size

I create a file using truncate -s 1024M a.test.
I was expecting a file size of a.test to be 1024M, but not getting correct size somehow.
Below is my code.
$du -sh a.test
4.0K a.test
When using ls -l a.test, it is ok:
$ ll a.test
-rw-rw-r-- 1 work work 1073741824 Jul 12 17:26 a.test
Can some one help me out with this issue.
du tells you how much actual disk space you use. Since your file does not have any data in it, the OS will store it as a sparse file, so actual disk usage is much smaller than the size of the file. If you check it with "du --apparent-size -sh a.test", then that will report what you expected.

File bigger than the size of the partition it's in

I have a server in which there's a file with 30GB inside the partition /, although df -h lists this partition as using 11GB. Why does that happen?
[root#APPSERVER21-S1 ~]# ls -l /etc/vinter/logs/
total 2046032
-rw-r--r-- 1 root root 3920496 Sep 11 14:35 PlusoftCRMIntegration-APISILVERNODE-1.log
-rw-r--r-- 1 root root 30823671719 Sep 11 15:13 rsp.appserver21-s1.apigoldnode-1.api-oi-gold.log
-rw-r--r-- 1 root root 406061056 Sep 11 15:13 rsp.appserver21-s1.apisilvernode-1.api-oi-silver.log
[root#APPSERVER21-S1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 3.6G 0 3.6G 0% /dev
tmpfs 3.6G 0 3.6G 0% /dev/shm
tmpfs 3.6G 137M 3.4G 4% /run
tmpfs 3.6G 0 3.6G 0% /sys/fs/cgroup
/dev/mapper/vg_main-lv_root 16G 5.0G 11G 32% /
/dev/mapper/vg_dados-lv_dados 20G 33M 20G 1% /datastorage
/dev/mapper/vg_dados-lv_docker 80G 128M 79G 1% /var/lib/docker
/dev/xvdb1 497M 161M 337M 33% /boot
tmpfs 722M 0 722M 0% /run/user/0
I have a server in which there's a file with 30GB inside the partition /, although df -h lists this partition as using 11GB.
Actually, it lists this filesystem as using 5 GB, not 11 GB.
Why does that happen?
This is impossible to answer without knowing what the contents of that file are, what the filesystem is, how the file was created, and so on.
There are filesystems that perform data-deduplication. If there are blocks with identical content, they will be replaced with links, so that they only take up the space of one block. So, if there is a lot of duplicate data on the filesystem, it is easily possible that the files take up much less space on-disk than their duplicated contents.
There are filesystems that perform compression. If there is a lot of redundancy on the filesystem, then the compression will reduce the data dramatically, and it is easily possible that the files take up much less space on-disk than their uncompressed contents.
Many filesystems support sparse files. Sparse files are files with "holes" in them. The holes will be read as a long string of binary zeroes, and are technically part of the content of the file, but they are not stored on-disk.

/media directory not working anymore

I can't automount USB sticks on my linux because I have several problems with /media directory.
Here is my ls -al result on / (I just kept the media and mnt directories for you) :
total 116
drwxr-xr-x 25 root root 4096 juin 13 09:39 .
drwxr-xr-x 25 root root 4096 juin 13 09:39 ..
drwx------ 8 acarbonaro acarbonaro 8192 janv. 1 1970 media
drwxr-xr-x 2 root root 4096 avril 11 2014 mnt
This already seems strange as for other users it is often owned by root.
When I try to sudo chown root:root media it says permission denied.
When I try to sudo chown 755 media it doesn't say anything but when I ls -l after nothing has changed.
The other problem : I don't know why but the media directory is empty I can't find the user directory that used to be in it.
When I plug a USB flash drive, it cannot auto mount. I have to mount it manually in another directory, which is not impossible but clearly not handy.
Thank you for your help.
EDIT:
Here is my df -T result :
Sys. de fichiers Type blocs de 1K Utilisé Disponible Uti% Monté sur
udev devtmpfs 4015584 8 4015576 1% /dev
tmpfs tmpfs 805680 1212 804468 1% /run
/dev/sda1 ext4 115214888 9815468 99523708 9% /
none tmpfs 4 0 4 0% /sys/fs/cgroup
none tmpfs 5120 0 5120 0% /run/lock
none tmpfs 4028392 522580 3505812 13% /run/shm
none tmpfs 102400 600 101800 1% /run/user
/dev/sda2 ext4 130654772 18532260 105462572 15% /home
/dev/sdb2 vfat 14938864 218480 14720384 2% /media
EDIT:
I don't know the answer to my problem, but rebooting reset the /media directory as it was before and it works agian.
I assume the problem was that you have yanked the USB stick out of port without unmounting. UNIX is not very keen to parts of its FS disappearing. Next time, umount it first, then remove.

Disk usage - du showing different results [duplicate]

This question already has answers here:
why is the output of `du` often so different from `du -b`
(5 answers)
Closed 6 years ago.
I am confused with du command because it gives different result for files.
[root#gerrh6-05 sathish]# du -s saravana/admin/sqlnet.ora
4 saravana/admin/sqlnet.ora
[root#gerrh6-05 sathish]# du -h saravana/admin/sqlnet.ora
4.0K saravana/admin/sqlnet.ora
[root#gerrh6-05 sathish]# du -b saravana/admin/sqlnet.ora
65 saravana/admin/sqlnet.ora
[root#gerrh6-05 sathish]# du -bh saravana/admin/sqlnet.ora
65 saravana/admin/sqlnet.ora
[root#gerrh6-05 sathish]# ll -h saravana/admin/sqlnet.ora
-rw-r----- 1 root root 65 May 18 03:47 saravana/admin/sqlnet.ora
Disk usage summary return invalid result(-s gives 4 and -b gives 65), where bytes(-b) return same as ll result.
[root#gerrh6-05 sathish]# du -sh saravana/admin
114M saravana/admin
[root#gerrh6-05 sathish]# du -bh saravana/admin
12K saravana/admin/1/xdb_wallet
7.4K saravana/admin/1/pfile
7.2M saravana/admin/1/test/result/data
7.6M saravana/admin/1/test/result
7.0M saravana/admin/1/test/data
28M saravana/admin/1/test
7.2M saravana/admin/1/adump
4.0K saravana/admin/1/logbook/controlfile_trace
8.0K saravana/admin/1/logbook
4.2K saravana/admin/1/dpdump
35M saravana/admin/1
35M saravana/admin
From above which is correct size of /admin dir 35M or 114M.
Which one I should take?
Note: I am working on a linux machine where I don't have UI.Purpose why I ma looking for this is, I writing a script to taking backup. I should split folders and files based on size limit 4GB. Which one I should take to count.Because the different is large!!
From man du:
--apparent-size: print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, and the like
-b, --bytes: equivalent to --apparent-size --block-size=1
So, -b tells you how much data is stored; without it, you get how much disk space is used. Both are "correct size", for different definition of "size".

Resources