
Reinstalling Ubuntu gives you a clean system when an installation is broken, slow, infected or cluttered after years of experiments, or when you want to move to a new release from scratch. Done carefully, you keep your files and only lose what you choose to. This guide covers when a reinstall makes sense, how to back up, how to create a bootable USB, reinstall Ubuntu 24.04 or 26.04 LTS on a PC, keep a separate home partition, reinstall Ubuntu on a VPS, and restore your data and software.
Quick answerBack up your files, download the Ubuntu ISO, write it to a USB stick, boot from it, choose Install Ubuntu and Erase disk and install Ubuntu (or manual partitioning to keep a separate /home), then restore your data. On a VPS, use your provider's control panel to reinstall the OS image instead.
Is it time to reinstall?
Try a repair first if the problem is specific. Reinstalling makes sense when:
- The system will not boot and repairs (from a live USB) have failed.
- Package management is badly broken by conflicting repositories or forced installs.
- A server may have been compromised. A clean reinstall is the only trustworthy fix.
- You want to jump several releases (for example from 20.04 to 26.04) and prefer a clean system to multiple in-place upgrades.
- You are giving the computer to someone else.
Step 1: Back up your data
A reinstall that erases the disk deletes everything. Back up:
- Your home folder (
/home/username): documents, photos, downloads, and hidden folders such as~/.ssh,~/.gnupgand application settings in~/.config. - Browser profiles, or sign in to sync.
- Databases: export them with
mysqldumporpg_dumpall. - Configuration you changed in
/etc(web server, SSH, cron jobs:crontab -l > crontab.txt). - A list of installed packages:
apt-mark showmanual > packages.txtandsnap list > snaps.txt.
Copy the backup to an external drive or another server, for example with:
rsync -a --info=progress2 ~/ /media/$USER/BackupDrive/home-backup/
Check that the backup opens before continuing.
Step 2: Download Ubuntu and create a bootable USB
- Download the Ubuntu Desktop or Server ISO from ubuntu.com. Choose the latest LTS (26.04, or 24.04) for long support.
- Verify the download with the SHA256 checksum published next to it:
sha256sum ubuntu-*.iso. - Write it to a USB stick of 8 GB or more (this erases the stick):
- On Ubuntu: open Startup Disk Creator or use balenaEtcher.
- On Windows: use Rufus or balenaEtcher.
- From the terminal:
sudo dd if=ubuntu.iso of=/dev/sdX bs=4M status=progress conv=fsync, replacingsdXwith the USB device (check withlsblk).
Step 3: Boot from the USB
Insert the USB, restart, and open the boot menu (often F12, F11, Esc or F8, depending on the manufacturer). Choose the USB drive. If it does not appear, check the firmware (BIOS/UEFI) settings; Ubuntu supports Secure Boot, so you normally do not need to disable it.
Step 4: Run the installer
- Choose Try or Install Ubuntu, then select your language, keyboard and network.
- Choose Install Ubuntu and an interactive installation.
- Choose between the default selection of apps and an extended selection, and whether to install third-party drivers and media codecs (recommended for NVIDIA graphics and Wi-Fi).
- For the disk:
- Erase disk and install Ubuntu wipes everything and installs a clean system. Recent installers also offer disk encryption here, including TPM-backed encryption on supported hardware in 26.04.
- Manual installation lets you choose partitions. Use it to keep an existing separate
/homepartition (see below) or to dual-boot.
- Create your user account, choose your time zone, review and click Install.
- Remove the USB and restart when prompted.
Keeping your files with a separate /home partition
If your existing installation has /home on its own partition, you can reinstall without touching your personal files:
- In the installer, choose Manual installation.
- Select the old system (root) partition, set its mount point to
/and mark it to be formatted. - Select the home partition, set the mount point to
/home, and make sure it is not formatted. - Keep the EFI system partition (mount point
/boot/efi), without formatting it if other systems use it. - Create the same user name as before so your home folder is reused.
Even with this method, keep a backup: one wrong tick formats your data.
Reinstalling Ubuntu on a VPS or dedicated server
On a VPS you do not use a USB stick. Log in to your provider's control panel, choose Reinstall or Rebuild, and select the Ubuntu version. This wipes the server's disk and gives you a fresh system with new root credentials or your SSH key. Before you click it:
- Back up websites, databases and configuration off the server (or take a snapshot if your provider offers it).
- Note your firewall rules, DNS records and any extra IP addresses configured on the server.
- Expect the SSH host key to change; remove the old entry with
ssh-keygen -R your-server-ipbefore reconnecting.
Step 5: After the reinstall
sudo apt update && sudo apt full-upgrade -y
xargs -a packages.txt sudo apt install -y # reinstall your packages (same release)
- Restore your files from the backup with
rsync, and fix ownership if needed:sudo chown -R $USER: ~. - Re-add third-party repositories only for software you still need.
- Restore databases and configuration, then test your applications.
- On servers: set up SSH keys, the firewall, automatic security updates and Fail2ban before putting it back into service.
Frequently asked questions
Can I reinstall Ubuntu without losing data?
Yes, if /home is on a separate partition and you reuse it without formatting, or if you back up and restore your files. Always keep a backup either way.
How do I reinstall Ubuntu from Ubuntu itself?
Create a bootable USB with Startup Disk Creator from your current system, then reboot from the USB and run the installer.
How long does reinstalling Ubuntu take?
Usually 15 to 30 minutes for the installation, plus time to back up and restore your data.
Will reinstalling Ubuntu remove viruses or malware?
Erasing the disk and reinstalling removes anything on it. Restore only data, not programs or scripts, from a possibly compromised system, and change your passwords and keys.


