How to fsck usb storage drive?

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
skylinestar
Level 1
Level 1
Posts: 23
Joined: Sun Jul 08, 2018 6:23 am

How to fsck usb storage drive?

Post by skylinestar »

I wanna check the integrity of my USB storage drive. It's an old Kingston GT100 G2.

Code: Select all

$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0 74.5G  0 disk 
├─sda1   8:1    0 39.1G  0 part 
├─sda2   8:2    0    1K  0 part 
└─sda5   8:5    0 35.5G  0 part /
sdb      8:16   1 28.7G  0 disk 
└─sdb1   8:17   1 28.7G  0 part /media/skylinestar/30F8-11F9
I run fsck but it warned me to unmount my drive first.

Code: Select all

$ sudo fsck.vfat /dev/sdb1
fsck.fat 4.1 (2017-01-24)
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
1) Remove dirty bit
2) No action
I unmounted it.

Code: Select all

$ sudo umount /dev/sdb1
And run fsck again

Code: Select all

$ sudo fsck.vfat /dev/sdb1
fsck.fat 4.1 (2017-01-24)
/dev/sdb1: 694 files, 248747/938214 clusters
It seems it doesn't do the filesystem check as I wanted because I am expecting a test result or something, but just a basic cluster info??
How do I run fsck for my usb drive?
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.
Intel Pentium E5800, Biostar G31M+ v6.1, Kingston 2x2GB DDR2-800, Galaxy GeForce GT440, Crucial M4-CT128 SSD, D-Link DFE-520TX (Rhine-III rev 8b), RT5370 WiFi, Corsair VS550, Aigo Blade 2, Dell E190S, Linux Mint 19 Mate
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to fsck usb storage drive?

Post by phd21 »

HI skylinestar,

It would help to know more about your system setup. If you run "inxi -Fxzd" and "lsusb" from the console terminal prompt, highlight the results, copy and paste them back here, that should provide enough information.

Most drive checking utilities or console terminal commands do require the drive to be checked to be "unmounted" which can be done from your file manager, or from the console terminal prompt as you did, or from the device notifier icon in your system tray

You can also use a Partition Manager editor like "gparted" to mount or unmount a drive's partitions and to check them. You may first need to install "gparted" from the Software Manager or Synaptic Package Manager. You can also burn a CD/DVD disc or USB stick of "gparted live" iso file and boot to that to check drives and their partitions.

I know the "disks" (gnome-disk or gnome-disk-utility) application can also perform the mount and unmount functions and maybe check the drive's partitions as well.

Are you sure the filesystem on that device is correct?

Code: Select all

sudo fdisk -l
or

Code: Select all

sudo lsblk -f
FYI: For a more detailed reply from the check command use -v for verbose,
You can get help information by running the command below for various "fsck" options like "vfat", or "man fsck".

Code: Select all

fsck.vfat --help
Example command I would use for this

Code: Select all

sudo fsck.vfat -a -v -V -t -p /dev/sdb1

Rescue a FAT32-formatted disk with Linux
https://www.dedoimedo.com/computers/res ... linux.html

How To Check Filesystem In Linux Ubuntu Using Command
http://sourcedigit.com/22104-how-to-che ... g-command/

How to Fix a Corrupted Windows NTFS Filesystem With Ubuntu
https://www.makeuseof.com/tag/fix-corru ... em-ubuntu/

windows - NTFS Repair - chkdsk from Linux - Unix & Linux Stack Exchange
https://unix.stackexchange.com/question ... from-linux

Hope this helps ...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
skylinestar
Level 1
Level 1
Posts: 23
Joined: Sun Jul 08, 2018 6:23 am

Re: How to fsck usb storage drive?

Post by skylinestar »

Code: Select all

skylinestar@g31m:~$ inxi -Fxzd
System:    Host: g31m Kernel: 4.15.0-24-generic x86_64 bits: 64 gcc: 7.3.0
           Desktop: MATE 1.20.1 (Gtk 3.22.30-1ubuntu1)
           Distro: Linux Mint 19 Tara
Machine:   Device: desktop Mobo: BIOSTAR model: G31M+ serial: N/A
           BIOS: American Megatrends v: 080014 date: 07/30/2010
