Broken file system on USB key

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Virus-
Level 3
Level 3
Posts: 147
Joined: Sun Jan 12, 2014 1:16 pm

Broken file system on USB key

Post by Virus- »

Simply by using a USB key in Nemo and forgetting only once to eject properly might break it ... so I have to boot with Gparted, delete the partition create a new one, usually this works for restoring the functionality of my USB keys. Other times, Nemo crashes while transferring files on the USB then I need to poweroff the machine, boot into Gparted again to repair the key.

This time one of them has I/O errors.. I think the hardware is damaged..? Should I simply trash that USB key? .. but if all this is starting to break the hardware.. that's a bummer..

I know major problems are happening when transferring files between my primary mint machine and my virtual machine in virtual box. Nothing seems to work when both OS are exchanging one USB key.. I can't find a secure sequence that works all the time.. eventually Nemo will crash (in the virtual machine), I will need to power off the machine and go back in Gparted to repair the Key...

I don't really know what to do.. it seems like the USB key problem is never improving with each new revisions of Linux mint.I try my best to eject properly.. but sometimes there is not even an eject option in Nemo, it's not always there for unknown reasons,

What should I do?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
all41
Level 19
Level 19
Posts: 9498
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Broken file system on USB key

Post by all41 »

Hello Virus-

Here is how I treat misbehaving sticks. Give it a read through before proceeding.

1. Erase the boot sectors and partition table:

Copy/paste the following into a terminal:

Code: Select all

sudo shred -s $((2048*512)) -vzn0 /dev/sdX
where sdX is the device--be absolutely sure this designation is correct.


2. Make a new msdos partition table.

Open Gparted and locate that device. It should now show as "unallocated" under 'File system'
in the lower window. If you have a desktop icon for the drive right-click and choose Unmount.
Click on 'Device' in the Gparted toolbar and choose 'Create a Partition Table'. The default is msdos so
just click 'Apply'.

3. Create a new partition.

Click 'Partition' in the Gparted toolbar and choose New, then select the file system you need--
(new sticks normally come formatted as fat32).
Optional---type a name for the stick in the 'Label' field--this will be the name that appears under the icon on the
desktop and in the mount directory. (otherwise it will be a long alphanumeric name)
Click 'Add'. The info in the lower window should now be correct.
Last step is to click the right-most arrow in the Gparted icons toolbar to 'Apply all Operations'

Unplug the stick and reinsert. All should be peachy.
Everything in life was difficult before it became easy.
Hoser Rob
Level 20
Level 20
Posts: 11806
Joined: Sat Dec 15, 2012 8:57 am

Re: Broken file system on USB key

Post by Hoser Rob »

Virus- wrote: Sat Sep 01, 2018 4:43 pm Simply by using a USB key in Nemo and forgetting only once to eject properly might break it ...
I don't think that's unique to Nemo or even Linux ... forgetting to eject a drive can break its file system in any OS AFAIK. I think you should try all41's suggestions in any case.
For every complex problem there is an answer that is clear, simple, and wrong - H. L. Mencken
Virus-
Level 3
Level 3
Posts: 147
Joined: Sun Jan 12, 2014 1:16 pm

Re: Broken file system on USB key

Post by Virus- »

I tried the procedure but my key is not responding well.

This has some effect on it (the one with the I/O effors)
sudo shred -s $((2048*512)) -vzn0 /dev/sdc1

Then once in gparted, I can create the new partition table no problems, but it will give me a I/O error while formatting in Fat32. Then if I try to put files in the KEY, nemo will simply try to do it without any effect, the light will flash indefinitely while nothing is happening I don't really know how to stop that process.

So nemo is frozen, the USB key will keep flashing indefinitly, if I take the key out, it might break it. I try shutting down the machine to be able to remove the key, most of the time this won't work either then I'll power it off manually, remove the key. Then, at reboot cinnamon will be crashed. Reboot a second time then everything is back to normal in the OS.

It's pretty much the cycle I am trapped in.
User avatar
all41
Level 19
Level 19
Posts: 9498
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Broken file system on USB key

Post by all41 »

sudo shred -s $((2048*512)) -vzn0 /dev/sdc1
Not sdc1 but just sdc--if sdc is the the correct device

That is where the error is
Everything in life was difficult before it became easy.
whois1230
Level 4
Level 4
Posts: 212
Joined: Mon Aug 28, 2017 5:35 am

Re: Broken file system on USB key

Post by whois1230 »

all41 wrote: Sun Sep 02, 2018 9:20 am Hello Virus-

Here is how I treat misbehaving sticks. Give it a read through before proceeding.

1. Erase the boot sectors and partition table:

Copy/paste the following into a terminal:

Code: Select all

sudo shred -s $((2048*512)) -vzn0 /dev/sdX
where sdX is the device--be absolutely sure this designation is correct.


