3

I accidentally removed Python 3 from /etc and now I lost many important folders, programs and also the Gnome shell. I know, I'm stupid.

I can still log in with my user but now everything is like this:

enter image description here

I believe the right solution is to install ubuntu 18.04 again.

Since my $HOME folder is undamaged (everything I had there remained: see screenshot below) I want to copy it to a flash drive so I can install Ubuntu again without losing my personal files.

enter image description here

But when I put my USB flash drive in, it shows me this message:

[ 264.065197] sd 6:0:0:0: [sdb] Asking for cache data failed 
[ 264.065242] sd 6:0:0:0: [sdb] Assuming drive cache: write through

How can I solve this to copy my home to a flash drive using this terminal?

I don't know if there is a way to restore everything again. I think reinstalling it should be better, but if there is another solution to this without reinstalling Ubuntu again it feel free to share.

  • 2
    If you have terminal, do you also have network. If so, you can reinstall python3. sudo apt install python3 – oldfred Aug 09 '19 at 19:53
  • yeah, I did that. I installed python again and all python packages necessary. But for some reason, I couldn't install the gnome-shell again because there was an error message saying that there were some files corrupted (and it didn't show which files), so I believe that reinstall it is better. – Lucas_Guerra Aug 09 '19 at 20:51
  • Copy home directory to Portable USB drive; https://askubuntu.com/questions/5484/how-can-i-move-my-home-directory-to-another-partition-if-its-already-part-of-t/1063036#1063036 – C.S.Cameron Aug 10 '19 at 16:58

1 Answers1

6

Use 2 USB Drives

First USB

Create a LiveUSB (also known as installation USB) of Ubuntu on this USB drive. You will need to use another computer for this task. If you already have a LiveUSB drive you used to install Ubuntu, you can skip this step.

Second USB

This will be your Home backup USB. Make sure you have enough space to keep all your home folders in this USB drive.

Boot from the LiveUSB

Use the Try Ubuntu without installation option to get to the Live session of Ubuntu. This will boot Ubuntu from the LiveUSB.

Mount the internal system partition

Mount the internal disk partition containing your /home folder. If you don't have a separate /home partition (standard Ubuntu installations don't) it will be your Ubuntu / partition.

Easiest way to mount this partition is to use the Disks application in Ubuntu. Look through each physical drives listed in Disks on the left margin and locate your internal physical drive. Then identify your Ubuntu partition. It will be formatted ext4.

Highlight the partition and click on the stopped ⬛ icon to turn it into a play ▶ icon. Note down the mountpoint which will look like

/media/ubuntu/<mountpointoftheinternalpartition>

where <mountpointoftheinternalpartition> is a bunch of letters and numbers.

Insert the second USB into the computer.

Do not unplug the first one to insert the second one! Use a different USB socket.

Copy all your folders and files into the second USB.

You can use Nautlus and drag and drop all the folders if you are the only user of this computer. Or use the command below

If you have multiple users and want to preserve the data of all the users, open a terminal by pressing Ctrl+Alt+T and use a command like:

sudo cp -rp /media/ubuntu/<mountpointoftheinternalpartition>/home /media/ubuntu/USB2TB/home

Make sure /media/ubuntu/USB2TB/home actually refers to you second USB drive where you intend to copy /home and /media/ubuntu/<mountpointoftheinternalpartition>/home actually refers to the /home folder in your internal drive.

Note: If you have a separate /home partition you will need to copy the contents of that partition to the second USB with a command like:

sudo cp -rp /media/ubuntu/<mountpointofthehomepartition> /media/ubuntu/USB2TB/home

Eject (Safely Remove) the second USB.

Be patient. If you have a lot of data copied to the USB, it may take a while for the data in the write cashe to be actually written to the USB. Don't lose your data by unplugging the USB too soon.

Install Ubuntu

There is an Install Ubuntu icon in the Live session. You can use it to install Ubuntu after you have safely copied all your important data to the second USB.

Once you have checked the new installation is running properly, you can copy your data from the second USB to your Home folder.

If you have other users and copied all their home data, then follow the instructions in the After Installation section of this answer.

Hope this helps

user68186
  • 33,360
  • 1
    That sounds great, I'll try it later. I did not know that if I choose the option "Try Ubuntu without installation" it would come with the same home folder that I had before, I thought it would be an empty home folder. That's nice. I'll try it later. – Lucas_Guerra Aug 09 '19 at 19:25
  • @Lucas_Guerra I have fixed the answer. – user68186 Aug 09 '19 at 20:54