CPU:       Dual core Pentium E5200 (-MCP-) 
           arch: Penryn rev.10 cache: 2048 KB
           flags: (lm nx sse sse2 sse3 ssse3) bmips: 10057
           clock speeds: max: 1419 MHz 1: 1247 MHz 2: 1419 MHz
Graphics:  Card: NVIDIA GF108 [GeForce GT 440] bus-ID: 01:00.0
           Display Server: x11 (X.Org 1.19.6 )
           drivers: nvidia (unloaded: modesetting,fbdev,vesa,nouveau)
           Resolution: 1024x768@60.00hz
           OpenGL: renderer: GeForce GT 440/PCIe/SSE2
           version: 4.6.0 NVIDIA 390.42 Direct Render: Yes
Audio:     Card-1 Intel NM10/ICH7 Family High Def. Audio Controller
           driver: snd_hda_intel bus-ID: 00:1b.0
           Card-2 NVIDIA GF108 High Def. Audio Controller
           driver: snd_hda_intel bus-ID: 01:00.1
           Sound: Advanced Linux Sound Architecture v: k4.15.0-24-generic
Network:   Card: VIA VT6105/VT6106S [Rhine-III]
           driver: via-rhine port: e800 bus-ID: 04:02.0
           IF: enp4s2 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:    HDD Total Size: 110.8GB (18.6% used)
           ID-1: /dev/sda model: WDC_WD800AAJS size: 80.0GB
           ID-2: USB /dev/sdb model: Ultra size: 30.8GB
           Optical: No optical drives detected.
Partition: ID-1: / size: 35G used: 13G (39%) fs: ext4 dev: /dev/sda5
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 36.0C mobo: N/A gpu: 0.0:36C
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 161 Uptime: 4 min Memory: 741.7/3944.8MB
           Init: systemd runlevel: 5 Gcc sys: 7.3.0
           Client: Shell (bash 4.4.191) inxi: 2.3.56 

Code: Select all

skylinestar@g31m:~$ lsusb
Bus 001 Device 004: ID 0781:5590 SanDisk Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 046d:c21a Logitech, Inc. Precision Gamepad
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 046d:c01d Logitech, Inc. MX510 Optical Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
phd21 wrote: Wed Aug 08, 2018 11:58 pm Are you sure the filesystem on that device is correct?
Yes, I'm sure.

Code: Select all

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1  *     2048 60062499 60060452 28.7G  c W95 FAT32 (LBA)
Intel Pentium E5800, Biostar G31M+ v6.1, Kingston 2x2GB DDR2-800, Galaxy GeForce GT440, Crucial M4-CT128 SSD, D-Link DFE-520TX (Rhine-III rev 8b), RT5370 WiFi, Corsair VS550, Aigo Blade 2, Dell E190S, Linux Mint 19 Mate
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to fsck usb storage drive?

Post by phd21 »

Hi skylinestar

I do not see anything wrong with the results of the "inxi -Fxzd" console terminal command, so that is a good thing. You are using Linux Mint 19 Mate edition.

So, what happens when you run the example console terminal command I gave you on that drive's partition? What are the results? It can take a little while to run depending on the size and content of the drive and its partition(s), so just let it finish.
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
skylinestar
Level 1
Level 1
Posts: 23
Joined: Sun Jul 08, 2018 6:23 am

Re: How to fsck usb storage drive?

Post by skylinestar »

phd21 wrote: Thu Aug 09, 2018 3:39 pm So, what happens when you run the example console terminal command I gave you on that drive's partition? What are the results? It can take a little while to run depending on the size and content of the drive and its partition(s), so just let it finish.
Can I not just run fsck.vfat /dev/sdb1 ? Is it because the option is not set, hence there's nothing?
Intel Pentium E5800, Biostar G31M+ v6.1, Kingston 2x2GB DDR2-800, Galaxy GeForce GT440, Crucial M4-CT128 SSD, D-Link DFE-520TX (Rhine-III rev 8b), RT5370 WiFi, Corsair VS550, Aigo Blade 2, Dell E190S, Linux Mint 19 Mate
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: How to fsck usb storage drive?

Post by catweazel »

