3

I ran into the ecryptfs bug where files with long filenames don't get written (because of the prefix that ecryptfs adds to the original filenames, thus extending their length). So I was wondering if there was a way to create a filesystem (hopefully ext4) in a file, inside an ecryptfs mount. Thus, ecryptfs encrypts the file without filename length trouble. However, I don't want to specify a static size for the ext4 filesystem, I want it to grow (or shrink) as I add (or remove) files. I have a feeling this isn't possible, but is there a solution to this problem? I cannot change the filenames that are too long.

  • You can read up on LUKS/cryptsetup and LVM. Maybe they can help you solve your problem in a different way. – Lucas Mar 24 '16 at 19:27
  • Are you using filename encryption? Do you have a link for that bug? I don't think any regular filesystems (meant for a partition and useable in a container file) can dynamically resize themselves. That's one of the big advantages to a system like eCryptfs or EncFS, they only take up a little more space than the files themselves. – Xen2050 Mar 27 '16 at 4:16
  • @Xen2050 bugs.launchpad.net/ecryptfs/+bug/344878 – insaner Mar 27 '16 at 14:36
  • How much more filename characters do you need? EncFS might give you about 50 more (about 190 total, if your host filesystem limit is 256) – Xen2050 Mar 28 '16 at 7:19
3

As @Lucas mentioned, LUKS would be preferable to eCryptfs for this, but yes, you can rather easily resize an ext4 image file. You can use truncate -s xxx file to change the size of the file, then losetup -c /dev/loopX to refresh the loop driver's idea of its size ( or unmount and remount it ), then resize2fs to grow it. To shrink, it must be unmounted and you resize2fs prior to reducing the size of the file. Just be careful you don't shrink the file smaller than resize2fs set the size of the filesystem to.

  • Thanks for the answer, however I am looking for something that can "dynamically" resize the partition, in other words, it resizes automatically as I add more files, like shrinkwrap. – insaner Mar 24 '16 at 23:29
  • @insaner, you either have to live with the name limits of eCryptfs, or manually resize a proper filesystem when you need to adjust your free space. – psusi Mar 24 '16 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.