title: Testing systemd during Development in Virtualization
category: Documentation for Developers
layout: default
SPDX-License-Identifier: LGPL-2.1-or-later
---
# Testing systemd during Development in Virtualization
For quickly testing systemd during development it us useful to boot it up in a container and in a QEMU VM.
## Testing in a VM
Here's a nice hack if you regularly build and test-boot systemd, are gutsy enough to install it into your host, but too afraid or too lazy to continuously reboot your host.
This will boot your local host system as a throw-away VM guest.
It will take your main harddisk, boot from it in the VM, allow changes to it, but these changes are all just buffered in memory and never hit the real disk.
Any changes made in this VM will be lost when the VM terminates.
I have called this script "q", and hence for test booting my own system all I do is type the following command in my systemd source tree and I can see if it worked.
The first three lines are necessary to ensure that the kernel's disk caches are all synced to disk before qemu takes the snapshot of it.
Yes, invoking "umount /" will sync your file system to disk as a side effect, even though it will actually fail.
When the machine boots up the file system will still be marked dirty (and hence you will get an fsck, usually), but it will work fine nonetheless in virtually all cases.