📜 ⬆️ ⬇️

Installing Ubuntu on a real hard drive via VirtualBox

For some reason, it may turn out that you need to install Ubuntu on the computer on which Windows is installed (in this case, it was Windows Server 2003). Why is it about Windows? Under Linux, there are other solutions, there are debootstrap and chroot, and on Windows there are fewer options for such a maneuver.

But the usual installation method (boot from the LiveCD / LiveUSB, install, configure everything, reboot again) does not always work. Why not always? Because it may be that access to a computer is only remote (in this case, it was an RDP server in Windows), and physical access is only through another person, and rare (once a day). And then no matter how much action it takes, if you do it in the usual way - insert a flash drive / disk, boot, wait until you are asked to try to use the distribution, select this option, then configure remote access (in Ubunt even the SSH server is not installed by default - never, by the way, understood why, but fact), and only after that go about his business. And so the only thing that was required from the person is to change the boot order from the hard drives in the BIOS.

By the way, theoretically, you can try to do even without this if you unpack the grldr from the grub4dos package on the C: \ drive in Windows, create the menu.lst in the same place (where you can boot from another hard disk using the chainloader), and add to C: \ Boot .ini item “C: \ grldr =“ GRUB ””, then select this item by default. Then you just need to restart your computer, and it will reboot into Ubuntu, where at that time there will already be SSH. You just have to remember to add the timeout parameter to the menu.lst configuration file - otherwise the download will not be done automatically (GRUB will wait for someone to press Enter).
')
In addition to remote installation, there is another important application of this method - imagine that you need to reduce the time that the server will not function from the user's point of view, to a minimum. And you can do it. From the fact that you install Ubuntu in a virtual machine, the server’s work will not be disrupted, and you can restart the virtual machine after installation to make all the necessary changes, including creating users, installing and configuring SSH, possibly a web server, mail server, FTP and everything else you might need. And then you just restart the computer. And everything that worked on Windows now works on Ubuntu: a minute and a half, which the computer will restart, is not at all as noticeable as a few hours, during which you would gradually set it up and turn it on.


And now about the installation itself



There is a very useful feature in VirtualBox. In addition to virtual hard disks, you can connect a real, real hard disk to a virtual machine.

To do this, create a special vmdk file for the hard disk.

This file takes about 1 kibbyte, although one would think that it would take a size comparable to the hard disk itself. :)

Open cmd.exe and do the following.

cd "C: \ Program Files \ Oracle \ VirtualBox"

VBoxManage internalcommands createrawvmdk -filename c: \ disk.vmdk -rawdisk \\. \ PhysicalDrive0

Instead of PhysicalDrive0 there may be, for example, PhysicalDrive1 - depending on the sequence number of the hard disk.

By the way, there is even an opportunity to use specific sections of a physical hard disk, you can read more about this in the documentation on VirtualBox .

After you have created a vmdk file, you can create a new virtual machine and connect this hard disk to it.

Open the VirtualBox GUI, click "New", then enter the name of the virtual machine and select OS Type (Linux, Ubuntu). We choose the amount of memory (well, when it is not less than a gibibite, but we must proceed from how much memory is at the computer itself, and how much it is used). Then, in the section Virtual Hard Disk you need to select "Use existing hard disk". Now you can click “Finish” and load the new virtual machine. It will use the selected physical disk of the computer. It remains to connect the Ubuntu ISO image to it and install it (after that, restart the virtual machine and make all the necessary changes — in order to load the already configured system on the computer itself).

The hard drive connects fully and completely - this means that through the virtual machine, the Ubuntu installation program successfully created the partition table, recorded the MBR and placed all the necessary files.

This was the way to install. Now, if you change the operating system from Windows to Ubuntu on any server or, say, remotely on a friend's computer - at his request, of course :) - then you can use this option.

Source: https://habr.com/ru/post/126658/


All Articles