*Edit: I have figured out how to use BTRFS and enable what it calls “transparent file compression”, and I’m going to use that on most of my old storage devices. The only problem I’m having is that I want to use F2FS on my oldest storage device, as BTRFS takes up too much space on the device and I was told by multiple users that F2FS also supports transparent file compression, but I can’t get files to compress and I’m not getting any error messages to try and fix it. Based on what the documentation says, I’m supposed to do something like this:

sudo mkfs.f2fs -f -O extra_attr,inode_checksum,sb_checksum,compression /dev/mmcblk0p1
sudo mount -o compress_algorithm=zstd,compress_extension=* /dev/mmcblk0p1 '/home/j/mountpoint/128mb'
chattr -R +c '/home/j/mountpoint/128mb'

The device will mount like this but files aren’t compressing when added, nor are they compressed if using the last command after they’ve been moved.*

I’m rewriting the old portion for clarification:

In Windows, there’s a file/folder option called “Compress contents to save disk space”. What it does is it compresses the files, as the name suggests, but leaves them accessible as though they aren’t. This doesn’t really have much of a benefit on newer storage devices but on older storage devices, in addition to saving space, it allows files to potentially read faster.

As I have some old storage devices that I want to run games from, I think this will be a great option to have if I could find something similar for Linux. I tried looking online myself but search engines are terrible and I couldn’t find anything though them. So, I decided to post about this here, to see if anyone knows of anything I could try.

  • vortexal@lemmy.mlOP
    link
    fedilink
    arrow-up
    4
    ·
    13 hours ago

    It’s 128 MB, brtfs needs at least 256 MB. Also yes, I’m aware that I’d need to install something to use zfs but I don’t know where to look to find out what I’d need to install.

    • hendrik@palaver.p3x.de
      link
      fedilink
      English
      arrow-up
      6
      ·
      13 hours ago

      Huh. My computer allows me to format a 128MB image file with brtfs. It won’t do it at 64MB though.

        • hendrik@palaver.p3x.de
          link
          fedilink
          English
          arrow-up
          1
          ·
          13 hours ago

          Good call. Seems minimum for ZFS is three quarters of a Gigabyte, anyway. And definitely not made for what OP does 😆

      • vortexal@lemmy.mlOP
        link
        fedilink
        arrow-up
        2
        ·
        13 hours ago

        How are you trying to format the device? I got that error message when using gparted.

        • hendrik@palaver.p3x.de
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          12 hours ago
          truncate -s 128M fs.img  
          parted fs.img  
            mklabel gpt  
            mkpart primary btrfs 1MiB 100%  
            quit  
          sudo losetup --find --partscan --show fs.img  
          sudo mkfs.btrfs /dev/loop0p1  
          

          You should be able to skip the loop device stuff and work on an actual device instead. Seems to me the limit is somewhere between 64M and 128M.

          Edit: But as edinbruh said, maybe try f2fs if it’s a flash device, that’s probably a bit more lightweight?! And since I don’t know what you’re doing… If it’s embedded stuff and you’re alright with read-only, you might want to use squashfs.

          • vortexal@lemmy.mlOP
            link
            fedilink
            arrow-up
            3
            ·
            12 hours ago

            I got brtfs working on a different storage device but I can’t tell if I set it up properly or not. I’m using the documentation that another user posted but it’s a bit confusing to me and I need to test it more.

            For my 128 MB sd card, I am trying f2fs because that’s working. It does seem to write much faster than it did with ext4 but it seems to take up more space and it now has about 25% less free space, and it doesn’t seem to compress files. I’ll have to do more testing before I determine whether this what I go with or not.

            As for squashfs, I probably don’t want that.

            • hendrik@palaver.p3x.de
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              12 hours ago

              Remember to enable compression. Usually the Arch Wiki is a great resource to learn stuff: https://wiki.archlinux.org/title/F2FS

              And don’t forget to back up your data if you’re messing around with your computer. One typo with the device names is enough to accidentally delete your harddrive.

              • vortexal@lemmy.mlOP
                link
                fedilink
                arrow-up
                1
                ·
                11 hours ago

                I figured out what I did wrong but now I’m getting a different error. It’s saying “Error: Wrong features compress_algorithm=zstd” even though the page you linked to specifies that that should be possible.

              • vortexal@lemmy.mlOP
                link
                fedilink
                arrow-up
                1
                ·
                12 hours ago

                I tried to enable compression using the command they provide but it fails with an error saying “Error: Failed to get the device stat!”. Also, to make sure that I’m using the correct command line, how would I change the command they give to enable zstd as the compression method for all files.

                • hendrik@palaver.p3x.de
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  11 hours ago

                  I haven’t tried it. But looks to me you need to add “compression” when formatting it. And then later when mounting, you’d add options like compress_algorithm=zstd,compress_extension=*

                  • vortexal@lemmy.mlOP
                    link
                    fedilink
                    arrow-up
                    2
                    ·
                    edit-2
                    11 hours ago

                    I actually figure out the problem, I was actually supposed to just enable compression and then use the command when mounting. Only problem is, it’s not compressing the files even though I mounted it with zstd enabled. I know this because I’m using a file that’s slightly larger than the free space but it’s still giving errors about not having enough space.

    • edinbruh@feddit.it
      link
      fedilink
      English
      arrow-up
      5
      ·
      13 hours ago

      If it’s a flash memory (sd card, usb stick, ssd, etc), you could try f2fs, it’s very light, and it supports compression and is meant specifically for that kind of devices (well, more for ssds).

      But judging your experience from your comments, I suggest you don’t delve into niche filesystems until you have more experience with Linux, especially for something like 128MB. I especially suggest you avoid zfs for now.

      • vortexal@lemmy.mlOP
        link
        fedilink
        arrow-up
        2
        ·
        12 hours ago

        It is an sd card and I did just format it to f2fs but how do I enable the compression? It does seem much faster that ext4 but it seems to also take up more space on the sd card, as I’ve lost about 25% of the free space after formatting it, so I’d like to enable the compression.

        As for zfs, I have been using Linux for over a few years at this point but I’ve mostly been avoiding some of the more complicated stuff. So if it is more complicated than what I originally thought, then I’ll avoid that for now as well.

        • edinbruh@feddit.it
          link
          fedilink
          English
          arrow-up
          3
          ·
          edit-2
          11 hours ago

          So, first of all, there is no gui for this, that I’m aware of, so you will have to do it from terminal. Second, on f2fs, compression works that you don’t enable compression for a folder, instead you mount the drive with compression enabled, and new files will be compressed automatically.

          So what you need is to set up your disk to be mounted with compression. There are many paths you can follow here. If you want your drive to be (almost) permanently connected, the easiest way is to use “/etc/fstab”. If you want to use it as a regular SD card, mounting and ejecting it from your file explorer etcetera, then you should go here and learn how to have udisks2 mount your device with compression, which should be what your desktop environment uses to mount drives. I suggest you set that up for your specific device, and not for all f2fs devices. Good luck.

          You can look up other useful f2fs options on the arch wiki. I suggest you add all those options that reduces writes to your disk and improve durability (like lazytime).

          You should use zstd as compression algorithm, and because this is a slow and small drive, you can crank up the level of compression.

          If you manage to pull this off, the next time you install a (bigger and faster) drive on your pc, you can try to look into zfs.

          • vortexal@lemmy.mlOP
            link
            fedilink
            arrow-up
            1
            ·
            11 hours ago

            I read the page you linked to but I have no idea what I’m supposed to do with it. If it’s talking about using the “mount” command, I’ve already used that and even though I specifically enabled zstd as the compression method, files aren’t being compressed. I know this because I’m using a file that’s slightly larger than the free space but it’s still giving errors about not having enough space.

            • edinbruh@feddit.it
              link
              fedilink
              English
              arrow-up
              4
              ·
              edit-2
              10 hours ago

              That is not a good method for testing. Maybe the filesystem still requires new files to be smaller than free space. Or maybe the file could be not really compressible, for example, you won’t be able to compress random data. You also won’t compress already compressed data, like videos.

              You could write a real text file of some kB and then check the compression ratio with something like “compsize”.

              The mount command mounts the disk with the options you give to it but only once. Now, because you don’t want to manually run mount everytime you use your disk, you must set it up so it is always mounted with the options you want. Udisks2 is one of the tools for that.

              P.s. apparently compsize is btrfs only. You can use “du” with and without --apparent-size and check the differenze

              • vortexal@lemmy.mlOP
                link
                fedilink
                arrow-up
                2
                arrow-down
                1
                ·
                10 hours ago

                I used a folder full of smaller files and it still isn’t compressing them. I’ve tried everything I can find or was told to do with f2fs but I cannot for the life of me, get files to compress. Btrfs works and files are compressing but it takes up so much space on the sd card.

                • edinbruh@feddit.it
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  2 hours ago

                  I have a similar setup and it works. So you are probably doing something wrong, I don’t know what. Maybe look at dmesg for a filesystem error.