2

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?

Simian
  • 125
  • 1
  • 6

1 Answers1

2

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.
rsl
  • 396
  • 1
  • 3
  • The two partitions at /dev/sdb2 and /dev/sdb5 have types of "Extended" and "Linux LVM" and I can't mount them. – Simian May 05 '11 at 14:32
  • Will this do the trick for LVM? sudo apt-get install lvm2 And how do I handle the extended? – Simian May 05 '11 at 14:34
  • I am unsure of what you are saying. My primary device is /dev/sda. The device that I want to recover data from is /dev/sdb. Running posv shows that /dev/sda5 and /dev/sdb5 have the same volume group of "ubuntu" – Simian May 05 '11 at 15:21
  • I had to rename the LVM volume, there were duplicates. Running mount is just hanging though, any ideas? – Simian May 05 '11 at 15:29
  • Do you see the logical volumes with lvs?. You can try to vgimport the group before attempting to mount – rsl May 05 '11 at 15:38
  • Ugh, the mount just gets killed, any way I can repair the LVM partition? – Simian May 05 '11 at 15:40
  • You can try to fsck the partition itself first. Doesn't mount throw any error message? – rsl May 05 '11 at 19:49
  • Yes, mount said it was "killed". How can I run fsck? I tried fsck /dev/sdb but it said the device is in use. I can run fsck on /dev/sdb1, but it doesn't help. My data resides wither on /dev/sdb2 or /dev/sdb5. /dev/sdb5 is my LVM volume – Simian May 05 '11 at 20:33
  • PHEW ok. So I had to rename the volume using vgrename as mentioned. Then I ran fsck against the volume, not the physical device. And then I was able to mount the volume as described. – Simian May 05 '11 at 20:59