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.
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:
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 the 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
ls /to see if you are in the boot partition (it will show
bootfolders). If it’s the boot partition, go to step 2. If not, type only
lsto see the partition list and then type
ls <partition name>/with every partition until you see boot folders. Then change root to the correct partition.
# in this case, (hd0,1) is the correct partition grub> ls (hd0,1)/ grub> set root=(hd0,1)
- Look for the .efi file for the Grub boot menu. It can be in
chainloaderand the path of that efi file.
grub> chainloader /EFI/GRUB/grubx64.efi
boot. If you’re lucky it will show the system boot menu.
In Debian/Ubuntu systems, you can use
dpkg-reconfigureto reconfigure an installed package using intuitive dialogs. I will show you how to use this command to change some system settings.
If you have a scanned PDF and you want to be able to search and copy text from it, in this tutorial I will show you how to do it.
If you want to do X11 forwarding from your container to your host, you can type these simple commands.
If you don’t have a Graphical User Interface (GUI) on your Linux device, or you need a simple text-based web browser, I will show you a couple of great programs.
A comprehensive list of Linux-related websites sorted by categories.