How to install xv6 on virtualbox or vmware? - xv6

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.

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.)

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

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.

Related

Unix command line on PC using Ubuntu

I am new to these forums and to using Ubuntu and linux and UNIX. I really need some help here. I hope I haven't shot myself in the foot already. I have been trying to complete a UNIX carpentry lesson on the internet for an assignment. I am learning the basics about UNIX. I am not using a Mac, I am using a PC that I did not configure in any way (maybe that's my problem). I am using windows 10 on a lenovo and trying to the command prompt on Ubuntu to find my desktop where a file called "data-shell" is located. The problem: IT IS NOT FINDING THE DESKTOP. Upon further inspection, I have been looking through the location of my desktop and "data-shell" file and found it in the Users location under a number 12094, which I am assuming is the serial number for the computer. I have NEVER fiddled with the software at all with this computer as it cost me a lot of money, but I really do not want to be stopped in the tracks already. I have the following images numbered in the order that I discovered everything; they are posted here. I would really appreciate the help. P.S.: Since I am using a PC and not mac, I thought I had to use another command line like BASH or the terminal on my PCor doI just use Ubuntu? The UNIX shell is supposed to start with a $, right? Please correct me if I a wrong and thank you for your help
.
linux commands on windows can be ran via cmder or git bash (what i had used in past)
and in linux the desktop is at the path
/home/< username>/Desktop
whereas in windows its
C:\Users<username>\Desktop
both windows (DOS) and ubuntu/mac(linux) environment are entirely different you can directly run commands of one on the other environment, you do need to "setup" that env first if the command is not native to that.
Now, since its assignments that you are doing and all you need is bare-min linux env
you can give https://repl.it/ a try and create a new project in bash
Also, when you install Ubuntu on windows you dont get acces to windows like path, like "C:...", in ubuntu c:\ of windows is mounted to some other path in ubuntu
search on google how to access windows desktop from ubuntu shell after installing ubuntu inside of windows
When using Windows Subsystem for Linux (WSL), your C drive is located under /mnt/c.
Judging from the screenshot, you are user 12094, so you can either accept this, or you need to actually configure your machine. Also if you look in the screenshot you provided, there is a /home folder which I am betting is actually pointing to /mnt/c/, and your home folder will be under /home/12094, which is also the same as what is stored in $HOME.
To find the location of a file called data-shell, you can run the following linux command while in your home folder:
find $HOME -type f -name 'data-shell'
This command recursively searches for files in your home directory, with the name data-shell

Is it possible to install Rstudio server on Linux without root access?

I'm an undergraduate research assistant working on a Linux server without root privilege. I'm trying to install the Rstudio server but the Rstudio website only provides the installation method for sudoers. Is it possible to install it without root access? I'm asking because I'm really not sure if I could get access from the manager. Any help will be appreciated!
No, you can't install it without root access. But there are a couple of things you could do to piece together a solution. Here are two options:
Extract the server and run it directly
You have to be root to install packages, so you can't install the .deb/.rpm file yourself. However, you could extract the contents of the file to a directory inside your home directory and run RStudio Server from there, by executing the rserver program in a regular shell.
Note that this will probably require an afternoon of editing the rserver.conf file to tell it where to find the rest of the files in the installation (since it presumes they are installed in /usr/lib by default). You can get some inspiration for how to do this here: https://github.com/rstudio/rstudio/blob/master/src/cpp/conf/rserver-dev.conf
Run the desktop version and forward the graphics
The other route is to run RStudio Desktop on the server; we make several builds of RStudio Desktop that are installer-less and can just be unpacked into your home directory. Then run an X11 server on your own computer and an X11 client on the RStudio server, so that the RStudio Desktop instance appears on your computer instead of the server.
Yes, you can run rserver without root priveliges.
For RStudio 1.4 I patched the following line into src/cpp/core/LogOptions.cpp
const FilePath kDefaultLogPath = core::system::xdg::userDataDir().completePath("log");
Then you need to set the system environment variables to some location read-writeable for the user, like
RSTUDIO_CONFIG_DIR=$HOME/.config/rstudio
RSTUDIO_CONFIG_HOME=$HOME/.config/rstudio
RSTUDIO_DATA_HOME=$HOME/.local/share/rstudio
And start rserver with the option
--server-data-dir={directory writeable for user}
--server-pid-file={file-path creatable for user}
--database-config-file={config-file}
With these adjustments it runs for me when I start it as a simple user (no root privileges) with
rserver --auth-none=1 --www-frame-origin=same --www-port={port} --www-verify-user-agent=0 --server-data-dir={my-tmp-path} --server-pid-file={my-tmp-path}/rstudio.pid --database-config-file={my-tmp-path}/db.conf}
ATTENTION:
But be aware, that anyone who can reach your system and the specified port from the network has access to the running RStudio in his browser and therefore can run any command in the name of the user on your system now.

install SQLite on a USB stick attached to a Linux/Debian box

