Thursday, October 24, 2013

Ubuntu 12.04 Busybox problem and Solutions

My roommate's laptop is a dual boot ubuntu and windows system. Something happened someday and Ubuntu stopped booting and ended up showing busybox prompt. It showed information that root folder '/' was not mounted so not able to boot. I searched internet for possible solutions.

I found two solutions for this problem. If you've same problem and you want to solve it, then you need Ubuntu live CD/ Bootable USB stick.

1st Solution: -
 1) Boot using live CD or USB.
 2) Select 'Try Ubuntu'
 3) Connect Internet.
 4) Open Terminal and then type

     sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update

 5) Press Enter and then Type the following

     sudo apt-get install -y boot-repair && (boot-repair &)

 6) Press Enter
 7) Open Boot repair by typing 'boot-repair' in terminal.
 8) Select "Recommended Repair" option.

Normally busybox problem will be resolved by doing this. If not resolved then it must be because of bad superblock in boot record. So we fix that using the following commands. This also needs a live CD.

2nd Solution.
1) First you need to find out in which partition Ubuntu is installed. To do that, type the following command in terminal.

   sudo fdisk -l|grep Linux|grep -Ev 'swap'

2) List all the superblocks related to this partition using the following command.

   dumpe2fs /dev/sdax | grep superblock

   Here sdax is your partition number.
   You should get output like this for the above command.
  Primary superblock at 0, Group descriptors at 1-6
  Backup superblock at 32768, Group descriptors at 32769-32774
  Backup superblock at 98304, Group descriptors at 98305-98310
  Backup superblock at 163840, Group descriptors at 163841-163846
  Backup superblock at 229376, Group descriptors at 229377-229382
  Backup superblock at 294912, Group descriptors at 294913-294918
  Backup superblock at 819200, Group descriptors at 819201-819206
  Backup superblock at 884736, Group descriptors at 884737-884742
  Backup superblock at 1605632, Group descriptors at 1605633-1605638
  Backup superblock at 2654208, Group descriptors at 2654209-2654214
  Backup superblock at 4096000, Group descriptors at 4096001-4096006
  Backup superblock at 7962624, Group descriptors at 7962625-7962630
  Backup superblock at 11239424, Group descriptors at 11239425-11239430
  Backup superblock at 20480000, Group descriptors at 20480001-20480006
  Backup superblock at 23887872, Group descriptors at 23887873-23887878

Choose the alternate superblock from the above list. Here you can choose 32768.
Now check and repair the file system using the alternate superblock chosen above.

fsck -b 32768 /dev/sda2
You should get similar output like this.
fsck 1.40.2 (12-Jul-2007)
e2fsck 1.40.2 (12-Jul-2007)
/dev/sda2 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #241 (32254, counted=32253).
Fix? yes
Free blocks count wrong for group #362 (32254, counted=32248).
Fix? yes
Free blocks count wrong for group #368 (32254, counted=27774).
Fix? yes
..........
/dev/sda2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda2: 59586/30539776 files (0.6% non-contiguous), 3604682/61059048 blocks
Try mounting the partition now using mount.
mount /dev/sda2 /mnt
Now try the following commands.
cd /mnt
mkdir test
ls -l
cp file /path/to/safe/location
If you are able make this far, then the problem is already resolved. Restart the computer
and boot normally.