skylinestar wrote: Fri Aug 10, 2018 6:20 am
phd21 wrote: Thu Aug 09, 2018 3:39 pm So, what happens when you run the example console terminal command I gave you on that drive's partition? What are the results? It can take a little while to run depending on the size and content of the drive and its partition(s), so just let it finish.
Can I not just run fsck.vfat /dev/sdb1 ? Is it because the option is not set, hence there's nothing?
It's best to take the advice you've been given.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
User avatar
mint-me
Level 3
Level 3
Posts: 146
Joined: Sat May 26, 2012 2:25 am
Location: Australia

Re: How to fsck usb storage drive?

Post by mint-me »

I had a problematic USB stick recently. Gparted did not fix it. The tool "Disks" has Check and Repair functions and that worked a treat!
Menu > Settings > Disks
Select the disk, then click on the cog icon, select "Check Filesystem", followed by "Repair Filesystem".
Debian 11 Bullseye Xfce: HP Notebook 15 BS143TU Intel® Core™ i5-8250U, 8GB DDR4 2400Mhz, Intel® UHD Graphics 620, 1366x768 15.6", 1 TB SATA
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to fsck usb storage drive?

Post by phd21 »

HI skylinestar,

Just because you ran the "fsck.vfat" console terminal command without additional command flags does not mean the command did not work only that it did not report anything back to you. Adding the "-v" command flag option (verbose) would display more information.

I have a few USB sticks formatted as "fat32" file system which I ran the command I suggested on and it provided useful details. If you run the help option for the "fsck.vfat", you will see why I chose those particular command flags. the articles I provided links for have good information in them.

And as was already stated, you can use some Linux desktop applications to check and or repair most other file systems. You might have to install extra packages (and reboot afterward) for certain file systems like Mac OS (search for "hfs") and Linux "btrfs", etc...

The really good "Minitool Partition Wizard" (MPW) works really fast and well on MS Windows filesystem formatted drives and their partitions. You can create a bootable CD/DVD disc or USB stick of MPW and boot to that to check MS Windows formatted drives and their partitions. It can be a little bit of a pain for Linux users to create the MPW CD/DVD disc or USB stick if you cannot find a download link to their ".iso" file. But, you can create it using their instructions. Years ago, before I knew how to use the console terminal commands properly, I used MPW to repair an external USB drive with 100's of gigabytes of files and folders that I could no longer access because of a power failure or because I forgot to "unmount" it first before disconnecting it which MPW fixed in only a couple minutes.

Hope this helps ...

Example: Results from running the console terminal command I suggested on a USB stick (2gb)

Code: Select all

sudo fsck.vfat -a -v -V -t -p /dev/sdc1

fsck.fat 3.0.28 (2015-05-16)
Checking we can access the last sector of the filesystem
0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt.
 Automatically removing dirty bit.
Boot sector contents:
System ID "mkfs.fat"
Media byte 0xf8 (hard disk)
       512 bytes per logical sector
      4096 bytes per cluster
        32 reserved sectors
