Я пытаюсь установить Ubuntu на свой MacBook Pro с помощью VirtualBox. Однако, похоже, нет руководства о том, как это сделать - большинство из них посвящено установке на ПК с Windows с помощью VirtualBox.
Может ли кто-нибудь помочь мне объяснить, как это сделать? Спасибо!
Я запускаю 20.04 в VirtualBox 6.1.10 на MacOS 10.15. За другими ответами следуйте указаниям мастера, и все это просто работает.
def vbinstall(alog, config, buildkey):
name = buildkey
home = Path.home()
download = f"{Path.cwd()}/downloads/{config['ubuntu'][buildkey]['dl'].split('/')[-1]}"
vb = hm.vbhost(host=config["virtualbox"])
cfg = f"{Path.cwd()}/bin/UnattendedTemplates/ubuntu_preseed.cfg"
exit, out = vb.cmd("VBoxManage list vms")
# alog.info(f"shared folder {config['sharedstorage']} -exists ")
alog.info(f"shared folder [{config['sharedstorage']}] exists [{Path(config['sharedstorage']).is_dir()}]")
for l in out:
vms = l.split()[0].strip("\"")
if vms == name:
alog.info(f"Server exists {vms}. Skipping setup....")
return
aux = f"{Path.cwd()}/bin/UnattendedTemplates/aux-{buildkey}"
alog.info(f"aux {aux}")
exit, out = vb.cmd(f"rm -rf {aux}")
exit, out = vb.cmd(f"mkdir {aux}")
with open(f"{Path.cwd()}/bin/UnattendedTemplates/autoinstall.yaml") as f: aconfig=yaml.safe_load(f)
# aconfig["autoinstall"]["hostname"] = buildkey
aconfig["autoinstall"]["identity"]["hostname"] = buildkey
aconfig["autoinstall"]["identity"]["username"] = config['mcs']['user']
aconfig["autoinstall"]["identity"]["password"] = config['mcs']['encrypted']
# substitute @@user@@ in late commands
aconfig["autoinstall"]["late-commands"] = \
[re.sub("\@\@user\@\@", config['mcs']['user'], l) for l in aconfig["autoinstall"]["late-commands"]]
with open(f"{aux}/autoinstall.yaml", "w") as f:
f.write("#cloud-config\n")
yaml.dump(aconfig, f)
with open(f"{aux}/user-data", "w") as f:
f.write("#cloud-config\n")
yaml.dump(aconfig, f)
exit, out = vb.cmd(f"touch {aux}/meta-data")
# want to keep UUID of VM constant for remoteit and plex - if defined use it
uuid = f'--uuid {config["ubuntu"][name]["uuid"]}' if "uuid" in config["ubuntu"][name].keys() else ""
# allow for VM specific location of sharedfolder
sharedstorage = config["ubuntu"][name]["sharedstorage"] if "sharedstorage" in config["ubuntu"][name].keys() else \
config["sharedstorage"]
alog.info(f"uuid: [{uuid}] storage: [{sharedstorage}]")
# VBoxManage createvm --name {name} --ostype \"Ubuntu_64\" --register --basefolder {home}/\"VirtualBox VMs\"/
vbi = f'''
VBoxManage createvm --name {name} --ostype \"Ubuntu_64\" --register --basefolder {home}/\"VirtualBox VMs\"/ {uuid}
#Set memory and network
VBoxManage modifyvm {name} --ioapic off
VBoxManage modifyvm {name} --memory 1024 --vram 128
VBoxManage modifyvm {name} --nic1 bridged
VBoxManage modifyvm {name} --bridgeadapter1 'en0: en0'
VBoxManage modifyvm {name} --graphicscontroller vmsvga
VBoxManage modifyvm {name} --audio none
#Create Disk and connect Debian Iso
VBoxManage createhd --filename {home}/\"VirtualBox VMs\"/{name}_DISK.vdi --size 15000 --format VDI
VBoxManage createhd --filename {sharedstorage}/{buildkey}-plex.vhd --size 50000 --format VHD
VBoxManage storagectl {name} --name "SATA Controller" --add sata --controller IntelAhci
VBoxManage storageattach {name} --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium {home}/\"VirtualBox VMs\"/{name}_DISK.vdi
VBoxManage storageattach {name} --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium {sharedstorage}/{buildkey}-plex.vhd
# shared storage
VBoxManage sharedfolder add {name} --name mcs --hostpath {sharedstorage} --automount
VBoxManage sharedfolder add {name} --name active --hostpath "{config['ubuntu'][name]['media']['active']}" --automount
VBoxManage sharedfolder add {name} --name archive --hostpath "{config['ubuntu'][name]['media']['archive']}" --automount
#Enable RDP
VBoxManage modifyvm {name} --vrde on
VBoxManage modifyvm {name} --vrdemulticon on --vrdeport 10001
# install
VBoxManage unattended install {name} --user={config['mcs']['user']} --password={config['mcs']['pwd']} \
--auxiliary-base-path {aux}/ \
--install-additions --iso={download} --country=SG --post-install-template={cfg} --script-template={cfg}
'''
exit, out = vb.cmd(vbi, assertfail=False)
for l in out: alog.info(f"{l}")
alog.info(f"finished {name} initial setup")
isolinux(aux, buildkey, config, alog)
preseed(aux, buildkey, config, alog)
exit, out = vb.cmd(f"VBoxManage startvm {name} #--type headless", assertfail=False)
alog.info(f"vm start [{exit}] {out}")
Процедура в значительной степени идентична Windows-компьютерам. Вы получаете ISO для Ubuntu и настраиваете новую виртуальную машину через графический интерфейс Virtualbox , как вам нравится. После завершения настройки дважды щелкните виртуальную машину, чтобы открыть ее, и выберите файл ISO. Затем подождите, пока он загрузится. После этого пройдите обычную установку. Когда он просит вас перезапустить, перезапустите. Когда он попросит вас удалить установочный носитель и нажать ввод, нажмите ввод. VirtualBox автоматически удалит установочный носитель для вас.