LimaでmacにLinux仮想環境を構築する

環境

  • Mac mini (M1, 2020)
  • macOS 11.6
  • Homebrew 3.3.6
  • Lima 0.7.4
❯ sw_vers
ProductName:	macOS
ProductVersion:	11.6
BuildVersion:	20G165
❯ brew --version
Homebrew 3.3.6
Homebrew/homebrew-core (git revision 9f835d692f6; last commit 2021-12-03)
Homebrew/homebrew-cask (git revision 5ff8565336; last commit 2021-12-03)
❯ limactl --version
limactl version 0.7.4

Limaをインストール

homebrewを使ってLimaをインストールします。

❯ brew update
❯ brew install lima

Linuxインスタンスを起動する

とりあえずデフォルトのインスタンスを起動します。limactl startすると、矢印キーで選択できるようになるので、Proceed with the default configurationを選んでエンターキーを押下。

❯ limactl start 
? Creating an instance "default"  [Use arrows to move, type to filter]
> Proceed with the default configuration
  Open an editor to override the configuration
  Exit

起動したインスタンスを確認する

limactl lsで起動したインスタンスを一覧表示できます。

❯ limactl ls
NAME       STATUS     SSH                ARCH       CPUS    MEMORY    DISK      DIR
default    Running    127.0.0.1:60022    aarch64    4       4GiB      100GiB    /Users/XXXXX/.lima/default

インスタンスを停止する

limactl stopでインスタンスを停止できます。

❯ limactl stop default

limactl lsでステータスを確認すると、Stoppedになっています。

❯ limactl ls
NAME       STATUS     SSH            ARCH       CPUS    MEMORY    DISK      DIR
default    Stopped    127.0.0.1:0    aarch64    4       4GiB      100GiB    /Users/XXXXX/.lima/default

インスタンスを削除する

limactl deleteでインスタンスを削除できます。

❯ limactl delete default

limactl lsで確認すると、何も無くなりました。

❯ limactl ls
WARN[0000] No instance found. Run `limactl start` to create an instance. 
NAME    STATUS    SSH    ARCH    CPUS    MEMORY    DISK    DIR

See Also

PowerShell - Item

フォルダ・ディレクトリ・変数・レジストリキーを操作

Homebrew

Mac/Linux用のパッケージマネージャー

PowerShell - Remove-Item

ファイルやディレクトリを削除する

Nushell

Rust製シェル

2024/04/15

今日見つけたツール