Add packages to Fedora VM on a Mac
🗓 Previously on Mac2net – I installed Fedora on a Mac
Add packages to Fedora VM on a Mac
In a similar way to adding packages to Brew on the Mac using a shell script, it is easy to add packages to the Fedora VM. After the VM is installed the only way to manage it is through a shell in the terminal which is rather limiting. We can use the lima.yaml file which was generated from the template and is stored in ~/.lima/default[or VM name if there are more than two] . This is what it looks like:
minimumLimaVersion: 1.1.0
images:
- location: https://download.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/x86_64/images/Fedora-Cloud-Base-Generic-42-1.1.x86_64.qcow2
arch: x86_64
digest: sha256:e401a4db2e5e04d1967b6729774faa96da629bcf3ba90b67d8d9cce9906bec0f
- location: https://download.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/aarch64/images/Fedora-Cloud-Base-Generic-42-1.1.aarch64.qcow2
arch: aarch64
digest: sha256:e10658419a8d50231037dc781c3155aa94180a8c7a74e5cac2a6b09eaa9342b7
- location: https://dl.fedoraproject.org/pub/alt/risc-v/release/42/Cloud/riscv64/images/Fedora-Cloud-Base-Generic-42.20250414-8635a3a5bfcd.riscv64.qcow2
arch: riscv64
digest: sha256:537c67710f4f1c9112fecaafafc293b649acd1d35b46619b97b5a5a0132241b0
mounts:
- location: "~"
- location: "{{.GlobalTempDir}}/lima"
mountPoint: /tmp/lima
writable: true
# # NOTE: Intel Mac with macOS prior to 15.5 requires setting vmType to qemu
# # https://github.com/lima-vm/lima/issues/3334
# vmType: qemu
Some important dnf commands
We can modify lima.yamlto install and configure a whole bunch of stuff at the time Lima boots the VM. Before going into this, let’s review dnf and a few fundamental commands.
First of all, dnf organises Fedora native packages three ways [probably more 🤔]:
- Individual packages which also installs dependencies
- Groups which install a set of packages and dependencies together
- Groups
--with-optionalwhich also installs a set of secondary packages and their dependencies.
The dnf group command…
$dnf group --help
Usage:
dnf5 [GLOBAL OPTIONS] group <COMMAND> ...
Query Commands:
list List comps groups
info List comps groups
Software Management Commands:
install Install comp groups, including their packages
remove Remove comp groups, including their packages
upgrade Upgrade comp groups, including their packages
$ dnf group list --help
Usage:
dnf5 [GLOBAL OPTIONS] group list [OPTIONS] [ARGUMENTS]
Options:
--available Show only available groups.
--installed Show only installed groups.
--hidden Show also hidden groups.
--contains-pkgs=PACKAGE_NAME,... Show only groups containing packages with specified names. List option, supports globs.
You can list all available groups this way…
$ dnf dnf group list --hidden
Updating and loading repositories:
Fedora 42 - aarch64 - Updates 100% | 15.7 KiB/s | 6.5 KiB | 00m00s
Repositories loaded.
ID Name Installed
networkmanager-submodules Common NetworkManager Submodules no
#list continues…
I have attached here a list of all the groups available from the Fedora repository. So what is installed by Lima?
# NOTE: always use --hidden as you can see the first command without this did not show all the groups installed
$ dnf group list --installed
Updating and loading repositories:
Repositories loaded.
ID Name Installed
container-management Container Management yes
$ dnf group list --installed --hidden
Updating and loading repositories:
Repositories loaded.
ID Name Installed
cloud-bootloader-tools Bootloader tools for Cloud images yes
cloud-server Cloud Server Tools yes
container-management Container Management yes
core Core yes
It is very easy to get details on both a Fedora package and a Fedora group package. I have attached a sample of both here.
$ dnf info ncdu
Updating and loading repositories:
Repositories loaded.
Available packages
Name : ncdu
Epoch : 0
Version : 2.9.1
Release : 1.fc42
Architecture : aarch64
Download size : 268.3 KiB
Installed size : 576.7 KiB
Source : ncdu-2.9.1-1.fc42.src.rpm
Repository : updates
Summary : Text-based disk usage viewer
URL : https://dev.yorhel.nl/ncdu/
License : MIT
Description : ncdu (NCurses Disk Usage) is a curses-based version of the well-known 'du',
: and provides a fast way to see what directories are using your disk space.
Vendor : Fedora Project
$ dnf group info editors
Updating and loading repositories:
Repositories loaded.
Id : editors
Name : Editors
Description : Sometimes called text editors, these are programs that allow you to create and edit text files. This includes Emacs and Vi.
Installed : no
Order :
Langonly :
Uservisible : yes
Repositories : fedora, updates
Optional packages : emacs
: emacs-auctex
: emacs-bbdb
: emacs-vm
: geany
: jed
: joe
: leafpad
: nano
: nedit
: poedit
: vim-X11
: vim-enhanced
: zile
Let’s modify Lima’s Fedora template
Below is a continuation of the above lima.yaml that can be pasted at the bottom of the file, which will install and configure a whole bunch of stuff at the time Lima boots the VM. For reference, I have attached a markdownversion of the YAML file and dnf info and dnf group info of all the packages in the template.
This template will do the following:
- Fedora
- Install several Fedora group packages
- Install several Fedora packages
- Enable and start several packages and add services to the firewall
- Setup a root password and permit root login to Cockpit. Much more on Cockpit will come in future posts.
- Hardware config: While I keep the VM running on my MBA M2 as power efficient as possible with just 2 CPUs and 4GiB of RAM, the VM running on my I7 Mac mini has 4 CPUs and 12GiB of RAM.
- Network access: the config below assumes you are installing Fedora on your own Mac and not a remote one.
- VNC: I do not use the VNC functions of Lima. Instead I install TigerVNC and the lightweight XFCE desktop. VNC configuration is not contained in this script. This will be covered in a future post. Access to a desktop running in a Fedora VM on Lima opens up additional possibilities for connecting the VM to a real Fedora server and its VMs.
Immediately after the installation is finished, it is necessary to comment out the bash script segment of the YAML or it will rerun every time the Fedora VM is booted by Lima and then
rebootthe VM. If it seems that the installer timed out before completing, just stop and start the VM which will finish the job before disabling the bash script.
# CPUs
# 🟢 Builtin default: min(4, host CPU cores)
cpus: null
# Memory size
# 🟢 Builtin default: min("4GiB", half of host memory)
memory: null
# OS: "Linux".
# 🟢 Builtin default: "Linux"
os: Linux
# The instance can get routable IP addresses from the vmnet framework using
# https://github.com/lima-vm/socket_vmnet.
# 🟢 Builtin default: []
networks:
# Lima can manage daemons for networks defined in $LIMA_HOME/_config/networks.yaml
# automatically. The socket_vmnet binary must be installed into
# secure locations only alterable by the "root" user.
# - lima: shared
# # MAC address of the instance; lima will pick one based on the instance name,
# # so DHCP assigned ip addresses should remain constant over instance restarts.
# macAddress: ""
# # Interface name, defaults to "lima0", "lima1", etc.
# interface: ""
# # Interface metric, lowest metric becomes the preferred route.
# # Defaults to 100. Builtin SLIRP network uses 200.
# metric: 100
#
# Lima can also connect to "unmanaged" networks addressed by "socket". This
# means that the daemons will not be controlled by Lima, but must be started
# before the instance. The interface type (host, shared, or bridged) is
# configured in socket_vmnet and not in lima.
# - socket: "/var/run/socket_vmnet"
# The "vzNAT" IP address is accessible from the host, but not from other guests.
# Needs `vmType: vz`
- vzNAT: true
# The host agent implements a DNS server that looks up host names on the host
# using the local system resolver. This means changing VPN and network settings
# are reflected automatically into the guest, including conditional forward,
# and mDNS lookup. By default, only IPv4 addresses will be returned. IPv6 addresses
# can only work when using a vmnet network interface and the host has working
# IPv6 configured as well.
hostResolver:
# 🟢 Builtin default: true
enabled: null
# 🟢 Builtin default: false
ipv6: true
provision:
- mode: system
script: |
#!/bin/bash
dnf -y install tigervnc*
dnf -y install *geolite*
dnf -y install konsole
dnf -y install dolphin
dnf -y install pandoc
dnf -y install kcron
dnf -y install pcp-zeroconf
dnf -y install cargo
dnf -y install fastfetch
dnf -y install firefox
dnf -y install php-devel
dnf -y install glances
dnf -y install bpytop
dnf -y install bandwhich
dnf -y install ranger
dnf -y install hdparm
dnf -y install mc
dnf -y install ncdu
dnf -y install grsync
dnf -y install blivet-gui
dnf -y install btop
dnf -y install nmap
dnf -y install lshw
dnf -y install switchdesk switchdesk-gui
dnf -y install duf
dnf -y install btrfs-assistant
dnf -y install borgmatic
dnf -y install vorta
dnf -y install NetworkManager-tui
dnf -y install gnome-system-monitor
dnf -y install gnome-disk-utility
dnf -y install bash-color-prompt
systemctl enable cockpit.socket
systemctl start cockpit.socket
systemctl unmask firewalld
systemctl start firewalld
systemctl enable firewalld
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=cockpit
firewall-cmd --permanent --add-service=vnc-server
firewall-cmd --reload
sed -i '2s/^/# /' /etc/cockpit/disallowed-users
echo "[root password here]" | passwd --stdin root
What’s next…
There are still some open issues that I will tackle in the next group of posts.
- Introducing some handy
cliandtuiutilities - Sorting out the networking which involves installing another Brew package.
- Configuring and accessing the VM by VNC
- Setting up the terminal with some helpful plugins and configurations
- Demonstrating Cockpit
- Setting up a command line based editor and using it for configuring
cron - Configuring backup and file syncing
