Coder Social home page Coder Social logo

macos-linux-vm-with-rosetta's Introduction

Rosetta-enabled virtual machine based on Apple Sample Code

Live stream

The Live stream recording where this was built and tested is on YouTube.

Building the app

The built app is downloadable at the releases page, or you can build the app yourself with XCode 13 Beta.

If you want to build the VM app yoursef, rather than using the pre-built download, do the following:

  1. Open XCode-beta and select from the menu bar XCode -> Settings
  2. In the settings dialog navigate to Accounts
  3. If your account is not listed click the + button at the bottom of the list and login to your Apple Developer account (a free account is sufficient)
  4. Close the settings window
  5. Clone the git repository off GitHub, e.g. git clone https://github.com/diddledani/macOS-Linux-VM-with-Rosetta.git
  6. Open the RosettaVM.xcodeproj project file in XCode
  7. Click the left-hand sidebar entry at the top of the tree labelled RosettaVM
  8. In the right-hand pane navigate to the TARGETS entry RosettaVM
  9. Click the top-bar entry labelled Signing & Capabilities
  10. In the Team drop-down select your Apple Developer account/team, and set the Signing Certificate drop-down to Sign to run locally
  11. Click the > (Run) button at the top-left of the XCode window

Setting up Rosetta

When you start the RosettaVM app, you should be prompted by the app to select a Linux installer ISO.

  • Ubuntu 22.04.1 Desktop (This is a daily build of the ISO and is classed as unstable, meaning that any particular day's download may have bugs - There is currently no 'stable' ISO for the desktop release)
  • Ubuntu 22.04.1 Server

Once you've supplied the app with an installation ISO file it should start the Virtual Machine. You need to follow the standard installation of the distro that you have downloaded.

If you're using the Ubuntu Server ISO you will need to install binfmt-support to provide the update-binfmts command which we will use below to enable the Rosetta wrapper. To install binfmt-support run:

sudo apt install -y binfmt-support

Once installed, you need to execute the following commands inside the Linux VM to enable Rosetta to intercept x86_64 binaries:

sudo mkdir /var/run/rosetta
sudo mount -t virtiofs ROSETTA /var/run/rosetta
sudo /usr/sbin/update-binfmts --install rosetta /var/run/rosetta/rosetta \
    --magic "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00" \
    --mask "\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
    --credentials yes --preserve no --fix-binary yes

Now you should be able to execute x86_64 Linux binaries as though they were native. Bare in mind, however, that you need all your Linux app's required libraries in x86_64. On Ubuntu these are installable by adding the following to your /etc/apt/sources.list file (ensure you change jammy to the codename of the version of Ubuntu you are running):

deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security main restricted
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security multiverse

You also need to tell APT and dpkg to enable amd64 repositories:

sudo dpkg --add-architecture amd64

When you make changes to the /etc/apt/sources.list file, or add an additional architecture with the dpkg command, you should run sudo apt update to update your cache of known packages.

To install an x86_64/amd64 library in Ubuntu once you've updated your /etc/apt/sources.list you need to append :amd64 to each package name, e.g.:

sudo apt install libx11-6:amd64

Installing the Ubuntu Desktop for graphical applications (Only when Server ISO were choosen)

When you install Ubuntu Server with the above ISO you will only have a command-line environment. You can upgrade from Ubuntu Server to Ubuntu Desktop by evecuting the following commands, which will take a while to complete:

sudo apt update
sudo apt -y full-upgrade
sudo apt -y install ubuntu-desktop^

Note: the ^ symbol is important when you want to install ubuntu-desktop as this tells apt to use a task which defines the complete Ubuntu Desktop. If you omit the symbol you may not get a fully-installed desktop. You won't need to use the ^ for any other apt install calls, however, only for ubuntu-desktop.

Once the process completes, you should reboot the VM with the following command:

sudo reboot

After the VM reboots you should see the graphical login screen.

macos-linux-vm-with-rosetta's People

Contributors

beiriannydd avatar lucyllewy avatar mavethee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

macos-linux-vm-with-rosetta's Issues

Application crashes right after start

Greetings!
I tried to install Ubuntu, but turned my Mac off before installation competed. Now, when I open application, its window shows for a split second and closes. There should be an issue with cashed files, right? I should be able to delete them and application will work?
The problem is: I don't know where corrupt files is...

How to run 2 linux system at the same time via RosettaVM?

I installed ubuntu via RosettaVM and it works perfect. Also I want to run another ubuntu at the same time. But when I try to open new rosettaVM, it brings the ubuntu screen which is already opened. Is rosettaVM supporting to run more than one server at he same time? Also I wonder that how can I change images. I mean, for instance, an ubuntu server is running but I don't want to use it anymore, and how can I change it with another iso. I am asking because, I couldn't find any interface about these.

Thanks for this great project. I really loved it.

Networking issues

Having some random networking issues. Sometimes the network works, sometimes it doesn't work.

Is there any way to trouble shoot it? Thanks!

NixOS VM: "Failed to add binary format 'rosetta': Invalid argument"

Hi there,

Firstly, thanks for creating this project!

I'm trying to get it working with a NixOS VM (ISO: https://hydra.nixos.org/build/196616052) without success.

I have added this snippet to /etc/nixos/configuration.nix: as per the README (https://github.com/diddledani/macOS-Linux-VM-with-Rosetta#setting-up-rosetta), and have mounted /var/run/rosetta.
When I try to activate the configuration, I get an error. I have taken this picture of the VM screen, with the output of a couple of commands to hopefully help in debugging:
IMG_5306

So, actually activating the configuration (and thus running update-binfmts) I get this error:

Failed to add binary format 'rosetta': Invalid argument

If I manually run /run/binfmt/rosetta I get the following error message (which may be totally irrelevant, since I'm not supposed to run it manually, but I figured it may be relevant so I'm including it):

rosetta error: Rosetta is only intended to run on Apple Silicon with a macOS host using Virtualizartion.framework with Rosetta mode enabled

My laptop is a 2021 14-inch MacBook Pro (M1) running macOS Ventura 13.0.

Ventura beta 2/3 issues?

Just went to play with this again on the dev beta 3 that came out today, but refused to actually launch:
image

I had to turn off the App Sandbox in RosettaVM.entitlements to get it to actually start up.

Also installing ubuntu server 22.04 will kernel panic when installing updates after the install stage (still boots fine, just requires an additional dpkg --configure -a when booted)

Paid developer account not necessary + the ubuntu server iso you have linked in readme.md missing package

just tested this out on my free developer account on Ventura (using the dev beta profile off a website).

xcode changes were basically sign to run locally and use my developer stuff in xcode

Works great and is stupid fast!

the ubuntu server iso is missing the update-binfmts command, but a simple apt install binfmt-support added it.

CleanShot 2022-06-18 at 12 55 13

Also, installing ubuntu-desktop^ does give a working desktop

image

thank you for this!

Guest did stop virtual machine

Hi there,

I have downloaded the latest:

  • macOS 13 beta
  • RosettaVM
  • ubuntu-22.04.1-live-server-amd64.iso

I can start RosettaVM and get a black screen and a file open dialog. When I click to load the Ubuntu iso, RosettaVM stops.

Now when I start it again, it insta-stops.

To get more details, I tried running from the terminal, and get:

❯ /Applications/RosettaVM.app/Contents/MacOS/RosettaVM
Virtual machine successfully started.
Guest did stop virtual machine.

Any idea would be appreciated :)

Mount a folder shared by the macOS host system inside the Ubuntu VM

I got a VM running, already so amazing 🤩 thank you for the work here.

It's not entirely clear to me how I can mount a folder into the VM. Use case: I have code in a local directory that I would like to be accessible in the VM, so I can make changes in my local code editor and watch & run them directly.

I guess I could use NFS or something like that for this, but configuring that correctly can be troublesome. I came across virtiofs and noticed this is also what is used to share Rosetta with the VM. I suspect this will be faster than going over NFS as well.

It is my understanding that from the VM side, we could just run this for example to mount a Shared Folder if it was tagged api2: sudo mount -t virtiofs api2 /srv/current. All that is missing now is sharing the folder with same tag from the host side.

Is this something that would need to be supported in the RosettaVM program that you built, or is there some way I can do this on the CLI already? The the former, a command line argument or cfg file to define a share would already be a lifesaver, no need for any ui :)

