Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a flash drive which is FAT32 formatted. I want to put a linux filesystem on the drive inside a file. I know I can do this by creating a file and formatting is with ext3 (or any other file system) and then mounting it with the -o loop option. What I would like is that the above filesystem be compressed. Essentially something like a read-write squashfs.

Is there something that exits that I can use? Additional bonus if the file can be stored as sparse, i.e. the file re-sizes as data is written or deleted.

share|improve this question

migrated from serverfault.com Dec 1 '11 at 0:34

This question came from our site for professional system and network administrators.

    
I don't know enough to put this as an answer but looks like squashfs could be what you are looking for. –  phunehehe Dec 1 '11 at 2:37

2 Answers 2

up vote 4 down vote accepted

Write a .7z, .tgz, .zip or other compressed archive file.

Bonus: you can read it anywhere.

Downside: it can be slow if you have a lot of files.

Use avfs to access files inside the archive transparently.

mountavfs
mount /dev/my_flash_drive /media/flash0
rsync -au mydata/foo/ ~/.avfs/media/flash0/archive.tgz\#/foo/
umount /media/flash0
share|improve this answer
    
ooh, that's very nice. i'm going to be using that. –  ixtmixilix Dec 1 '11 at 11:08

BTRFS has a compression mode built-in, but with the correct mount option. And the file must be at the final size. As BTRFS can resize the partition on-the-fly it could be possible to hack something for increasing the file, but I never tried and I won't try it.

But the best way would be to buy a bigger flash drive than hacking around with compression.

share|improve this answer
    
Thanks a lot. Part of the problem is that I am limited by the 2GB file size of FAT32. Maybe its time to put NTFS on the flash drive. –  Doc Dec 1 '11 at 3:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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