Removing an operating system in a dual-boot system
If you want to remove an OS in a computer where you have two or more OS installed, and resize the partitions, follow this tutorial.
Table of Contents
- Introduction
- Use a Live USB
- Delete the partition of the OS you want to remove
- Resize main OS partition
- Resize main OS filesystem
- Bootloader
Introduction
I am going to describe the process of removing an OS that was created after the operating system you want to keep (“main system”). The main system partition needs to be before the system partition you want to remove.
Use a Live USB
If you want to resize the partition of the OS you want to keep, you’ll need a system that can boot from a USB, because the partition you want to resize needs to be unmounted.
Delete the partition of the OS you want to remove
-
Type
fdisk -l
(change to the root user if needed). Take note of the device in where the partition you want to remove is (for example:/dev/sda
). -
Type
fdisk
and the device name.fdisk /dev/sda
-
Type
p
to list the partitions. Remember the number of the partition you want to remove. -
Type
d
to delete a partition. It will show a prompt where you need to type the partition number you want to delete (for example:6
).
Resize main OS partition
- Type
p
to check if the main system partition has the same number as before. - Type
d
to delete the main system partition (don’t worry, we are not really going to delete it, but we are going to re-create it). Type the partition number of the main system. It will ask you if you want to remove an existing signature, typeN
for No. - Type
p
to check again the partition table. - Type
n
to create a new partition. When it asks you for the “Last sector”, type+
, and the size you want for the partition (for example:+100G
). If you want the partition takes all available space, accept the default.
Resize main OS filesystem
- Run
e2fsck -f <partition path>
.e2fsck -f /dev/sda3
- Run
resize2fs <partition path>
.resize2fs /dev/sda3
- It will resize the filesystem to fill all the partition space.
Bootloader
You may need to update your bootloader (usually GRUB). Depending of the Linux distro, this can be achieved using update-grub
or grub-mkconfig -o <grub.cfg path>
. If you have problems doing this from the Live USB, try rebooting (from the hard drive). If you see the GRUB command-line (instead of the GRUB boot menu), you can follow these steps in order to recover the GRUB menu.
GRUB only shows a command-line, not the boot menu
Check Common GRUB issues.
If you have any suggestion, feel free to contact me via social media or email.
Latest tutorials and articles:
Featured content: