Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, you'll probably laugh at this question but I don't know the answer so I ask:
Which is the best filesystem for a USB pendrive ?
I tried with ext4 but some of my files got corrupted so I think that ext4 is for HDDs and SSDs.
FAT32 seems to work fine, but people told me it is a bad filesystem so what should I try maybe ext3 or ext2?
Thank you in advance for the attention you'll give to this message.
If your files got corrupted, I doubt is had anything to do with the ext4 file system.
I normally leave mine at the default (usually NTFS these days), since they occasionally must be used with Windows machines. I did once format an external USB drive ext4 (not a thumb drive, but a drive is drive), as I knew it would be used only with Linux, and the drive served me well for many years until it went to that great electronics recycling system in the sky.
If your files got corrupted, I doubt is had anything to do with the ext4 file system.
I normally leave mine at the default (usually NTFS these days), since they occasionally must be used with Windows machines. I did once format an external USB drive ext4 (not a thumb drive, but a drive is drive), as I knew it would be used only with Linux, and the drive served me well for many years until it went to that great electronics recycling system in the sky.
I think it is a fliesystem problem because it only happens if I format the drive to ext4 if I format to fat32 it all works fine the drive in question is a 16GB usb2.0 pendrive. Thank you for replying.
I think it is a fliesystem problem because it only happens if I format the drive to ext4 if I format to fat32 it all works fine the drive in question is a 16GB usb2.0 pendrive. Thank you for replying.
I feel it may be worthwhile explaining this corruption and describing what happens, because I have used ext4 for years with external USB media. In fact this is the first thing I do when I insert a new USB. Ext4 is very old, just as well established as many other file systems. I'm finding it difficult to not think it instead may be user error. Are you unmounting the drive? What else are you doing with it? What types of files, are you using the drive with other types of systems?
Filesystem questions on HDD or SSD storage are one thing, but the answers are very different for a flash drive and depend on what you will use it for. I use a FAT based format because EVERYTHING reads FAT and I need to use it on different machines. I also use E2B a lot, and while NTFS can be used the performance from NTFS is truly depressing.
Keep in mind that a flash drive is, by nature, more likely to fail than any HDD or SSD device. I would keep an identical spare and use persistence on the longer lived storage.
FAT and ExFAT are more or less intended to lose data. They are leftovers from the 5.25" floppy disk days and are not appropriate with modern systems. Avoid them at all costs. Speaking of costs, in some countries they are afflicted with software patents and you must pay to use them.
You might look at using XFS for the USB stick and enable copy-on-write. EXT does not have copy-on-write. It reduces the likelihood of losing more than one file at time.
Another might be OpenZFS, but with a zpool of a single drive. However, that is just a guess and might not be practical. It would, however, keep track of file integrity.
Which operating systems do you have to use this USB stick with?
I feel it may be worthwhile explaining this corruption and describing what happens, because I have used ext4 for years with external USB media. In fact this is the first thing I do when I insert a new USB. Ext4 is very old, just as well established as many other file systems. I'm finding it difficult to not think it instead may be user error. Are you unmounting the drive? What else are you doing with it? What types of files, are you using the drive with other types of systems?
No it is not a user error because I did this operation multiple times and the files get corrupted as soon as I copy them in the ext4 flashdrive without even removing the flash drive. In the same USB formatted in FAT32 it all works fine. However not all files get corrupted (mp3 and mp4 istantly corrupted, PDF sometimes some file gets corrupted, sometimes not just randomly , Jpg and Office documents are fine and then other formats such as appimages get corrupted).
FAT and ExFAT are more or less intended to lose data. They are leftovers from the 5.25" floppy disk days and are not appropriate with modern systems. Avoid them at all costs. Speaking of costs, in some countries they are afflicted with software patents and you must pay to use them.
You might look at using XFS for the USB stick and enable copy-on-write. EXT does not have copy-on-write. It reduces the likelihood of losing more than one file at time.
Another might be OpenZFS, but with a zpool of a single drive. However, that is just a guess and might not be practical. It would, however, keep track of file integrity.
Which operating systems do you have to use this USB stick with?
I disagree exFAT is supposed to be an optimized filesystem for SD cards.
Make sure you properly unmount the drive and not just unplug it. Typically the desktop will pop up a message if the drive is busy and will not unmount. linux buffers writing so copying files happens in the background.
If you don't want DOS filesystem, ext2 can be read by quite a few O/S.
Getting a corruption to an ext4 filesystem is very rare - are you sure you unmounted it before removing it(?).
(I often create mine using ext4 with the -m 0 flag.)
Yes sure I did. I did this operation multiple times and the files get corrupted as soon as they are copied into the ext4 drive without even removing the pendrive. If I use FAT32 it all works fine. However not all files get corrupted (mp.3 and mp.4 istantly corrupted, Pictures in jpg seem to not get corrupted, Office documents are fine and finally PDF sometimes get corrupted, sometimes not.)
Yes sure I did. I did this operation multiple times and the files get corrupted as soon as they are copied into the ext4 drive without even removing the pendrive. If I use FAT32 it all works fine. However not all files get corrupted (mp.3 and mp.4 istantly corrupted, Pictures in jpg seem to not get corrupted, Office documents are fine and finally PDF sometimes get corrupted, sometimes not.)
I will echo what others have said, in that ext4 has ALWAYS worked fine for me on removable devices, from USB flash memory to removable hard drives. Have never had a problem, but I do use FAT32 on some, so I have things that Windows can read without a problem.
That said, the fact that you have some media files and PDF's corrupted could mean that you had the open while you removed the drive. Your music player could be indexing those files, or have them locked open...when you remove the USB drive, are you *POSITIVE* that it actually says it's ok to remove?? Clicking the icon does NOT always dismount if something is open.
What about EXT4 with under-provisioning? Partition it for EXT4 but at less than full capacity and leave a bit of unallocated space. There is a lot of voodoo going on under the hood in drives of all kinds, not the least in solid state ones, so as a wild guess, I would try that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.