0% found this document useful (0 votes)
48 views2 pages

Repair Flash Drive On Ubuntu Terminal

This document provides a step-by-step guide for identifying, diagnosing, and repairing a flash drive on Ubuntu using the terminal. It includes commands for checking the drive, repairing the file system, recreating the partition table, formatting the partition, and mounting the drive. The summary of commands is also included for quick reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views2 pages

Repair Flash Drive On Ubuntu Terminal

This document provides a step-by-step guide for identifying, diagnosing, and repairing a flash drive on Ubuntu using the terminal. It includes commands for checking the drive, repairing the file system, recreating the partition table, formatting the partition, and mounting the drive. The summary of commands is also included for quick reference.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Repair Flash Drive on Ubuntu Terminal

Steps to Identify, Diagnose, and Repair a Flash Drive on Ubuntu

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.

4. Recreate Partition Table (if needed)If no partitions exist or the partition


table is corrupted:
• Use parted to create a new partition table:
========================================
sudo parted /dev/sdb mklabel msdos
========================================

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
========================================

6. Format the New PartitionFormat the partition as FAT32:


========================================
sudo mkfs.vfat -F 32 /dev/sdb1
========================================

7. Verify the PartitionAfter formatting, verify the partition:


========================================
sudo parted /dev/sdb print
========================================

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

1. Identify the flash drive


========================================
sudo lsblk
sudo fdisk -l
========================================

2. Check the partition details


========================================
sudo parted /dev/sdb print
========================================

3. Repair FAT32 file system


========================================
sudo dosfsck -v -a /dev/sdb1
========================================

4. Recreate partition table (if needed)


========================================
sudo parted /dev/sdb mklabel msdos
========================================

5. Create a new partition


========================================
sudo parted /dev/sdb mkpart primary fat32 1MiB 100%
sudo parted /dev/sdb set 1 boot on
========================================

6. Format the partition


========================================
sudo mkfs.vfat -F 32 /dev/sdb1
========================================

7. Verify the partition


========================================
sudo parted /dev/sdb print
========================================

8. Mount and test the partition


========================================
sudo mount /dev/sdb1 /mnt
========================================

9. Unmount the flash drive


========================================
sudo umount /mnt
========================================

You might also like