
In this tutorial, we will guide you through the process of changing the boot partition from one drive to another in Ubuntu 18.04 via SSH. This process can be quite useful in various scenarios, such as when you want to boot from a backup drive or when you are migrating to a new drive.
Prerequisites
Before we start, make sure you have:
- A machine running Ubuntu 18.04.
- SSH access to the machine.
- Familiarity with basic Linux commands and text editors (like nano or vim).
- Root or sudo access.
Overview of the Process
The process of changing the boot partition involves two main steps:
- Identifying the new boot partition.
- Changing the boot order.
Step 1: Identifying the New Boot Partition
First, we need to identify the partition that we want to boot from. For this, we will use the lsblk
command, which lists all block devices (i.e., hard drives and their partitions) on your system.
sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
This command will output a list of all block devices, their file system type, size, mount point, and label. Identify the partition you want to boot from.
Step 2: Changing the Boot Order
The method of changing the boot order depends on whether your system uses EFI or BIOS for booting.
For EFI Systems
EFI systems use a firmware-based boot manager, efibootmgr
, to manage the boot process. You can check your current boot order with the following command:
sudo efibootmgr
This command will output a list of boot entries. Each entry is represented by a four-digit number. Identify the number of the boot entry that corresponds to your desired boot partition.
To change the boot order, use the following command:
sudo efibootmgr -o <boot number>,<other boot numbers>
Replace <boot number>
with the number of your desired boot entry, and <other boot numbers>
with the other boot entry numbers in the order you want them to be tried if booting from the first entry fails.
For BIOS Systems
BIOS systems use the GRUB bootloader. To change the boot order in GRUB, we need to edit its configuration file. First, open the file with a text editor:
sudo nano /etc/default/grub
Find the line that starts with GRUB_DEFAULT
and change its value to the number of the GRUB menu entry that corresponds to your desired boot partition. GRUB menu entries are 0-indexed, so the first entry is 0, the second is 1, and so on.
After making the change, save and close the file, then update GRUB with the following command:
sudo update-grub
Conclusion
Changing the boot partition from one drive to another in Ubuntu 18.04 via SSH can be a bit complex, but with the right commands and a careful approach, it can be done safely and effectively. Always remember to double-check your changes before rebooting to avoid any potential issues.
A boot partition is a specific partition on a hard drive that contains the necessary files for the operating system to start up. It typically includes the bootloader and other essential boot files.
To access a machine running Ubuntu 18.04 via SSH, you need to open a terminal on your local machine and use the following command: ssh username@ip_address
. Replace username
with your username on the remote machine and ip_address
with the IP address or hostname of the remote machine.
You can check if you have root or sudo access by running the sudo -v
command. If you have the necessary privileges, the command will execute without asking for a password. If you don’t have the required privileges, it will prompt you for a password.
After running the lsblk
command, look for the partition you want to boot from in the output. The MOUNTPOINT
column will show the mount point of each partition. If the partition you want to boot from is mounted, it will have a mount point listed. If it is not mounted, the MOUNTPOINT
column will be empty.
To change the boot order on an EFI system, you can use the efibootmgr
command. First, run sudo efibootmgr
to see the list of boot entries. Identify the number of the boot entry that corresponds to your desired boot partition. Then, use the command sudo efibootmgr -o <boot number>,<other boot numbers>
to change the boot order. Replace <boot number>
with the number of your desired boot entry, and <other boot numbers>
with the other boot entry numbers in the order you want them to be tried if booting from the first entry fails.
On a BIOS system, you can change the boot order by editing the GRUB configuration file. Open the file /etc/default/grub
with a text editor using the command sudo nano /etc/default/grub
. Find the line that starts with GRUB_DEFAULT
and change its value to the number of the GRUB menu entry that corresponds to your desired boot partition. Save and close the file, then update GRUB with the command sudo update-grub
.