-
-
Notifications
You must be signed in to change notification settings - Fork 506
How to create a DietPi image for VirtualBox
MichaIng edited this page Apr 11, 2019
·
12 revisions
-
New
machine: Name e.g.DietPi_VirtualBox-x86_64-Stretch
,Linux
,Debian (64-bit)
-
Memory size: 1024 MB
which is default on VirtualBox and for our VMs as well. 2048 MB + GPU memory (= 2064 MB default) would be necessary to avoid swapfile auto-creation, but as far as I read, using a swapfile on guests as well (beside host) is not uncommon, as guest swap system is able to decide more effectively what to swap. -
Create a virtual hard disk now
=>Create
-
File size: 8 GB
as default, or adjust as desired. It is anyway just an upper limit in combination with dynamic allocation and can be increased afterwards. -
VDI
default native VirtualBox format, as this can be enlarged, compacted and converted better with VirtualBox tools -
Dynamically allocated
to reduce initial disk size. For best performance it could be beneficial to choose Fixed size on end machine. But especially when sharing the image through the web, for transfer, packing and unpacking this is not recommended. =>Create
- Select the new machine and
Settings
>System
>Motherboard
- Deselect
Floppy
- Chipset:
ICH9
, the modern one, supporting USB2+3, I never had issues with it -
Pointing device: PS/2 Mouse
, which allows disabling USB, although leave USB enabled to allow live mounting on first boot - Switch to
Acceleration
and assureVT-x/AMD-V + Nested Paging
is enabled. -
Display
>Display Memory: 16 MB
as default for initial headless server. - Graphics Controller:
VBoxVGA
since the (on VBox 6) defaultVMSVGA
(emulates VMware VGA) causes a crash on boot when selecting certain fixed GFXPAYLOAD (resolution), regardless of memory.VBoxVGA
has less features but is sufficient for default server setup. When using any video features the display options need to be tweaked anyway. - Disable
Audio
and(https://github.com/Fourdee/DietPi/issues/2093#issuecomment-423964511) as default.USB
-
Network
>Attached to: Bridged Adapter
to allow local SSH,Advanced
>Adapter Type: virtio-net
, for best performance.
- Debian netboot/mini.iso: https://deb.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/mini.iso
- In case remove the dedicated IDE controller and add an optical drive to the existing SATA controller.
- Mount/Select the downloaded
iso
file to thisoptical drive
. - Start the VM.
- NB: The following steps can be automated, however the effort on netboot installers is too high to have any benefit over manually going through the installation for a single VM: https://www.debian.org/releases/stable/amd64/apbs01.html.en#preseed-methods
-
Advanced options
>Expert install
-
Choose language
>Englisch
>United Kingdom
>en_GB.UTF-8
>continue
(select NO additional locales) -
Configure the keyboard
>British English
Detect network hardware
-
Deselect any
Modules to load
as we don't require them. -
Configure the network
>Yes
(auto-configure) Hostname: DietPi
Domain name: <leave empty>
- APT mirror: Just use one near to your location or
deb.debian.org
. It will be overwritten anyway by DietPi-PREP, as actually most other settings as well 😉. - Debian version to install:
stretch - stable
-
Download installer components
: deselect everything >continue
-
Set up users
> Enable shadow passwords?Yes
> Allow root login?Yes
> password:dietpi
- Create a normal user account now?
No
-
Configure the clock
> Use NTP?Yes
> leave default mirror0.debian.pool.ntp.org
> time zone:UTC
-
Detect disks
> Deselect anyModules to load
>Partition discs
> Select the drive > Create new empty partition table?Yes
>msdos
> Select the partition >Create a new partition
> New partition size:max
>Primary
- Verify:
ext4
and mount point/
> Done setting up the partition > Finish partitioning >No
return due to missing swap partition >Yes
write to disk Install the base system
- Select kernel package:
linux-image-amd64
- Select
targeted
since no generic driver installation is required for virtual machines. -
Configure the package manager
>No
nonfree, contrib and especiallyNo
source repository! -
Deselect
security updates
,release updates
andbackported software
for now. These will be re-added by DietPi-PREP later. -
Select and install software
>No
virtualbox-guest extension andNo
survey (user should decide this oneself later) - Deselect all additional software
-
Install the GRUB boot loader
>Yes
to master boot record > to the only available partition (/dev/sda
) >Not
to the EFI removable media path, actually no idea why it detects EFI, as it was not selected on machine and is definitely not available afterwards... -
Finish the installation
> set to UTC?Yes
-
BEFORE
Continue
: Unplug the optical drive (context menu on ROM symbol at button,Remove disc
>Force removal
!), to prevent reboot into installer >Continue
- Login as root:dietpi
- apt update; apt install -y ca-certificates curl dropbear-run
- Connect via SSH (IP:
ip a
) for easier copy&paste etc.
bash -c "$(curl -sSL https://raw.githubusercontent.com/MichaIng/DietPi/master/PREP_SYSTEM_FOR_DIETPI.sh)"
- Git branch:
master
- Enter your name to be shown as image creator within DietPi banner credits.
- Enter
Debian mini.iso
as this was our base image above. - Device:
20 : x86_64 VM
- Deselect WLAN functionality for VMs as they virtualise Ethernet adapters for network only.
- Distro version:
4: Stretch
- In case purge old kernel packages, e.g.
linux-image-4.9.0-4-amd64
, or manually remove them from/lib/modules/
as mentioned by the last script[ INFO ]
output as well. shutdown now
- Mount virtual drive (vdi) to another Linux system or virtual machine, use
zerofree -v /dev/sdx1
to reduce the final image size. In case:apt -y install zerofree
- To reduce the actual image file size as well (which does not affect the exported appliance/download size), run:
VBoxManage modifyhd --compact "[drive]:\[path_to_image_file]\DietPi_VirtualBox-x86_64-Stretch.vdi"
- On VirtualBox you might want to remove your default Bridged Network host adapter. For this, close VirtualBox, open
DietPi_VirtualBox-x86_64-Stretch.vbox
(and to be sure as wellDietPi_VirtualBox-x86_64-Stretch.vbox-prev
) and change the similar line to<BridgedInterface name="eth0"/>
. As there is no way to keep the bridged networking setting without saving a certain interface name as well, andeth0
is at least the most general one that will fit for most Linux hosts. All others will face an error message and the option to adjust the interface to an available one. No bid deal, no better way to handle this. After editing the files, you MUST NOT open the VMs settings any more, otherwise it will insert your available interface again. Directly open the top menu to export the appliance first. - Export the whole appliance with OVF 1.0 format for compatibility reasons.
- Create hashes, e.g. using HashMyFiles, saving the report to
hash.txt
. - Pack VM export file(s) + hash.txt with 7zip for high compression rate.
Project management
Extend
- DietPi-Software list
- DietPi TCP/UDP port usage list
- How to add a new software title
- How to create a DietPi image for Raspberry Pi
- How to create a DietPi image for VirtualBox
- How to create a DietPi image for VMware
- How to create a DietPi image for Parallels (macOS)
- How to create a DietPi image for x86_64 PCs (BIOS)
- How to create a DietPi image for x86_64 PCs (UEFI)
Knowledge Base