# [Solved] FS for USB-flash?

## Perfect Gentleman

I got Gentoo installed on USB-flash. USB is formatted in XFS. But lately FS becomes corrupted after doing nothing. Really, I did nothing for a couple of days, and today's morning system became un-pingable.

What's the best FS for headless installation on USB-flash?

or it's bad USB-flash?Last edited by Perfect Gentleman on Thu May 04, 2017 10:40 am; edited 1 time in total

----------

## NeddySeagoon

Perfect Gentleman,

USB Flash is slow since it rarely supports discard or wear levelling.

Journaled filesystems are bad for Flash too.

I use ext4 with the journal turned off on microSD cards, they are Flash.

----------

## Perfect Gentleman

I use journaled FS because of power cut which happens rather often.

I used EXT4 without journal couple of years ago, and it was completely destroyed after two power cuts.

----------

## NeddySeagoon

Perfect Gentleman,

By default, ext4 only journals metadata.  A journal replay makes the filesystem metadata self consistent but says nothing about any user data that may be stored on the filesystem.

You can journal everything but that means updates take two writes, once to the journal then to the filesystem.

Journaling is not a magic bullet. You can still corrupt a filesystem with a power cut. 

Its usually faster to do a journal replay that a full fsck.

For power cuts you need a UPS, so you can get a clean shut down.

----------

## szatox

It's a case where I'd consider f2fs or perhaps some other so called "logging" filesystem. Something that doesn't really have any area for data, and instead stores everything in journal.

They have that nice property that it creates a new point in time view of the filesystem first and tags older views as dirty later, so your previous good version can never be partially overwritten, which in turn makes room for rolling back to the previous known good version in case of failure. Assuming this feature actually works  :Smile: 

----------

## Perfect Gentleman

there was another blackout. USB FS had lots of errors corrected, but system is bootable and functioning.

----------

## Perfect Gentleman

USB-flash died today.

----------

## NTU

Microsoft says exFAT works great for SSDs and other flash media. Seems legit.

----------

## NeddySeagoon

NTU,

exFAT on Linux is depends on FUSE.  That makes it slow because of all the context switches.

----------

## chithanh

USB flash drives sometimes have a "pretend to write successfully, but read only garbage" failure mode.

I have one USB flash drive that does precisely this. Copying small files is usually no problem, but copying a large file like an ISO image will cause parts of it to be corrupted (rsync told me it was about 300 KiB corrupted of a 4 GiB file).

See if your USB flash drive corrupts data by filling it with large files, then "echo 3 > /proc/sys/vm/drop_caches", then comparing sha1sum.

 *NeddySeagoon wrote:*   

> Journaling is not a magic bullet. You can still corrupt a filesystem with a power cut.

 Not if all parts of your storage observe write barriers correctly.

----------

