Running linux on mac virtual

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Linux virtual machines, typically on macOS, for running containerd

License

lima-vm/lima

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

…g/x/sys-0.10.0 build(deps): bump golang.org/x/sys from 0.9.0 to 0.10.0

Git stats

Files

Failed to load latest commit information.

README.md

Lima: Linux virtual machines (on macOS, in most cases)

Lima launches Linux virtual machines with automatic file sharing and port forwarding (similar to WSL2), and containerd.

Lima can be considered as a some sort of unofficial «containerd for Mac».

Lima is expected to be used on macOS hosts, but can be used on Linux hosts as well.

✅ Automatic port forwarding

The talks page contains links to slides and video from conference presentations about Lima.

The goal of Lima is to promote containerd including nerdctl (contaiNERD ctl) to Mac users, but Lima can be used for non-container applications as well.

  • Rancher Desktop: Kubernetes and container management to the desktop
  • Colima: Docker (and Kubernetes) on macOS with minimal setup
  • Finch: Finch is a command line client for local container development
  • Podman Desktop: Podman Desktop GUI has a plug-in for Lima virtual machines
  • Lima xbar plugin: xbar plugin to start/stop VMs from the menu bar and see their running status.
  • lima-gui: Qt GUI for Lima
$ uname -a Darwin macbook.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64 $ lima uname -a Linux lima-default 5.11.0-16-generic #17-Ubuntu SMP Wed Apr 14 20:12:43 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux $ LIMA_INSTANCE=arm lima uname -a Linux lima-arm 5.11.0-16-generic #17-Ubuntu SMP Wed Apr 14 20:10:16 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux

See ./docs/multi-arch.md for Intel-on-ARM and ARM-on-Intel .

Читайте также:  Apache2 linux httpd conf

Sharing files across macOS and Linux

$ echo "files under /Users on macOS filesystem are readable from Linux" > some-file $ lima cat some-file files under /Users on macOS filesystem are readable from Linux $ lima sh -c 'echo "/tmp/lima is writable from both macOS and Linux" > /tmp/lima/another-file' $ cat /tmp/lima/another-file /tmp/lima is writable from both macOS and Linux

Running containerd containers (compatible with Docker containers)

$ lima nerdctl run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine

You don’t need to run «lima nerdctl» everytime, instead you can use special shortcut called «nerdctl.lima» to do the same thing. By default, it’ll be installed along with the lima, so, you don’t need to do anything extra. There will be a symlink called nerdctl pointing to nerdctl.lima. This is only created when there is no nerdctl entry in the directory already though. It worths to mention that this is created only via make install. Not included in Homebrew/MacPorts/nix packages.

Источник

Create macOS or Linux virtual machines

Learn how you can use the Virtualization framework to quickly create virtual machines on your Mac. We’ll show you how to create a virtual Mac and quickly test changes to your app in an isolated environment. We’ll also explore how you can install and run full Linux distributions on Apple silicon, and share how you can take advantage of Rosetta 2 to run x86-64 Linux binaries.

Resources

WWDC23

let virtualMachine = VZVirtualMachine(configuration: configuration) try await virtualMachine.start()
let virtualMachineView = VZVirtualMachineView() virtualMachineView.virtualMachine = virtualMachine
var configuration = VZVirtualMachineConfiguration() configuration.cpuCount = 4 configuration.memorySize = (4 * 1024 * 1024 * 1024) as UInt64 configuration.storageDevices = [newBlockDevice()] configuration.pointingDevices = [newPointingDevice()]
let platform = VZMacPlatformConfiguration() let hardwareModel = VZMacHardwareModel(dataRepresentation: savedHardwareModel) platform.hardwareModel = hardwareModel! let auxiliaryStorage = VZMacAuxiliaryStorage(contentsOf: auxiliaryStorageURL) platform.auxiliaryStorage = auxiliaryStorage let machineIdentifier = VZMacMachineIdentifier(dataRepresentation: savedIdentifier) platform.machineIdentifier = machineIdentifier! configuration.platform = platform
configuration.bootLoader = VZMacOSBootLoader()
let restoreImage = try await VZMacOSRestoreImage.latestSupported try await download(restoreImage.url)
let requirements = restoreImage.mostFeaturefulSupportedConfiguration guard let requirements = requirements else < // No compatible configuration. return > platform.hardwareModel = requirements.hardwareModel configuration.cpuCount = requirements.minimumSupportedCPUCount configuration.memorySize = requirements.minimumSupportedMemorySize
let virtualMachine = VZVirtualMachine(configuration: configuration) let installer = VZMacOSInstaller(virtualMachine: virtualMachine, restoringFromImageAt: imageURL) try await installer.install()
let graphicsConfiguration = VZMacGraphicsDeviceConfiguration() graphicsConfiguration.displays = [ VZMacGraphicsDisplayConfiguration(widthInPixels: 1920, heightInPixels: 1200, pixelsPerInch: 80) ] configuration.graphicsDevices = [graphicsConfiguration]
let trackpad = VZMacTrackpadConfiguration() configuration.pointingDevices = [trackpad]
let sharedDirectory = VZSharedDirectory(url: directoryURL, readOnly: false) let share = VZSingleDirectoryShare(directory: sharedDirectory) let tag = VZVirtioFileSystemDeviceConfiguration.macOSGuestAutomountTag let sharingDevice = VZVirtioFileSystemDeviceConfiguration(tag: tag) sharingDevice.share = share configuration.directorySharingDevices = [sharingDevice]
let diskImageURL = URL(fileURLWithPath: "linux.iso") let attachment = try! VZDiskImageStorageDeviceAttachment(url: diskImageURL, readOnly: true) let usbDeviceConfiguration = VZUSBMassStorageDeviceConfiguration(attachment: attachment) configuration.storageDevices = [usbDeviceConfiguration, createBlockDevice()]
let efi = VZEFIBootLoader() efi.variableStore = VZEFIVariableStore(creatingVariableStoreAt: storeURL, options: []) configuration.bootLoader = efi
let virtioGPU = VZVirtioGraphicsDeviceConfiguration() virtioGPU.scanouts = [ VZVirtioGraphicsScanoutConfiguration(widthInPixels: 1280, heightInPixels: 720) ] configuration.graphicsDevices = [virtioGPU]
let rosettaDirectoryShare = try! VZLinuxRosettaDirectoryShare() let directorySharingDevice = VZVirtioFileSystemDeviceConfiguration(tag: "RosettaShare") directorySharingDevice.share = rosettaDirectoryShare configuration.directorySharingDevices = [directorySharingDevice]
mount -t virtiofs RosettaShare /mnt/Rosetta sudo /usr/sbin/update-binfmts --install rosetta /mnt/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

