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
- Use a Live USB
- Delete the partition of the OS you want to remove
- Resize main OS partition
- Resize main OS filesystem
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
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:
fdiskand the device name.
pto list the partitions. Remember the number of the partition you want to remove.
dto delete a partition. It will show a prompt where you need to type the partition number you want to delete (for example:
Resize main OS partition
pto check if the main system partition has the same number as before.
dto 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, type
pto check again the partition table.
nto 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
e2fsck -f <partition path>.
e2fsck -f /dev/sda3
resize2fs <partition path>.
- It will resize the filesystem to fill all the partition space.
You may need to update your bootloader (usually GRUB). Depending of the Linux distro, this can be achieved using
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: