物理Ubuntu机器转VirtualBox镜像后启动报错:No bootable Medium found!
Hey there, sorry you're stuck on this boot error—let's break down the problem and fix it step by step!
问题根源
The key issue here is that you used dd to back up only a single partition (/dev/sda1) instead of the entire physical disk (/dev/sda). Bootable systems rely on the master boot record (MBR) or GRUB bootloader, which lives in the very first sector of the whole disk (not inside a single partition like /dev/sda1). Your converted VMDK only has the data from /dev/sda1—it's missing the critical boot metadata VirtualBox needs to start the system.
解决方法
方法1:重新制作完整镜像(最稳妥)
This is the recommended approach because it captures all the necessary boot and partition data:
- Go back to your physical Ubuntu machine, and run this command to back up the entire disk (not just
/dev/sda1):
Note: This will include all partitions (like swap, data partitions) and the boot sector, so your VirtualBox VM will have an exact copy of the physical system.dd if=/dev/sda of=/mnt/f/disk.raw bs=1024 - Convert the full raw image to VMDK again:
VBoxManage convertfromraw /mnt/f/disk.raw /mnt/f/disk.vmdk --format VMDK - Create a new VirtualBox VM (or replace the existing disk in your current VM) with this new VMDK, then try booting again.
方法2:修复现有镜像的引导(如果不想重新备份)
If re-backing up the disk isn't feasible right now, you can repair the bootloader on your existing VMDK:
- In VirtualBox, edit your VM's settings: add an Ubuntu installation ISO as a CD/DVD drive, and set the VM to boot from the CD first.
- Start the VM and select "Try Ubuntu" (don't install it).
- Open a terminal and identify your VMDK's partition:
Look for a partition that matches the size of your originallsblk/dev/sda1(it'll probably be/dev/sda1in the live environment). - Mount the partition and fix GRUB:
sudo mount /dev/sda1 /mnt sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys sudo chroot /mnt grub-install /dev/sda update-grub exit - Unmount the mounted directories:
sudo umount /mnt/sys sudo umount /mnt/proc sudo umount /mnt/dev sudo umount /mnt - Shut down the VM, remove the Ubuntu ISO from the CD drive, set the VM to boot from the hard disk first, then try starting it again.
额外检查
- Double-check your VM's System > Boot Order settings to ensure the hard disk is at the top of the list.
- Confirm that your VM's architecture (64-bit) matches your physical Ubuntu system—if your physical machine is 32-bit, selecting "Ubuntu 64-bit" would cause issues (but it sounds like you got this right!).
备注:内容来源于stack exchange,提问作者user7864052