USB support

How can we manage to detect external usb device?

Guest did stop virtual machine

Hi,
so I started the program and loaded the ubuntu iso but somehow the installation stopped, so I force quitted RosettaVM.

Now it tells me "Guest did not stop virtual machine".

I faced the same problem when I ran the SampleVirtualMachine by Apple Development and I fixed it by deleting the .bundle file and reinstalling the vm.

The problem is indeed that I cannot find the .bundle file. Any help with this? thank you.

Not able to finish building VM on Sonoma

Hi all,
This issue has the same message as #16, although there are some differences.
I'm trying to build a Fedora VM, running on a MacBook Air with chip M1.

fatalError("Failed to retrieve the machine identifier data.")

In fact, I never reach to the step to choose the linux distribution.
Specifically, the error appear in line 99, file AppDelegate.swift
I don't try to use Rosetta, at least by now.
Thank you!

Add ability to use non default storage size?

Screwing around with the VM I managed to run out of space compiling Firefox, is there a way to ideally add more space to the current VM or do I need to nuke it and change something in the xcode project itself?
CleanShot 2022-06-18 at 20 36 07

Ubuntu 20.04 Support.

Is Ubuntu 20.04 supported currently or might be in testing? Please let us know.

I am a ROS developer and would like to try this on ROS Noetic that runs only on Focal Fossa/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.