Having wrestled with this for several days, I'm going to explain how to enable auto-resize in desktops where it doesn't work out-of-the-box, which turns out to be most of them. This is somewhat advanced stuff, but not rocket surgery. Besides, a VM at less than full size is frustrating, so worth a little effort to get running correctly. I assume you have installed qemu-guest-agent and spice-vdagent, as mentioned in the main tutorial.
A simple solution, which works in most cases (but not KDE), is to run xrandr --output Virtual-1 --auto in Terminal. Has to be run after each boot, though, so not convenient. Can be placed in a panel or desktop launcher, but that's only a little more convenient. To my mind, the best solution is crontab, which will run the command string automatically at boot. First, using your favorite text editor, create a file with these two lines:Save in your home folder. Can be called almost anything. I use auto-resize.sh. Then make the file executable: chmod +x auto-resize.sh. Notice, no sudo. Not needed, it's your file.
Next, run crontab -e (again, no sudo). At prompt, select nano as text editor. Add a new line at end of the file: @reboot sh /home/pbear/auto-resize.sh (replace pbear with your username, of course). Ctrl-O to save (write-Out) ; tap Enter key to confirm over-write file ; Ctrl-X to exit. FYI, user crontab files are save in /var/spool/cron/crontabs, but shouldn't be edited directly. Use crontab -e. Reboot to test.
KDE is more complicated. This is the best solution I've seen, so it's what I'm going to describe here.
If anyone knows (or figures out) the trick, please share. Meanwhile, it's just a VM. Take the easy way out and run it with Plasma (X11).
A simple solution, which works in most cases (but not KDE), is to run xrandr --output Virtual-1 --auto in Terminal. Has to be run after each boot, though, so not convenient. Can be placed in a panel or desktop launcher, but that's only a little more convenient. To my mind, the best solution is crontab, which will run the command string automatically at boot. First, using your favorite text editor, create a file with these two lines:
Code:
#!/bin/bashxrandr --output Virtual-1 --auto
Next, run crontab -e (again, no sudo). At prompt, select nano as text editor. Add a new line at end of the file: @reboot sh /home/pbear/auto-resize.sh (replace pbear with your username, of course). Ctrl-O to save (write-Out) ; tap Enter key to confirm over-write file ; Ctrl-X to exit. FYI, user crontab files are save in /var/spool/cron/crontabs, but shouldn't be edited directly. Use crontab -e. Reboot to test.
KDE is more complicated. This is the best solution I've seen, so it's what I'm going to describe here.
- Modify VM settings: Display Spice > Address > Localhost only ; Video > QXL. Other settings might work also, but the defaults don't.
- Run sudo systemctl status spice-vdagent. Notice enabled but inactive (dead). This is the main problem.
- Run kate /usr/lib/systemd/user/plasma-core.target ; add spice-vdagent.service to end of Wants= line ; enter sudo password when prompted.
- Create auto-resize.sh file as described above, saving in Home. Make executable.
- Settings > Startup and Shutdown > Autostart > Add... > Add Application... > Open file dialog > choose script + tick box to Run in Terminal. Reboot to test.
If anyone knows (or figures out) the trick, please share. Meanwhile, it's just a VM. Take the easy way out and run it with Plasma (X11).
Statistics: Posted by pbear — 2024-05-07 05:55 — Replies 12 — Views 508