I need my application to run from a USB stick and perform the installation from there.
The application is eventually installed on a Linux/Debian.
For the application installation I need a DB to be installed on that USB. I also need the DB data (tables, etc.) to be kept on that USB stick.
I read that SQLite is a good candidate to be used for such a purpose. However, I could no find the steps needed for installing it on the USB stick.
I did download the sqlite-snapshot-202002271621.tar.gz from the sqlite.org site, placed it in one of my Debian directories and used the 3 commands to install it (./configure,make,make install).
That installed SQLite on my hard disk.
What should I do in order to achieve the same on the USB stick?
Mount the USB to the Debian box, place the tar.gz file there, and run the commands from there?
Will that install SQLite on the USB?
Thanks
So the answer is indeed:
Mount the USB to the Debian box
Place the sqlite-snapshot-202002271621.tar.gz file there
Run the commands from there
./configure
make
make install
Notice just that I had to tar the sqlite-snapshot-202002271621.tar.gz file using:
tar -zvxf sqlite-snapshot-202002271621.tar.gz -C /media/usbstick/ --no-same-owner
In order to avoid the error:
"Cannot change ownership to uid 1000, gid 1000: Operation not permitted"

Can I execute a Linux binary from a Windows application?

I want to execute a Linux binary from a QT application running on W10.
In QT we have QProcess to launch additional processes. However, since my binary is for Linux, I've thought of two possible approaches:
Running the binary in a container (i.e.: Docker, Kubernetes, Singularity...).
Executing the binary through WSL (Ubuntu) bash.
In any case, the QT application should initiate the process (the container or the bash) and, in turn, this process should launch my binary.
I've been searching on the web and I could not find something related, what makes me think that it will be difficult. For this reason, I am posting the question in order to know the viability of the proposed approaches.
EDITED
It looks like the WSL is easier, the problem is that the user has to have install ed it. Apart from requiring the sudo password when installing new software via apt-get.
The binary that I have to execute only exists for Linux, and let's say that cross-compiling is dismissed because of its complexity. Furthermore, this application needs CGAL, BOOST, MPI, among other pieces of software.
If you want to go with WSL, you can just run wsl myLinuxProgram --options.
Using WSL is the easiest way I believe as the current directory (PWD), is the current one i.e. the same as the PWD of your Qt app.
You can read Microsoft documenation for more info: https://learn.microsoft.com/en-us/windows/wsl/interop
If your linux binary depends on a lots of things, I really suggest you use docker for windows. Then, you have chance to pre-build an own docker image which put all dependency software also the linux binary you need to run in it.
Of course, to let your customer to use it, you should put it to dockerhub, register an account for yourself.
Then, the solution is simple: let the QT application to call docker run to setup a container base on your own image, execute it, and also let the linux binary to write the log or others to the bind mount volume among linux container & windows. After it run, the QT application fetch the linux binary output from this shared folder.
Finally, I give a minimal workable example for your reference:
Suppose the shared folder between windows & linux container is: C:\\abc\\log_share, it will mapped to linux container as /tmp folder. Of course you need to allow volume share by right click the docker icon in windows tray area & choose settings, like described here
Simplify the windows application as bat file, and simplfy the docker image as ubuntu, you should use your own prebuilt docker image with all dependency in it:
win_app.bat:
ECHO OFF
::New a shared folder with linux container
RD /s/q C:\\abc\\log_share > NUL 2>&1
MKDIR C:\\abc\\log_share
::From windows call docker to execute linux command like 'echo'
echo "Start to run linux binary in docker container..."
docker run -it -v C:\\abc\\log_share:/tmp ubuntu:16.04 bash -c "echo 'helloworld' > /tmp/linux_log_here.txt"
::In windows, get the log from shared bind mount from linux
echo "Linux binary run finish, print the log generated by the container..."
type C:\\abc\\log_share\linux_log_here.txt
Simplify the linux binary just as echo command in linux, the output things should be all write to shared directory:
echo 'helloworld' > /tmp/linux_log_here.txt
Now, execute the bat file with command win_app.bat:
C:\abc>win_app.bat
C:\abc>ECHO OFF
"Start to run linux binary in docker container..."
"Linux binary run finish, print the log generated by the container..."
helloworld
You can see the windows application already could fetch things(here is helloworld) which generated by linux binary from docker container.

Copying file to live VM (KVM/libvirt)

Just wondering if there is any method to copy a file to a live VM created over KVM using libvirt tools. My objective is to assign a static IP address to VM without modifying the img file or without using dhcp. What I understand is we need to have a file in /etc/sysconfig/network-scripts/ corresponding to the interface in VM where ip address has to be assigned. Wondering if I can copy this file after VM is created and booted up.
Update : I am using CentOS 7 for guest and host .
Thanks
I'd suggest using a kickstart file for installing the machine. That way the installer automatically sets the IP address wherever it is needed (even though you know where it needs to be set in the current version). Copying the file onto the disk with the VM being running must be done in a way that the VM knows about that, but that means you need to have access to the machine, which, I guess, you don't; mainly since that's probably what you're trying to do.
If the machine is installed and you want to configure that without access to it and without reinstalling, I'd suggest to cleanly shutdown the VM, then use libguestfs (mainly guestfish command) that lets you access the disk of the machine.
This works really well: http://www.linux-kvm.org/page/9p_virtio
Basically mkdir /tmp/share && echo '/hostshare /tmp/share 9p trans=virtio,version=9p2000.L 0 2' >> /etc/fstab. On Host ``mkdir /tmp/share`.
Then in Virt-manager, Add Hardware > Filesystem, change Driver to Path, add Source /tmp/share and Target /hostshare. And mount -a.
Or add by command mount -t 9p -o trans=virtio,version=9p2000.L hostshare /tmp/share.

Resources