0

I have a sandbox Ubuntu server VM (virtualbox) with a single drive. Recently I needed to extend the disk space of the server, so I created a second disk. I dd'd the original /dev/sda to the new /dev/sdb and extended the partition size with parted and resize2fs. Everything looks great, so now I want to make the /dev/sdb partition default and remove the /dev/sda. How do I make the /dev/sdb the default boot option? Currently I can only boot into it from a rescuecd, the default boot option is /dev/sda

lsblk output (booted from /dev/sdb via rescuecd):

[12:10] [vhost2 ~] # lsblk 
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    10G  0 disk 
├─sda1   8:1    0     1M  0 part 
└─sda2   8:2    0    10G  0 part 
sdb      8:16   0    20G  0 disk 
├─sdb1   8:17   0     1M  0 part 
└─sdb2   8:18   0  18.6G  0 part /

fdisk output:

[12:10] [vhost2 ~] # fdisk -l
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 4E763705-333C-4EE0-80EB-782C5D968F03

Device     Start      End  Sectors Size Type
/dev/sda1   2048     4095     2048   1M BIOS boot
/dev/sda2   4096 20969471 20965376  10G Linux filesystem


Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 4E763705-333C-4EE0-80EB-782C5D968F03

Device     Start      End  Sectors  Size Type
/dev/sdb1   2048     4095     2048    1M BIOS boot
/dev/sdb2   4096 39062500 39058405 18.6G Linux filesystem

My fstab is empty

[12:11] [vhost2 ~] # cat /etc/fstab 
UUID=88fdcaac-dcfd-4f0e-99de-5adf19d4ab12 / ext4 defaults 0 0
/swap.img   none    swap    sw  0   0
deimos
  • 721
  • isn't that something to do inside virtualbox? you copied the disk so you don't need to have the original mounted. just tell virtualbox that that copy is it's disk and what it should boot. perhaps you should provide more context to your post. I'm supposing from what you're saying this isn't a system created in Virtualbox, it is bootable on your whole machine but also you're able to load it up from another OS using virtualbox, correct? – tatsu Jun 10 '19 at 12:23
  • 1
    Hi. No, it's just a simple setup of VMs in my virtualbox. Removing the original disk from VM did the trick flawlessly. I think I overthought the whole process and I could do that much easier and faster, haha. – deimos Jun 10 '19 at 12:41

1 Answers1

1

Boot-Repair should provide an easy, semi-automated solution here.

  1. Detach your old drive from the VM (to prevent adding further work at the end).
  2. Boot the live medium and run the recommended repair in Boot-Repair.
  3. Power off the VM and detach the live CD.
  4. Your new drive should boot normally.
  5. Fix your /etc/fstab if necessary. It should point to your actual root partition’s UUID. The current contents look well (if the UUID of your partition is correct), the file is definitely not “empty”.

If cloning the drive using dd wasn’t a necessary part of your sandbox experiments, you could have just extended the original virtual hard drive instead of cloning it. Of course, this approach is not feasible with physical hard-drives.

Melebius
  • 11,431
  • 9
  • 52
  • 78