Linux not booting: Restoring bad blocks

I am one of those with multiple computers, used with varying intervals. The other day after a system reboot of my Linux desktop I couldn’t boot up the system because of a bad block. Restoring it would be crucil as I use that computer for my video editing, among other stuff. The bummer in this situation is that the monitor I get display during boot is set up in portrait mode rather than landscape, so I have to tilt my head to the right to read it.

At first I thought it was a bad kernel, since the last update I did was a kernel upgrade. Investigation quickly pointed to this bad block. Early indications also suggested /dev/hdb6 which unfortienately is my main filesystem /

Every time I booted the computer, I was thrown into recovery mode during filesystem check in boot sequence. The recovery mode login have root privileges, so no need for sudo commands. Some useful commands here are fdisk -l to get full partition list, and badblock -svn /dev/sda and e2fsck -fccky /dev/sda2 to check for bad blocks. Yes /dev/sda not /dev/sdb, since you cannot badblock check actively mounted partitions. The scan of /dev/sdb took about one hour to complete. After making sure /dev/sda is healthy, I rebooted onto a Ubuntu Live image on an USB stick.

To prepare a bootable Ubuntu Live I downloade the proper disc image from the site, and wrote it to an USB stick with dd if=ubuntu-22.04.2-desktop-amd64.iso of=/dev/sdg bs=1M status=progress and checked to see the files on the stick.

Finally I got booted onto the USB stick and selected “Try Ubuntu”, opened up a terminal and typed sudo badblocks -svn /dev/sdb. This was going to take time. 55 minutes for the first percent scanned. The full 2TB of this disk took a whooping 4 days to complete, next I did run e2fsck -fccky /dev/sdb1 on all partitions of this disk.

You can imagine my disapointment when this prosedure didn’t solve the situation. So after a shopping trip I came home with a 4TB extrernal drive so I could backup everything, in preparation for formating and repartioning of /dev/sda and /dev/sdb. 24 hours later with the backup in hand, I did a full re-partinioning and reinstall of Ubuntu. Now using LVM on all disks, and I have a working workstation again. The entire ordeal lasted me well over 2 weeks.

Add a Comment

Your email address will not be published. Required fields are marked *