How do I recover documents from a broken Ubuntu installation?

6,797

Solution 1

Go to another computer, simply download an actual Ubuntu image and make a bootable USB stick described on homepage from ubuntu.com. Boot from these USB stick and choose "Try Ubuntu". Now put a clean second USB stick or HDD into another USB port and save your documents from your computer HDD.

PS: It does not work, if you have encryption enabled by installation.

Solution 2

You might have somehow crashed the GRUB bootloader.

I'll explain how to recover, saving both systems, and also how to get files from in case recovery fails.

But for both you'll first need a live CD/USB

Preparing LiveCD/USB

From another computer make a Live CD or USB by simply following these steps.

  1. Download an Ubuntu image

  2. Write it to a CD or USB as described

  3. Boot from the live CD/USB on the problem computer. You may need to access the BIOS by pressing an F key (eg F2), Esc or Del and change boot order to prefer CD or USB.

Recovering bootloader

  1. In terminal execute

    sudo add-apt-repository ppa:yannubuntu/boot-repair
    sudo apt-get update
    sudo apt-get install boot-repair
    boot-repair
    
  2. Press Recommended repair and when finished try booting your system from the hard disk again.

    See boot repair | Ubuntu help wiki

Copying files

  1. Mount the partition that contains /home/

  2. Copy your whole username folder to some other place, not on the hard disk or the live USB system. Ypu need to copy the whole directory rather than just the contents because it will contain also hidden files that include browser bookmarks and other settings you might want to keep for backup.

Solution 3

My Ubuntu 16.04 crashed during file editing. After power cycle, it kept flopping between login password and reboot console printout. I inserted a bootable USB stick with Ubuntu 18.04 and chose "Try Ubuntu". The way to find where the old data/documents is

Ctrl+Alt+T to open a terminal.

Issue "lsblk" to see the partitions:

ubuntu@ubuntu:~/Documents$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
...
sda      8:0    0  74.5G  0 disk 
├─sda2   8:2    0  37.3G  0 part 
├─sda5   8:5    0   3.7G  0 part 
├─sda6   8:6    0  29.8G  0 part 
└─sda7   8:7    0   3.7G  0 part [SWAP]
sdb      8:16   1   1.9G  0 disk 
└─sdb1   8:17   1   1.9G  0 part /cdrom
sdc      8:32   1     2G  0 disk 
└─sdc1   8:33   1     2G  0 part 

or graphically by using ubuntu@ubuntu:~/Documents$ gparted

From the size, you can tell the old data is either in /dev/sda2 or /dev/sda6.

Make a directory sda2 under /media and mount /dev/sda2 at /media/sda2/ for sda2:

 ubuntu@ubuntu:/dev$ sudo mkdir /media/sda2
 ubuntu@ubuntu:/dev$ sudo mount /dev/sda2 /media/sda2 
 ubuntu@ubuntu:/dev$ ls sda2
 Document

Do the same thing for sda6 until you find the old data.

ubuntu@ubuntu:/media$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
...
sda      8:0    0  74.5G  0 disk
├─sda2   8:2    0  37.3G  0 part /media/sda2  
├─sda5   8:5    0   3.7G  0 part
├─sda6   8:6    0  29.8G  0 part /media/sda6

Then you can tarball and zip the data with

% tar -czvf oldData.tgz Document

Saving the .tgz file to a locally inserted USB flash drive is not possible since Ubuntu 18.04 is not installed yet. So I used Firefox to upload it to Google Drive. From there, I downloaded it to my Windows PC. After unzip and extract, I found the unsaved data/files were indeed gone due to the crash, but the rest is safe. Now I can start to install Ubuntu 18.04 knowing that the old data has been saved.

Solution 4

Apparently, you can recover files from a wubi installation. It requires some command line work, but nothing too difficult. You'll need to boot from an Ubuntu live CD, and then run the following in a terminal window:

sudo fdisk -l
sudo mkdir /win
sudo mount /dev/sdxy /win
sudo mkdir /vdisk
sudo mount -o loop /win/ubuntu/disks/root.disk /vdisk

Now, check the file browser, your wubi installation should be available there.

In the third command, the x and y are most probably a and 1, which gives /dev/sda1. Make sure to adjust according to where the wubi installation is.

Source: http://neosmart.net/forums/showthread.php?t=5004

Share:
6,797
Daniel Mesa
Author by

Daniel Mesa

Updated on September 18, 2022

Comments

  • Daniel Mesa
    Daniel Mesa almost 2 years

    I installed Ubuntu on a hard drive that had Windows XP installed so I could dual-boot the two operating systems. Everything was fine but now I can't boot into XP or Ubuntu. I had some important documents in the Ubuntu partition and the hard drive is still working, so how can I recover those files from a working Ubuntu installation? Where should I look for the broken Ubuntu installation?

    • mikewhatever
      mikewhatever over 12 years
      Depends on how Ubuntu was installed. If it's on a dedicated partition, you could use a live CD/USB and copy the files over. However, if you installed Ubuntu inside Windows, I don't know the way.
    • Daniel Mesa
      Daniel Mesa over 12 years
      Yeah i installed ubuntu inside Windows and thats the problem.
    • Kangarooo
      Kangarooo over 12 years
      Then need to use in my answer ==PRepearing LiveCD/USB== & == A Recovering bootloader==
    • Eliah Kagan
      Eliah Kagan over 6 years
  • Daniel Mesa
    Daniel Mesa over 12 years
    I have done that, but i do not know where to search my old documents because there are no actual ubuntu folders like home/ i do not know how to visibilize those folders that use ubuntu's file system, not the ntfs one. P.S I'm new to ubuntu, so this may seem a stupid question
  • Kangarooo
    Kangarooo over 12 years
    not good idea to use time to install couse Ubuntu live session can be used with CD or USB
  • mikewhatever
    mikewhatever over 12 years
    What? What time are you talking about?
  • Kangarooo
    Kangarooo over 12 years
    2 days ago. Check ubuntu.com/download/ubuntu/download there u can see that u can use USB Live without intallation. And wubi is slow & installed. You dont need to install OS to recover files and u dont need to install in Windows partition to make slow system in system- like Inception.
  • Kangarooo
    Kangarooo over 12 years
    No im am not high so youre alone on that..