First, you need an Ubuntu Live media. It's the same CD/DVD/USB used to install it. Also get a spare flash drive/external drive/CD/DVD to make the backup. If your installation media is a USB drive, you can make a second partition out of it to keep your files.
We'll also need some information, such as your Ubuntu partition name. Consider some factors:
Do you have a separate /home
partition? If so, discover its name.
If you don't have a separate /home
partition, discover the root (/
) partition's name.
The "name" is the path to the partition's special device file, something like /dev/sda1
. You should know it at this point. Take note of it.
Boot into your Live media and insert your backup drive. We'll need to discover its "name", too. To do it, you can run df -aTh
in a terminal. You will find information about mounted filesystems, find your backup media and take note of it. Again, it should be something like /dev/sdb1
.
In a terminal, run:
sudo mount /dev/sdXY
/mnt`
replacing /dev/sdXY
with Ubuntu's partition name. Then
sudo umount /dev/sdAB
replacing /dev/sdAB
with the backup media.
sudo mkdir /backup
sudo mount /dev/sdAB /backup
sudo mkdir /backup/ubuntu_backup
sudo cp -rf /mnt/home /backup/ubuntu_backup
The above command may take some time, since it's the actual backup.
When it finishes, the backup is ready. Make sure by running nautilus /backup/ubuntu_backup
and making sure all you home folders and files are there. Run:
sudo umount /mnt
sudo umount /backup
You can proceed to reinstall Ubuntu from the Live media you're currently running, formatting the old Ubuntu partition Make sure you create your admin user with the exact same name you had before. When it finishes, reboot to the Live media and not to the installed Ubuntu OS. From the Live media, in a terminal, run:
sudo mount /dev/sdXY /mnt
sudo umount /dev/sdAB
sudo mkdir /backup
sudo mount /dev/sdAB /backup
sudo rm -rf /mnt/home
sudo cp -rf /backup/ubuntu_backup/home /mnt
again, the above will take a bit of a time. It's copying the backup to the freshly installed system.
When it finishes, simply reboot into Ubuntu and all your files (including Desktop icons) should be there.
NOTE: the backup won't keep your installed apps/software. You should take note of them to reinstall later.
Never remove Python. It's essential for Ubuntu core functionality. As a rule of thumb, never delete anything that comes with Ubuntu.
Have a nice day.