nixos/virtualbox-image: remove the raw image trick
This is slower, but the raw image thing no longer works with VirtualBox 7.0.6.
This commit is contained in:
@@ -81,7 +81,7 @@ in {
|
|||||||
extraDisk = mkOption {
|
extraDisk = mkOption {
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Optional extra disk/hdd configuration.
|
Optional extra disk/hdd configuration.
|
||||||
The disk will be an 'ext4' partition on a separate VMDK file.
|
The disk will be an 'ext4' partition on a separate file.
|
||||||
'';
|
'';
|
||||||
default = null;
|
default = null;
|
||||||
example = {
|
example = {
|
||||||
@@ -183,8 +183,8 @@ in {
|
|||||||
export HOME=$PWD
|
export HOME=$PWD
|
||||||
export PATH=${pkgs.virtualbox}/bin:$PATH
|
export PATH=${pkgs.virtualbox}/bin:$PATH
|
||||||
|
|
||||||
echo "creating VirtualBox pass-through disk wrapper (no copying involved)..."
|
echo "converting image to VirtualBox format..."
|
||||||
VBoxManage internalcommands createrawvmdk -filename disk.vmdk -rawdisk $diskImage
|
VBoxManage convertfromraw $diskImage disk.vdi
|
||||||
|
|
||||||
${optionalString (cfg.extraDisk != null) ''
|
${optionalString (cfg.extraDisk != null) ''
|
||||||
echo "creating extra disk: data-disk.raw"
|
echo "creating extra disk: data-disk.raw"
|
||||||
@@ -196,8 +196,8 @@ in {
|
|||||||
mkpart primary ext4 1MiB -1
|
mkpart primary ext4 1MiB -1
|
||||||
eval $(partx $dataDiskImage -o START,SECTORS --nr 1 --pairs)
|
eval $(partx $dataDiskImage -o START,SECTORS --nr 1 --pairs)
|
||||||
mkfs.ext4 -F -L ${cfg.extraDisk.label} $dataDiskImage -E offset=$(sectorsToBytes $START) $(sectorsToKilobytes $SECTORS)K
|
mkfs.ext4 -F -L ${cfg.extraDisk.label} $dataDiskImage -E offset=$(sectorsToBytes $START) $(sectorsToKilobytes $SECTORS)K
|
||||||
echo "creating extra disk: data-disk.vmdk"
|
echo "creating extra disk: data-disk.vdi"
|
||||||
VBoxManage internalcommands createrawvmdk -filename data-disk.vmdk -rawdisk $dataDiskImage
|
VBoxManage convertfromraw $dataDiskImage data-disk.vdi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
echo "creating VirtualBox VM..."
|
echo "creating VirtualBox VM..."
|
||||||
@@ -209,10 +209,10 @@ in {
|
|||||||
${lib.cli.toGNUCommandLineShell { } cfg.params}
|
${lib.cli.toGNUCommandLineShell { } cfg.params}
|
||||||
VBoxManage storagectl "$vmName" ${lib.cli.toGNUCommandLineShell { } cfg.storageController}
|
VBoxManage storagectl "$vmName" ${lib.cli.toGNUCommandLineShell { } cfg.storageController}
|
||||||
VBoxManage storageattach "$vmName" --storagectl ${cfg.storageController.name} --port 0 --device 0 --type hdd \
|
VBoxManage storageattach "$vmName" --storagectl ${cfg.storageController.name} --port 0 --device 0 --type hdd \
|
||||||
--medium disk.vmdk
|
--medium disk.vdi
|
||||||
${optionalString (cfg.extraDisk != null) ''
|
${optionalString (cfg.extraDisk != null) ''
|
||||||
VBoxManage storageattach "$vmName" --storagectl ${cfg.storageController.name} --port 1 --device 0 --type hdd \
|
VBoxManage storageattach "$vmName" --storagectl ${cfg.storageController.name} --port 1 --device 0 --type hdd \
|
||||||
--medium data-disk.vmdk
|
--medium data-disk.vdi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
echo "exporting VirtualBox VM..."
|
echo "exporting VirtualBox VM..."
|
||||||
|
|||||||
Reference in New Issue
Block a user