2

I'm trying to run xv6 operating system on VirtualBox or VMWare in a Linux host. The official instructions said how to run the OS on qemu only. However, the official page (https://pdos.csail.mit.edu/6.828/2014/xv6.html) mentioned that xv6 can be booted directly on hardware also, but it's not clear how.

I want to boot xv6 on VirtualBox or VMware first. I extracted the following command from the Makefile, which runs xv6 from the command line after it's compiled using make command.

/usr/bin/qemu-system-i386 -serial mon:stdio -drive file=fs.img,index=1,media=disk,format=raw -drive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512

Please help me how to proceed. If the procedure is already documented some reference will be helpful.

Abhik Bose
  • 161
  • 3
  • 7

3 Answers3

1

The instructions are here which is linked (via 6.828 tools page) from your link though they are a bit terse:

Using a Virtual Machine

Otherwise, the easiest way to get a compatible toolchain is to install a modern Linux distribution on your computer. With platform virtualization, Linux can cohabitate with your normal computing environment. Installing a Linux virtual machine is a two step process. First, you download the virtualization platform.

VirtualBox (free for Mac, Linux, Windows) — Download page
VMware Player (free for Linux and Windows, registration required)
VMware Fusion (Downloadable from IS&T for free). 

VirtualBox is a little slower and less flexible, but free!

Once the virtualization platform is installed, download a boot disk image for the Linux distribution of your choice.

Ubuntu Desktop is what we use.

This will download a file named something like ubuntu-10.04.1-desktop-i386.iso. Start up your virtualization platform and create a new (32-bit) virtual machine. Use the downloaded Ubuntu image as a boot disk; the procedure differs among VMs but is pretty simple. Type objdump -i, as above, to verify that your toolchain is now set up. You will do your work inside the VM.

I can see how one could read that and not see the answer.

After the virtual machine is installed, download the Ubuntu Desktop .iso. Install that into the VM and fire it up. Presumably the Desktop will provide a clear mechanism for loading your OS. (Wait, I'm giving it a try. Will update with the result.)

Turns out that is simply a Ubuntu client desktop, and isn't anything special for running a sub-operating system.

Looking around some more, I found the commentary to be the best potential clue. It contains this (head scratcher) phrase:

To run xv6, install the QEMU PC simulators. To run in QEMU, run "make qemu".

If only it specified the context to get to that point! (Sorry I am not more help.)

wallyk
  • 56,922
  • 16
  • 83
  • 148
1

I see that you want to boot it on VirtualBox or VMware, but another option would be to using docker to run xv6. A great guide for getting started with xv6 through docker is here.

The full guide is elaborate and can help you with getting started. It is an alternative option, but one that can get you going fast hopefully.

It will only take 4 steps to get going with the xv6:

Step 1

  • Download and set up docker here

Step 2 - Run this command in PowerShell or bash to pull the ubuntu image with xv6 docker pull grantbot/xv6

Step 3 - To run the docker image and get going with xv6 run this command docker run -it grantbot/xv6

Step 4 - Now inside the shell in the ubuntu image run cd /home/a/xv6-public/ to enter the root folder of the xv6.

Done - Now you can compile and run the xv6 with make qemu-nox

ms99
  • 61
  • 4
1

Step 1.Compile xv6

Download the code, unzip it and enter the directory, compile the operating system image and root file system, the command is as follows:

make xv6.img&&make fs.img

Step 2. Write image to disk

Create two disks in a existed vmware virtual machine(my vmware version is 15.2.2, linux version is Centos7.8), the operation steps are: virtual machine settings -> add -> disk -> SCSI -> create a new virtual disk -> size 0.005 (allocate immediately, single file) -> name the disk "os", which means this disk is the operating system.

Create another disk named "fs" in the same way to put the root file system.

At this time, there should be "sdb" and "sdc" in the /dev/ directory (sda is the current operating system itself). If you do not see the "sdb" and "sdc", restart the guest operating system. Write the operating system and root file system to the disk with the following command:

dd if=./xv6.img of=/dev/sdb bs=4k count=1000
dd if=./fs.img of=/dev/sdc bs=4k count=1000

shutdown the current virtual machine to ensure that the file has sync to the disk. At this time, the two images have been written to the disk, vmware saves the disk as a file, the location is in the directory of the current virtual machine, named os.vmdk, fs.vmdk, the next step will load these two files into the new virtual machine.

Step 3. Create xv6 virtual machine

To create an empty virtual machine, the operation steps are: customize (advanced) -> next -> install the operating system later -> choose other operating system type (choose other versions) -> take the virtual machine name as xv6 (name depend on you) ) -> Then use the default configuration all the way to "Next" to completion.

Right-click the created virtual machine and delete the disk created by default. Add the disk file created in the previous step to the current virtual machine. The operation steps are: add -> "disk" -> ide (note that this is an IDE instead of a SCSI disk, because xv6 reads an IDE format disk) -> use an existing virtual disk -> select the os.vmdk generate in the step 2->complete

Add fs.vmdk in the same way. Note that you must add os.vmdk first. Because os.vmdk is the operating system, it needs to be the first hard disk.

Now, you create a virtual machine which has two disk. one is os disk, another is root file system disk, all is ready.

Start the virtual machine, and the xv6 will start successfully.

screenshot

szwry
  • 11
  • 2
  • This looks good to me, but could you please do things link put long commands such as the `dd` invocations in codeblocks (surrounded by triple backticks), and filenames and disk names, etc., in single backticks? That will make it more readable. Also please show the image itself instead of just a link to it. You can look at other posts with images if you don't know how to do that. –  Nov 08 '21 at 18:02