Ubuntu – Stuck in initramfs, need to recover data

data-recoveryUbuntu

I'm running Ubuntu LTS 10.4 on Virtualbox. Out of nowhere, I'm unable to boot into my VM and I get stuck in initramfs.

I have another Ubuntu VM that I can mount the virtual HD to. I just want to copy over my files so I do not lose them.

I attached my virtual HD to /dev/sdb1 and did:

sudo mount /dev/sdb1 /mnt

Yet when I ls /mnt, my home directory is nowhere to be found. How can I get access to the original file system?

Best Answer

Probably your home directory is in another partition of the disk ( or even on another disk ). Try first with fdisk -l. That should return something similar to:

Disk /dev/sdb: 145.9 GB, 145999527936
bytes 255 heads, 63 sectors/track,
17750 cylinders Units = cylinders of
16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1           7       56196   83  Linux
/dev/sdb3             263         517     2048287+  83  Linux
/dev/sdb4             518       17750   138424072+   f  W95 Ext'd (LBA)
/dev/sdb5             518         900     3076416   83  Linux
/dev/sdb6             901        1283     3076416   83  Linux

Then try mounting every device on the list one by one and check the files on that filesystem until you find your home partition:

sudo mount /dev/sdb1 /mnt
ls -la /mnt

Are the files from your home directory?. If not continue:

sudo umount /mnt
sudo mount /dev/sdb3 /mnt
ls -la /mnt

Repeat until bingo.


In case of LVM the approach is different.

  1. Mount your / partition ( the one you identified as the / partition before ) on /mnt.
  2. Identify what device corresponds to what mountpoint ( i.e. sdb3 -> /var, sdb4 -> /usr, and so on ).
  3. Mount them on the corresponding directory of the / you mounted on the previous step. ( i.e. if your var filesystem is sdb3 do sudo mount /dev/sdb3 /mnt/var, ... ).
  4. Finally mount the device where you want to copy your home files on /mnt/mnt
  5. You can then do a sudo chroot /mnt; mount /proc;mount /sys and begin working with your mounted image. ( Play with lvm as usual ). Mount your home filesystem ( it should be visible as an lvm volume ), and copy the useful data to the /mnt directory.
  6. Once finished exit and you'll be back to your server.
Related Topic