Advertisement
AlabamaHit

Fix's some issues with hard drives not mounting.

Mar 26th, 2025
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. # Fix's some issues with hard drives not mounting.
  4.  
  5. # List all drives and extract drive paths
  6. drive_paths=($(lsblk -o NAME -n -p -l))
  7.  
  8. # Display the available drives for selection
  9. echo "Available drives:"
  10. for ((i=0; i<${#drive_paths[@]}; i++)); do
  11.     echo "[$i] ${drive_paths[i]}"
  12. done
  13.  
  14. # Prompt user to select a drive
  15. read -p "Enter the number of the drive you want to fix: " drive_number
  16.  
  17. # Validate user input
  18. if ! [[ $drive_number =~ ^[0-9]+$ ]] || [ $drive_number -ge ${#drive_paths[@]} ]; then
  19.     echo "Invalid drive number selected. Exiting..."
  20.     exit 1
  21. fi
  22.  
  23. selected_drive=${drive_paths[drive_number]}
  24.  
  25. # Display information
  26. echo "Selected drive: $selected_drive"
  27.  
  28. # Prompt for confirmation
  29. read -p "Press Enter to continue..."
  30.  
  31. # Run sudo ntfsfix on the selected drive
  32. sudo ntfsfix $selected_drive
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement