Repair Flash Drive On Ubuntu Terminal
Repair Flash Drive On Ubuntu Terminal
1. Identify the Flash DriveUse lsblk or fdisk to list all storage devices:
========================================
sudo lsblk
sudo fdisk -l
========================================
Find the flash drive (e.g., /dev/sdb).
2. Check Partition and File SystemUse parted to check the partition and file system
details:
========================================
sudo parted /dev/sdb print
========================================
If it shows no file system or an error, you need to repair or reformat the drive.
3. Check and Repair the File System (FAT32)If your drive is formatted as FAT32 and
has file system errors, you can use dosfsck to repair it:
========================================
sudo dosfsck -v -a /dev/sdb1
========================================
If you get an error like "Logical sector size is zero," it usually means the file
system is severely corrupted, and you may need to recreate the partition.
5. Create a New PartitionCreate a primary partition using the full space on the
flash drive:
========================================
sudo parted /dev/sdb mkpart primary fat32 1MiB 100%
========================================
Set the partition as bootable:
========================================
sudo parted /dev/sdb set 1 boot on
========================================
8. Mount and Test the Flash DriveMount the partition to ensure it's working:
========================================
sudo mount /dev/sdb1 /mnt
Check the contents or test the drive as needed.
========================================
9. Unmount the Flash DriveOnce done, safely unmount the flash drive:
========================================
sudo umount /mnt
========================================
###################################################################################
###################
Summary of Commands