Multipass with VirtualBox usage - relocate systemprofile path to other directory

ZMOT ME·2021년 3월 7일
0

ubuntu-desktop

목록 보기
3/5

부서 computer 들을 windows 10 20H2 로 upgrade 하려고 했었다. 가장 큰 이유는 WSL 2의 손쉬운 사용.

1809 / 190X 에도 WSL 2 를 활성화 시킬 수 있지만, User Land 작업을 거의 완벽히 싫어하는 게 분위기라, 고민하고 있었는데, multipass 가 1.5 이상을 올라가면서, virtualbox 생성 위치를 Sytem Profile 밑이 아니라 지정할 수 있게 환경변수가 지원되면서 가능해져 보인다.

MULTIPASS_STORAGE Environment Variable 의 사용

기존에 SYSTEM 계정으로 VirtualBox 가 실행될 때, %LOCALAPPDATA% 에 VirtualBox 가 생성되므로, 여러 단점들이 있었는데, 해소가능하게 되었다.
MULTIPASS_STORAGE 환경 변수를 적용하면 된다.

  • Windows Update 시 VM Data 들이 날아갈 수 있는 문제가 해결된다.
  • Domain User 들에게 Elevated Shell 을 허용하지 않으므로 해당 Data 에 접근을 할 수 없었지만, 가능하다.
  • Windows System32 Directory 에 있으므로, Any 32bit program 들을 사용할 수 없었는데 32bit/64bit 에 따라 달라지지 않는 폴더에 놓을 수 있게 된다.
  • 생성된 VirtualBox 를 간단하게 수정하기 위해서 vboxmanage 를 PSExec -s -i 등으로 사용하지 않아도 된다. (물론 Domain User 권한으로는 -s option 인 System account 를 사용하지 못하므로 이도 가능해진다.)
C:\Windows\System32\config\systemprofile\AppData\Local\multipassd>tree
폴더 PATH의 목록입니다.
C:.
└─cache
    ├─network-cache
    │  ├─data8
    │  │  ├─0 ...
    │  └─prepared
    └─virtualbox
        └─vault
            └─images
                └─focal-20210223
                
 # After Assign %MULTIPASS_STORAGE% in System Environment Directory
 $ c:\opt\bin\gtree -dL 5
.
|-- Storage
|   |-- cache
|   |   |-- network-cache
|   |   |   |-- data8
|   |   |   |   |-- 0
|   |   |   |   |-- e
|   |   |   |   `-- f
|   |   |   `-- prepared
|   |   `-- virtualbox
|   |       `-- vault
|   |           `-- images
|   `-- data
|       |-- certificates
|       |-- registered-certs
|       |-- ssh-keys
|       `-- virtualbox
|           `-- vault
|               `-- instances
|-- bin
|   `-- platforms
`-- fonts

Install Multipass with silent option supporting VirtualBox

It seems mulitpass windows installer is based on NSIS installer, silent option to be /S.

Requirements for our case

  • mulipass should be installed other location with TrustedInstaller have protected privilege.
  • VirtualBox should be installed other location with TrustedInstaller have protected privilege.
  • On installing multipass, local driver should be set to virtualbox. It seems possible without shell engagement just sed with System account's %LOCALAPPDATA%\multipassd.conf
C:\Windows\System32\config\systemprofile\AppData\Local\multipassd>type multipassd.conf

[General]
local.driver=virtualbox
  • MULTIPASS_STORAGE should be set other location not in System account's %LOCALAPPDATA%
  • VirtualBox should have global property
  • Less Path is better, We will use scoop teams' shim in global path, because we need VirtualBox related commands must be exist in shims directory :
$ dir *.exe /b
vbox-img.exe
VBoxAutostartSvc.exe
VBoxBalloonCtrl.exe
VBoxBugReport.exe
VBoxDTrace.exe
VBoxExtPackHelperApp.exe
VBoxHeadless.exe
VBoxManage.exe
VBoxNetDHCP.exe
VBoxNetNAT.exe
VBoxSDL.exe
VBoxSDS.exe
VBoxSVC.exe
VBoxTestOGL.exe
VBoxWebSrv.exe
VirtualBox.exe
VirtualBoxVM.exe

multipass silent install

  • Set MULTIPASS_STORAGE = C:\VBoxVMs\Multipass\Storages
  • Install VirtualBox
  • VBoxManage setproperty machinefolder C:/VBoxVMs
  • Temporarly export Path to Environment to multipass can get VBoxManage
  • keep silent install waiting
  • execute command multipass set local.driver=virtualbox
  • subincal for domain user can stop and restart
start /wait "" "mulitpass....exe" /SD=C:\opt\multipass

https://nsis.sourceforge.io/Which_command_line_parameters_can_be_used_to_configure_installers%3F
/D=C:\Bla or /D=C:\Path with spaces
Set installation folder ($INSTDIR)
Must be the last parameter on the command line and must not contain quotes even if the path contains blank spaces.
Related to: $INSTDIR

References

profile
꼼퓨타 포맷해주는 사람, 지켜주지 몬해서 미안해

0개의 댓글