Источник

Читайте также:  Linux disable network interface

How to use Linux on your Mac using a virtual machine

Linux on Mac

With virtualization, you can install and use various operating systems on your Mac, including Windows and Linux. For the latter, we recommend using the latest version of Parallels or open-source VirtualBox. Here’s a look at how to install and use Linux using each option.

What is virtualization?

As I noted in a previous post, software virtualization allows you to simulate a hardware environment and run multiple operating systems on one computer. In doing so, these virtual machines can take advantage of the hardware components on a computer such as RAM and storage in complete isolation to the primary operating system.

For those wanting to install Linux on their Mac through virtualization, we recommend using the latest version of Parallels or open-source VirtualBox. The former offers an easier-to-install solution, but you must pay for it after a 14-day free trial. The latter is open-source and free, but more difficult to install. Regardless, each solution will get the job done.

Installing Linux through Parallels

Using Parallels 15 for Mac, you can install a copy of Linux on your computer following the directions below. These steps assume Parallels has already been installed on your machine.

  1. Click File on the Parallels toolbar.
  2. Select New
  3. Highlight Download Ubuntu Linux under Free Systems.
  1. Click Continue.
  2. Choose Download to download a copy of Linux onto your computer.

Once installed, Linux want you to add a new password for the «Parallels» user. You can also choose «Not Listed?» to add a new UNIX user. Regardless, sign into your UNIX account.

  1. Type in your newly created password in the Parallels Tools box.
  2. Click OK.
  1. Restart your virtual machine at the prompt.

You can now use Ubuntu Linux on your Mac using Parallels.

Installing Linux through VirtualBox

To install a virtual copy of Linux on your Mac using the open-source VirtualBox, do the following. These steps assume VirtualBox has already been installed on your machine:

  1. Click New in VirtualBox.
  2. Add a name for your virtual copy of Linux.
  3. Choose Linux as the type of installation.
  4. Select the version of Linux to use.
  5. Click Continue
  1. Choose a Memory Size. Use the suggested minimum or select another number up to your maximum. The more memory you allocate for your virtual operating system, the speedier it will be.
  2. Select Continue.
  3. Choose the Create a virtual hard disk now radio dial.
  4. Click Create.
  1. Confirm VDI (VirtualBox Disk Image) as your hard drive file type.
  2. Select Continue.
  3. Confirm Dynamically allocated for storage.
  1. Choose file location and size
  2. Select Create.
Читайте также:  Apple для linux ubuntu

The steps above are just the first part of installing Linux on your Mac. You must now download a copy of Linux to work with VirtualBox to finish the process:

  1. Download Ubuntu Desktop from the Ubuntu website.
  2. Click Download next to the latest LTS version.
  3. Confirm to download.

Once downloading this file is complete, go back into VirtualBox.

  1. Highlight the Linux instance on the left side of the VirtualBox Manager.
  2. Choose Start.
  3. Click on the File Icon on the pop-up screen.
  4. Select Add at the top left.
  1. Find, then highlight the Ubuntu file you just downloaded.
  2. Choose Open.
  1. With the new file highlight, select Choose.
  2. Select Start.

From there, following the online directions provided by Ubuntu to finish the installation.

Adjust the settings

Depending on your Mac version and age, you may need to adjust the VirtualBox settings for Linux to make the window bigger. To do so, you must first exit the Linux installation. From there:

  1. Highlight the Linux virtual intallation on the main VirtualBox screen.
  2. Choose Settings.
  3. Select Display.
  4. Change Scale Factor from 100% to 200%.
  5. Click OK.
  1. Click Start to start Linux on your Mac.

You can now change the screen size for your Linux installation and begin using the oeprating system on your Mac.

Which should you choose?

Having installed Linux through both Parallels and VirtualBox on my MacBook Pro, I can tell you the process is easier through Parallels. As you can see above, there are much fewer steps to install Linux through Parallels. The result is the same once the operating system gets installed, however.

If you’re already using Parallels on your Mac (to use Windows, for example), you should continue to do so for Linux. The process is simple, and easy-to-follow. However, if you’re looking for a free solution or are new to virtualization, consider VirtualBox. Just go into it know you’ll need to follow a few more steps.

Questions?

Do you have any questions? Let us know in the comments below.

Get more iMore in your inbox!

Our news, reviews, opinions, and easy to follow guides can turn any iPhone owner into an Apple aficionado

By submitting your information you agree to the Terms & Conditions and Privacy Policy and are aged 16 or over.

Источник

Оцените статью
Adblock
detector