1

Well, I was upgrading my Ubuntu 12.04 to 14.04 and suddenly the power went off. I was in the installation stage and only a bit of it was done. Now when I boot into Ubuntu, it shows a command line that shows that it can't read the files or something. I please need to recover my system and most importantly my files. Any help would be appreciated.

2
  • 1
    Online upgrade or off a boot medium (CD, USB..)? You will be wanting a bootable disc of some sort, and ideally a USB drive you can backup your files on. Do you have these, or access to another PC if not? Dec 9, 2014 at 15:44
  • Yes, one of 2GB free.
    – Anony Mous
    Dec 10, 2014 at 13:11

1 Answer 1

0

If you boot off the bootable CD/USB & select the 'Try Ubuntu' option you will have a working system; plug the USB drive in, it should mount; you should also have an icon for your main (corrupted) drive, which you can double-click & it, too should mount. Assuming it does, you can navigate to your files & copy them safely to the USB drive. If this goes OK, you'll almost certainly need to re-do the installation - I would unmount & disconnect the backup drive first. That's it..

If you get permission errors, or something won't mount, open a terminal:

sudo -i to get root permissions for all the next bit.

If drives mounted, skip over the following to Copying.

mkdir /media/ubuntu/drive1 /media/ubuntu/drive2 - we need to create mount points. Then, we need to identify your drives:

dmesg | tail will tell you where it put your USB drive - likely sdb or similar.

Your main drive should be /dev/sda_ ; _ may be 1 if there's no Windows etc around. If you're not sure, run fdisk -l /dev/sda which should list the partitions for you. You can probably work out which is your home directory by sizes if it's not obvious - that's the one we want. fdisk -l with no drive will list all drives on your system.

Once you're confident you have the right drives, (I'll use sda1 for your old files, sdb1 for the new USB - you use whatever you found..) type:

mount /dev/sda1 /media/ubuntu/drive1
mount /dev/sdb1 /media/ubuntu/drive2

Copying:

shopt -s dotglob if you want to keep hidden files, eg .gnupg/, .mozilla/ - better to do it than not.

cp -R -preserve=all /media/ubuntu/whatever-it-called-your-old-drive/home/yourname/* /media/ubuntu/whatever-it-called-your-USB/ # This will take some time, but will copy all your files under your old userid, to your backup drive.

We now have the backup & can proceed to re-install to OS - unmount & disconnect the USB first.

Finally:

Once the re-installation is done, you have a system with an almost empty home directory. Just copy some or all of your files back off the USB. If you use the shopt -s dotglob command it will take all your emails & passwords etc back over too; but may overwrite some system files, so I always take a (renamed) copy of the new blank home as well, just in case!

If the new installation assigned you a new userid, you may find you can't log in due to not owning your own files.

cd /home/
shopt -s dotglob
sudo chown -R you:you you

should fix that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .