LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 04-25-2020, 07:04 PM   #1
Linux0110
Member
 
Registered: Mar 2020
Posts: 69

Rep: Reputation: Disabled
Format for usb flash drive


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.
 
Old 04-25-2020, 07:52 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,342
Blog Entries: 28

Rep: Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145
A drive is a drive.

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.
 
1 members found this post helpful.
Old 04-25-2020, 08:03 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,240

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
exfat
 
Old 04-25-2020, 08:15 PM   #4
Linux0110
Member
 
Registered: Mar 2020
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by frankbell View Post
A drive is a drive.

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.
 
Old 04-26-2020, 05:05 AM   #5
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,503

Rep: Reputation: Disabled
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.)
 
1 members found this post helpful.
Old 04-26-2020, 07:18 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by Linux0110 View Post
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?
 
Old 04-26-2020, 08:43 AM   #7
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,674

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
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.
 
Old 04-26-2020, 09:43 AM   #8
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
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?
 
Old 04-26-2020, 12:02 PM   #9
Linux0110
Member
 
Registered: Mar 2020
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
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).

Thank you for replying

Last edited by Linux0110; 04-26-2020 at 12:09 PM.
 
Old 04-26-2020, 12:03 PM   #10
Linux0110
Member
 
Registered: Mar 2020
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Turbocapitalist View Post
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?
Only linux. Thank you for replying.
 
Old 04-26-2020, 12:05 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,746

Rep: Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925Reputation: 5925
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.
 
Old 04-26-2020, 12:06 PM   #12
Linux0110
Member
 
Registered: Mar 2020
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fatmac View Post
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.)
 
Old 04-26-2020, 12:22 PM   #13
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,676

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by Linux0110 View Post
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.
 
Old 04-26-2020, 12:29 PM   #14
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,328
Blog Entries: 3

Rep: Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726Reputation: 3726
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.
 
1 members found this post helpful.
Old 04-26-2020, 07:09 PM   #15
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,342
Blog Entries: 28

Rep: Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145Reputation: 6145
I think I stand corrected. Thanks for the info.

I stumbled over an old flash drive the other day. I intend to reformat it ext4 and see what happens in the light of this thread.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cloning bootable USB flash drive onto larger flash drive - best method? cilbuper Linux - General 5 02-26-2014 09:51 AM
Can't format USB flash drive, write protection krisbitner Linux - Hardware 5 02-07-2007 03:18 PM
How to format a usb flash drive eypros Linux - Software 4 04-19-2006 01:06 PM
FLASH FLASH XP Home and Samba Fix FLASH FLASH zollodav Linux - Networking 1 02-19-2006 01:16 AM
How to format a USB flash drive? Erik_the_Red Linux - Hardware 4 08-29-2005 12:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration