lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.49k stars 608 forks source link

attach and mount external drive (ssd / hdd) via usb [eg Ext4] #2098

Open erlangparasu opened 11 months ago

erlangparasu commented 11 months ago

Description

mount into /mnt from external drive (even external filesystem is unreadable by macos, eg Ext4, NTFS)

AkihiroSuda commented 11 months ago

The following steps MAY work (I didn't test):

Host

# Change N to the actual ID of the external disk
sudo qemu-nbd --socket=/tmp/nbd.sock /dev/rdiskN
sudo chown $(whoami) /tmp/nbd.sock
ssh -F ~/.lima/ssh.config -R /tmp/nbd.sock:/tmp/nbd.sock lima-default

Guest

sudo apt-get install nbd-client
sudo nbd-client -unix /tmp/nbd.sock /dev/nbd0
sudo kpartx -a /dev/nbd0
sudo mount /dev/nbd0p1 /mnt/foo

See also:

erlangparasu commented 11 months ago

i hope mounting feature is directly accessable via limactl command