Announcement

Collapse
No announcement yet.

Empty Folder size = 0 KB in Dolphin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Empty Folder size = 0 KB in Dolphin

    Hello,
    I created an empty folder and I right click and check its properties. It says the size is 4 KB.
    It is my understanding that folders take up space on ext4 formatted partitions.


    Is there a way I can make Dolphin not count folder sizes? I want it to show 0 KB.



    #2
    Folder size and file size are not the same. If you understand disk space and how files are stored you'd realize that you're mixing and matching two different things. There are no files in the folder, so the file size would be 0 bytes. However, the directory DOES take up space in the file table (depends on what file system you're using ext4/reifer fs/BTRFS or whatever file system you chose when installing. You may want to read up here to better understand the underlying issues. Hope that helps.
    Challenges are what that keeps us from the borderline of boredom in life's journey. Linux user no. 419401 currently running Kubuntu 24.04
    _______________________________________________
    Current System: Beelink Mini PC, AMD Ryzen 7 5800H 8 Core(Up to 4.4GHz), 32GB DDR4 RAM 1TB NVME M.2 SSD, SER5 MAX Mini Desktop Computer with TCL BeyondTV5 serving as my monitor. ​

    Comment


      #3
      OK, is there a way to see the file size of a folder from the Properties?

      Comment


        #4
        Originally posted by vanadiumboy View Post
        OK, is there a way to see the file size of a folder from the Properties?
        I think you may have missed the point of the previous comment. "Folders" take zero "file" space. Generally - depending of the file system - folders consume meta data space and files consume data space. Dolphin reports data space, so a folder uses zero data space.

        In Dolphin, if you right-click on a folder and select properties, you should see the number of sub-folders and files contained in that folder along with a total amount of data bytes used. Click image for larger version  Name:	Screenshot_20240820_205552.jpg Views:	0 Size:	20.0 KB ID:	681891

        Please Read Me

        Comment


          #5
          Originally posted by oshunluvr View Post

          I think you may have missed the point of the previous comment. "Folders" take zero "file" space. Generally - depending of the file system - folders consume meta data space and files consume data space. Dolphin reports data space, so a folder uses zero data space.

          In Dolphin, if you right-click on a folder and select properties, you should see the number of sub-folders and files contained in that folder along with a total amount of data bytes used. Click image for larger version Name:	Screenshot_20240820_205552.jpg Views:	0 Size:	20.0 KB ID:	681891
          OK, I will upload what my Dolphin shows.
          Why does it show 12 KB?

          BTW, in this case 1024 B = 1 KB
          Attached Files
          You may only view thumbnails in this gallery. This gallery has 1 photos.

          Comment


            #6
            Originally posted by oshunluvr View Post

            I think you may have missed the point of the previous comment. "Folders" take zero "file" space. Generally - depending of the file system - folders consume meta data space and files consume data space. Dolphin reports data space, so a folder uses zero data space.

            In Dolphin, if you right-click on a folder and select properties, you should see the number of sub-folders and files contained in that folder along with a total amount of data bytes used. Click image for larger version Name:	Screenshot_20240820_205552.jpg Views:	0 Size:	20.0 KB ID:	681891
            yes, it seems file system specific.

            Ext4 on the left, btrfs on the right. Both empty directories with no hidden files, even .directory ones.
            Click image for larger version  Name:	Screenshot_20240820_213915-1.png Views:	0 Size:	292.4 KB ID:	681896

            So, it isn't Dolphin, it IS the file system.
            The bottom section is ext4, with empty dirs showing 4096 (aka 4Kib)

            Code:
            claydoh@cubist:~/Downloads$ ls -la
            total 348
            drwxr-xr-x 1 claydoh claydoh 146 Aug 20 21:44 .
            drwxr-x--- 1 claydoh claydoh 1030 Aug 20 18:00 ..
            -rw-rw-r-- 1 claydoh claydoh 341615 Aug 11 08:09 2022_Absentee_App.9721_2.pdf
            drwxrwxr-x 1 claydoh claydoh 0 Aug 20 21:34 kromey
            drwxrwxr-x 1 claydoh claydoh 0 Aug 17 22:15 'New Folder'
            drwxrwxr-x 1 claydoh claydoh 504 Jul 19 03:06 'Pixel 7'
            -rw-rw-r-- 1 claydoh claydoh 350 Aug 18 22:59 rxlist
            lrwxrwxrwx 1 claydoh claydoh 34 Aug 20 2023 screenshots -> /home/claydoh/Pictures/screenshots
            -rwxr-xr-x 1 claydoh claydoh 1246 Aug 16 01:43 stuff
            
            claydoh@cubist:~/Downloads$ ls -la /media/claydoh/Extras
            total 12
            drwxrwxrwx 4 root root 4096 Aug 20 21:36 .
            drwxr-x---+ 1 root root 44 Aug 20 18:00 ..
            drwxrwxr-x 2 claydoh claydoh 4096 Aug 20 21:36 'New Folder'
            drwxrwxr-x 2 claydoh claydoh 4096 Aug 17 22:20 virts​
            This seems to be from the fact that ext4 uses a default minimum block size of.....4096 bytes.
            https://askubuntu.com/questions/1868...4096-bytes-4-k and about 6 million other sources asking about this. I noticed this many aeons ago, found the answer, then promptly forgot about it.

            Last edited by claydoh; Aug 20, 2024, 08:07 PM.

            Comment


              #7
              Originally posted by claydoh View Post


              So, it isn't Dolphin, it IS the file system.
              The bottom section is ext4, with empty dirs showing 4096 (aka 4Kib)
              It is Dolphin because it does not distinguish between a folder and a file.

              If Dolphin were to be coded like this

              Code:
              for(thing that is in folder X)
              {
                   if(thing is a file)
                   {
                        CountTheBytes+=Bytes_of_this _file;
                   }
              }
              Then the properties of folder X would be Size = 0 KB if there are no files in folder X. Even if there are hundreds of empty folders in folder X, Size = 0 KB
              Looks like Dolphin is also counting the size of folders and for each folder, it adds 4 KB.​

              Comment


                #8
                I would bet it has to do with how EXT4 stores metadata vs. other file systems. I think an empty folder would still use one block of space on EXT4 vs. BTRFS where metadata is a separate block group. Maybe, anyway. hmmm, maybe a test is in order...

                Please Read Me

                Comment


                  #9
                  OK, totally simple test: I took a thumb drive, made 2 partitions of 1000MiB each. Formatted 1 with EXT4 and 2 with BTRFS:

                  Code:
                  Filesystem         Size  Used Avail Use% Mounted on
                  /dev/sde1          966M   24K  900M   1% /media/stuart/0449f3c5-70b8-4faf-a2a4-2d8c5b7f3673
                  /dev/sde2         1000M  5.8M  883M   1% /media/stuart/a7f5745f-f40f-4c17-8782-e660ffbe51f8
                  ​
                  Then I made 1000 folders on both partitions:
                  Code:
                  $ for n in {1..1000}; do sudo mkdir /dev/sde1/$n; done
                  $ for n in {1..1000}; do sudo mkdir /dev/sde2/$n; done
                  Resulting in these sizes:
                  Code:
                  Filesystem         Size  Used Avail Use% Mounted on
                  /dev/sde1          966M  4.0M  896M   1% /media/stuart/0449f3c5-70b8-4faf-a2a4-2d8c5b7f3673
                  /dev/sde2         1000M  6.5M  883M   1% /media/stuart/a7f5745f-f40f-4c17-8782-e660ffbe51f8
                  ​


                  So EXT4 shows space used for folders - 4M - which I think works out to 4096/1000 or 4kb per folder.
                  BTRFS shows no data space used for folders because it reserves metadata space before the folders were created.

                  Interestingly, I went back and deleted all the folders and got this:

                  Code:
                  /dev/sde1          966M   40K  900M   1% /media/stuart/0449f3c5-70b8-4faf-a2a4-2d8c5b7f3673
                  /dev/sde2         1000M  5.8M  883M   1% /media/stuart/a7f5745f-f40f-4c17-8782-e660ffbe51f8
                  ​
                  So EXT4 did not give back all the folder space

                  I did not take the time to remove the reserved space that EXT4 created by default. Not sure if that would make a difference or not.
                  Last edited by oshunluvr; Aug 22, 2024, 01:11 PM.

                  Please Read Me

                  Comment


                    #10
                    For kicks I did it again, this time releasing the reserved space, which added 50M to total available space, but the results were the same 24k used before folder creation and 40K used after creation+deletion. Odd...

                    Please Read Me

                    Comment


                      #11
                      This is nothing new.
                      You'd think after over a quarter century of my Linux usage that all the file managers would have coded things to both detect the the file system being used, as well as detecting every empty directory, then "lying", in essence. Plus somehow keeping the this updated as you browse, as well as having the disk space usage reporting match this(more lying) somehow. Dynamically.

                      If it were as simple as some math, it would have been done ages and ages ago. I haven't found much reference on why they don't lie, other than it may be computationally expensive.
                      https://gitlab.xfce.org/xfce/thunar/-/issues/460

                      https://github.com/linuxmint/nemo/issues/2186

                      Fact is, a folder on ext3/4 does take up, or is assigned, 4096 bytes by the file system

                      Plus, where does dolphin actually show this value? I only see it in an individual directory's properties, and can't see any other place where this might be added. But I didn't fall into another rabbit hole dig in for a deeper dive

                      Comment


                        #12
                        Originally posted by claydoh View Post
                        This is nothing new.
                        You'd think after over a quarter century of my Linux usage that all the file managers would have coded things to both detect the the file system being used, as well as detecting every empty directory, then "lying", in essence. Plus somehow keeping the this updated as you browse, as well as having the disk space usage reporting match this(more lying) somehow. Dynamically.

                        If it were as simple as some math, it would have been done ages and ages ago. I haven't found much reference on why they don't lie, other than it may be computationally expensive.
                        https://gitlab.xfce.org/xfce/thunar/-/issues/460

                        https://github.com/linuxmint/nemo/issues/2186

                        Fact is, a folder on ext3/4 does take up, or is assigned, 4096 bytes by the file system

                        Plus, where does dolphin actually show this value? I only see it in an individual directory's properties, and can't see any other place where this might be added. But I didn't fall into another rabbit hole dig in for a deeper dive
                        I don't see why they would need to detect the file system that is used.
                        Dolphin or Thunar or whatever are just apps, just like the apps that I write.

                        I already do this kind of thing in my apps:
                        https://sourceforge.net/projects/fil...caseextension/
                        (Not that I want to advertise. Let me know if this is against the rules and I'll remove the link.)

                        This is how I do it

                        Code:
                        pdirIterator=new QDirIterator(pfolderPath, QDirIterator::Subdirectories);
                        while(pdirIterator->hasNext())
                        {
                             fileInfo=pdirIterator->fileInfo();
                             if((fileInfo.isDir()==false)&&(fileInfo.isSymLink()==false))
                             {
                                    Do it
                             }
                        }


                        I’m sure that code hasn’t blown up anyone’s hard drive or melted any CPUs.

                        If it is a folder, then don’t count the size.
                        If it is a file, then count the size and add it to the total.

                        Comment

                        Working...
                        X