First FAT starts at byte 16384 (sector 32)
         2 FATs, 32 bit entries
   1965568 bytes per FAT (= 3839 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 3947520 (sector 7710)
    491324 data clusters (2012463104 bytes)
62 sectors/track, 63 heads
      2048 hidden sectors
   3938304 sectors total
Starting check/repair pass.
Checking for bad clusters.
Reclaiming unconnected clusters.
Checking free cluster summary.
Starting verification pass.
Checking for unused clusters.
Performing changes.
/dev/sdc1: 1 files, 1/491324 clusters
.
gparted_PartitionManager1.jpg
.
gparted_PartitionManager_checking_fat32.jpg
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
skylinestar
Level 1
Level 1
Posts: 23
Joined: Sun Jul 08, 2018 6:23 am

Re: How to fsck usb storage drive?

Post by skylinestar »

phd21 wrote: Fri Aug 10, 2018 1:24 pm I have a few USB sticks formatted as "fat32" file system which I ran the command I suggested on and it provided useful details.

Code: Select all

sudo fsck.vfat -a -v -V -t -p /dev/sdc1
Here's roughly the result of my scan:

Code: Select all

sudo fsck.vfat -a -v -V -t -p /dev/sdb1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "android "
Media byte 0xf0 (5.25" or 3.5" HD floppy)
       512 bytes per logical sector
     32768 bytes per cluster
        60 reserved sectors
First FAT starts at byte 30720 (sector 60)
         2 FATs, 32 bit entries
   3752960 bytes per FAT (= 7330 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 7536640 (sector 14720)
    938214 data clusters (30743396352 bytes)
32 sectors/track, 64 heads
         0 hidden sectors
  60060448 sectors total
Starting check/repair pass.
...followed by my files with lots of these entries, where XXXXX is a number:

Code: Select all

Cluster 0 (XXXXX) is unreadable. Skipping it.
...then, lots of entries like these where YYYYY is a number:

Code: Select all

Checking for bad clusters.
Cluster YYYYY is unreadable.
...followed by:

Code: Select all

Reclaiming unconnected clusters.
Checking free cluster summary.
Free cluster summary wrong (787675 vs. really 13)
  Auto-correcting.
Starting verification pass.
Read 3752864 bytes at 30720:Input/output error
Tonnes of entries for bad clusters. How bad is my Sandisk 32GB thumbdrive?
If there are many defects, is it possible to tell how much is the remaining "good" storage space?
Intel Pentium E5800, Biostar G31M+ v6.1, Kingston 2x2GB DDR2-800, Galaxy GeForce GT440, Crucial M4-CT128 SSD, D-Link DFE-520TX (Rhine-III rev 8b), RT5370 WiFi, Corsair VS550, Aigo Blade 2, Dell E190S, Linux Mint 19 Mate
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to fsck usb storage drive?

Post by phd21 »

Hi skylinestar

Okay, well those results are a little unusual for me.
System ID "android "
Media byte 0xf0 (5.25" or 3.5" HD floppy)
I wonder why it shows "Android" as a system id and Media shows "HD floppy"? When you first got this Sandisk 32GB thumbdrive (usb stick) did you use it with an Android phone or Tablet computer without first formatting it with a computer as "fat32" or "NTFS"?

When checking the drive is completed, make sure it is "unmounted" and then remove it wait a few seconds and re-insert it into your computer and see if you can access its content.

As for all the bad clusters, I am not sure what that means besides "bad clusters". How old is the Sandisk 32GB thumbdrive? I am assuming there are files that you want off of this USB stick? If not, I would just reformat it. If yes, try copying the files to your hard drive or somewhere else, and then reformat it (use your file manager or "safecopy"). There are other data rescue and forensics options if needed, but that can get really involved.

FYI: Depending upon how you reformat the USB drive or any drive, that program (partition manager editor) should provide details including "bad sectors". Of course, you can just "check" the drive after reformatting for errors. If any drive has bad sectors, it could indicate a bad drive or a drive going bad and it would be best to get another one (replace it). Installing the smartmon tools (smartctl) can also help with giving information about and diagnosing regular drives.

Hope this helps ...
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
skylinestar
Level 1
Level 1
Posts: 23
Joined: Sun Jul 08, 2018 6:23 am

Re: How to fsck usb storage drive?

Post by skylinestar »

phd21 wrote: Fri Aug 10, 2018 3:04 pm Hi skylinestar

Okay, well those results are a little unusual for me.
System ID "android "
Media byte 0xf0 (5.25" or 3.5" HD floppy)
I wonder why it shows "Android" as a system id and Media shows "HD floppy"? When you first got this Sandisk 32GB thumbdrive (usb stick) did you use it with an Android phone or Tablet computer without first formatting it with a computer as "fat32" or "NTFS"?

When checking the drive is completed, make sure it is "unmounted" and then remove it wait a few seconds and re-insert it into your computer and see if you can access its content.

As for all the bad clusters, I am not sure what that means besides "bad clusters". How old is the Sandisk 32GB thumbdrive? I am assuming there are files that you want off of this USB stick? If not, I would just reformat it. If yes, try copying the files to your hard drive or somewhere else, and then reformat it (use your file manager or "safecopy"). There are other data rescue and forensics options if needed, but that can get really involved.

FYI: Depending upon how you reformat the USB drive or any drive, that program (partition manager editor) should provide details including "bad sectors". Of course, you can just "check" the drive after reformatting for errors. If any drive has bad sectors, it could indicate a bad drive or a drive going bad and it would be best to get another one (replace it). Installing the smartmon tools (smartctl) can also help with giving information about and diagnosing regular drives.

Hope this helps ...
This is the drive:
Sandisk Ultra Dual USB Drive 3.0
https://www.sandisk.com/home/mobile-dev ... sb-drive-3
Image
I don't remember how I format it though. But it works fine on my phone and computer. Definitely FAT32.

I have never fully filled up the drive with files, so I don't know the true integrity of it. However, I am able to access my files in it (approx 5 to 10GB of stuffs). A few days ago, I was trying to copy a 1GB file into it. The transfer got stuck, not moving. Smells fishy. This made me to do a fsck on it and here I am today.

Why would I need to reformat it again? What's the purpose? Doesn't fsck fix it?
Intel Pentium E5800, Biostar G31M+ v6.1, Kingston 2x2GB DDR2-800, Galaxy GeForce GT440, Crucial M4-CT128 SSD, D-Link DFE-520TX (Rhine-III rev 8b), RT5370 WiFi, Corsair VS550, Aigo Blade 2, Dell E190S, Linux Mint 19 Mate
skylinestar
Level 1
Level 1
Posts: 23
Joined: Sun Jul 08, 2018 6:23 am

Re: How to fsck usb storage drive?

Post by skylinestar »

Any info if I need to reformat again? Or is it fixed now?
Intel Pentium E5800, Biostar G31M+ v6.1, Kingston 2x2GB DDR2-800, Galaxy GeForce GT440, Crucial M4-CT128 SSD, D-Link DFE-520TX (Rhine-III rev 8b), RT5370 WiFi, Corsair VS550, Aigo Blade 2, Dell E190S, Linux Mint 19 Mate
phd21
Level 20
Level 20
Posts: 10104
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to fsck usb storage drive?

Post by phd21 »

Hi skylinestar,

Can you now access and use the drive?

If there is nothing on the USB stick that you wanted to keep, just use the Linux Mint USB Stick formatter to format the drive or a Partition Manager editor.

I would still run another check and look for bad sectors, if there are any, this USB stick might need to be replaced.
Phd21: Mint 20 Cinnamon & KDE Neon 64-bit Awesome OS's, Dell Inspiron I5 7000 (7573, quad core i5-8250U ) 2 in 1 touch screen
skylinestar
Level 1
Level 1
Posts: 23
Joined: Sun Jul 08, 2018 6:23 am

Re: How to fsck usb storage drive?

Post by skylinestar »

phd21 wrote: Tue Aug 28, 2018 10:11 am I would still run another check and look for bad sectors, if there are any, this USB stick might need to be replaced.
Here's the result. Compare to my previous check, it doesn't say anything about bad cluster or unreadable stuff. Does that mean it's ok now?

Another question:
Let's say this is a 32GB thumbdrive. If 30GB is full of bad cluster, and fsck has marked the 30GB as bad and make it unusable for future write, does the OS still detect this as a 2GB drive or still a 32GB drive? Will I get a warning if I copy a file that's bigger than 2GB into it?

Code: Select all

$ sudo fsck.vfat -a -v -V -t -p /dev/sdb1
fsck.fat 4.1 (2017-01-24)
Checking we can access the last sector of the filesystem
Boot sector contents:
System ID "android "
Media byte 0xf0 (5.25" or 3.5" HD floppy)
       512 bytes per logical sector
     32768 bytes per cluster
        60 reserved sectors
First FAT starts at byte 30720 (sector 60)
         2 FATs, 32 bit entries
   3752960 bytes per FAT (= 7330 sectors)
Root directory start at cluster 2 (arbitrary size)
Data area starts at byte 7536640 (sector 14720)
    938214 data clusters (30743396352 bytes)
32 sectors/track, 64 heads
         0 hidden sectors
  60060448 sectors total
Starting check/repair pass.
Checking for bad clusters.
Reclaiming unconnected clusters.
Checking free cluster summary.
Starting verification pass.
Checking for unused clusters.
/dev/sdb1: 1069 files, 610254/938214 clusters

Intel Pentium E5800, Biostar G31M+ v6.1, Kingston 2x2GB DDR2-800, Galaxy GeForce GT440, Crucial M4-CT128 SSD, D-Link DFE-520TX (Rhine-III rev 8b), RT5370 WiFi, Corsair VS550, Aigo Blade 2, Dell E190S, Linux Mint 19 Mate
Locked

Return to “Hardware Support”