Hyper-V: Change the screen resolution in a CentOS or RHEL virtual machine
I was considering switching back to GNU/Linux as my desktop OS. My previous stint with GNU/Linux lasted five years before I returned to Windows. This time, I decided to try CentOS 7, whose long support lifecycle made it appealing for a development machine.
Before committing to the switch, I wanted to see how the distribution worked out of the box and test the development tools and applications I needed. I installed CentOS 7 in a Hyper-V virtual machine.
After installation, the display resolution was set to 1152×864. I couldn’t change it through either KDE System Settings or the Hyper-V virtual machine settings.
After some digging, I learned that the Hyper-V framebuffer driver accepts a screen resolution through a kernel boot parameter. CentOS provides grubby for managing boot entries, so I could set the parameter without editing grub.cfg manually.
To set the resolution, open a terminal inside the virtual machine and switch to the root account:
su -Then set the desired resolution and reboot:
grubby --update-kernel=ALL --args="video=hyperv_fb:1280x1024"
rebootReplace 1280x1024 with the resolution you want to use. The --update-kernel=ALL option updates the boot arguments for all existing kernel entries. The new resolution takes effect after the virtual machine reboots.
These steps describe my CentOS 7 setup. For a later RHEL example, see Red Hat’s guide to changing the Hyper-V screen resolution in RHEL 8.
For more information about the command’s options, run man grubby.