2. Make a new msdos partition table.

Open Gparted and locate that device. It should now show as "unallocated" under 'File system'
in the lower window. If you have a desktop icon for the drive right-click and choose Unmount.
Click on 'Device' in the Gparted toolbar and choose 'Create a Partition Table'. The default is msdos so
just click 'Apply'.

3. Create a new partition.

Click 'Partition' in the Gparted toolbar and choose New, then select the file system you need--
(new sticks normally come formatted as fat32).
Optional---type a name for the stick in the 'Label' field--this will be the name that appears under the icon on the
desktop and in the mount directory. (otherwise it will be a long alphanumeric name)
Click 'Add'. The info in the lower window should now be correct.
Last step is to click the right-most arrow in the Gparted icons toolbar to 'Apply all Operations'

Unplug the stick and reinsert. All should be peachy.
Hi, I ran sudo shred -s $((2048*512)) -vzn0 /dev/sdc and an error appeared, the output is: shred: /dev/sdc: pass 1/1 (000000)...
shred: /dev/sdc: error writing at offset 0: Remote I/O error
.Here is a detailed view: https://pastebin.com/raw/uLVxFZhN
User avatar
all41
Level 19
Level 19
Posts: 9498
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Broken file system on USB key

Post by all41 »

To completely erase the drive by writing zeros to every cell:
sudo dd if=/dev/zero of=/dev/sdX bs=1M
Here again make doubly sure that sdX is the correct drive designation

This will take a while depending on the size of the drive--after which
you will need to create a new partition table--use gparted
Everything in life was difficult before it became easy.
jglen490

Re: Broken file system on USB key

Post by jglen490 »

It can be frustrating. I've had thumb drives give me all kinds of problems with the usual software approaches. Sometimes they are just dead.

The last one I had resisted all kinds of gparted derivatives. But finally it did work to insert the thumbdrive into a USB port on an exisiting Linux box, make sure that it shows up with a dmesg command response, and then use

Code: Select all

sudo fdisk /dev/sdc
BE ABSOLUTELY POSITIVE THAT THE THUMB DRIVE IS SHOWN AS "SDC" IN THE DMESG OUTPUT. THE FDISK COMMANDS WILL DESTROY WHATEVER IS ON THE TARGET DRIVE.

While in fdisk, enter "m" (no quotes) to get a listing of fdisk commands at any point. The first command is "p" (no quotes). This will list whatever state the /dev/sdc device is is currently in. If it shows that /dev/sdc is either nonexistent or provides some other error, it may still be dead, but continue anyway. The first step will be to try and create a partition system. At the bottom of the m list it shows a section named Create a new label. At the prompt type in "g" (no quotes) and press enter. If no error is displayed then a GPT partition scheme is set up. The next step will be to create a new partition. At the prompt type in "n" (no quotes), and if you are on a Linux box it will probably automatically create a Linux partition, but if it does prompt for a file system, then enter either "20" (no quotes) for a Linux filesystem or "11" (no quotes) for a basic Windows system. Either will work for a thumb drive used to install Linux. It will prompt you for some default info, so just press enter for those. Then press enter. Again enter "p" (no quotes), to see if it made something like this

Code: Select all

Disk /dev/sdc: 14.6 GiB, 15703474176 bytes, 30670848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1137b7ff

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdc1        2048 30670847 30668800 14.6G  b W95 FAT32

It won't be exactly that, but this shows the steps. Then enter "w" (no quotes) to write the results to the thumb drive and exit fdisk.

If it fails, then consider the thumb drive a very small paper weight ....

In any case, you can eject the thumb drive at the command line with

Code: Select all

sudo eject /dev/sdc
jglen490

Re: Broken file system on USB key

Post by jglen490 »

So if you don't want to go through all that, try another thumb drive to use for the install :)
vansloneker

Re: Broken file system on USB key

Post by vansloneker »

Just for sure, you may want to perform above actions on the USB stick from a live CD/DVD/USB with all internal hard disks disconnected by unplugging the sata cable.
whois1230
Level 4
Level 4
Posts: 212
Joined: Mon Aug 28, 2017 5:35 am

Re: Broken file system on USB key

Post by whois1230 »

all41 wrote: Tue Nov 20, 2018 8:18 pm To completely erase the drive by writing zeros to every cell:
sudo dd if=/dev/zero of=/dev/sdX bs=1M
Here again make doubly sure that sdX is the correct drive designation

This will take a while depending on the size of the drive--after which
you will need to create a new partition table--use gparted
It still didn't work: https://pastebin.com/raw/00jkRae9
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1368
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: Broken file system on USB key

Post by ricardogroetaers »

On removable media (flash drive, memory card) use the following sequence in File Manager:
1st dismantling
2nd eject
3rd remove physically
Locked

Return to “Beginner Questions”