Search code examples
linux-kerneldriverlinux-device-driverubuntu-16.04

How to disable vmwgfx driver without compiling a new kernel on Ubuntu?


I know I can disable it by compiling a new kernel without setting CONFIG_DRM_VMWGFX in config file. But I don't want build a new kernel, can I achieve it by modify some configurations?

I tried to delete vmwgfx.ko from the lib/modules/XXX/kernel/driver directory, then reboot, but the driver works well On Ubuntu 16.04. Why? Is the file elsewhere?

And I also tried to rmmod,but it's not work.

[root@ubuntu:] lsmod |grep vmwgfx
vmwgfx                235405  4 
drm_kms_helper        159169  1 vmwgfx
ttm                    99345  1 vmwgfx
drm                   370825  7 ttm,drm_kms_helper,vmwgfx
[root@ubuntu:] rmmod -f vmwgfx
rmmod: ERROR: ../libkmod/libkmod-module.c:793 kmod_module_remove_module()
could not remove 'vmwgfx': Resource temporarily unavailable
[root@ubuntu:] modprobe -r vmwgfx
modprobe: FATAL: Module vmwgfx is in use.

Solution

  • Finally, I know how to do it.

    The reason for my situation is that the driver's file is stored in initramfs-xxx.img. So we need to rebuild a initramfs-xxx.img.

    1. find file path: modinfo vmwgfx
    filename:       /lib/modules/4.4.0-21-generic/kernel/drivers/gpu/drm/vmwgfx/vmwgfx.ko
    version:        2.9.0.0
    license:        GPL and additional rights
    description:    Standalone drm driver for the VMware SVGA device
    author:         VMware Inc. and others
    srcversion:     AC179B70460E5C5D32AC416
    alias:          pci:v000015ADd00000405sv*sd*bc*sc*i*
    depends:        ttm,drm,drm_kms_helper
    intree:         Y
    vermagic:       4.4.0-21-generic SMP mod_unload modversions 
    parm:           enable_fbdev:Enable vmwgfx fbdev (int)
    parm:           force_dma_api:Force using the DMA API for TTM pages (int)
    parm:           restrict_iommu:Try to limit IOMMU usage for TTM pages (int)
    parm:           force_coherent:Force coherent TTM pages (int)
    parm:           restrict_dma_mask:Restrict DMA mask to 44 bits with IOMMU (int)
    
    1. remove the driver file mv /lib/modules/$(uname -r)/kernel/driver/gpu/drm/vmwgfx/vmwgfx.ko /home/$(whoami)/.

    2. backup your boot img: mv /boot/initrd.img-`uname -r` /home/`whoami`/

    3. rebuld boot img: mkinitrd -f /boot/initrd.img-`uname -r` `uname -r`

    4. reboot

    If you want to remove other build-in driver file, this method works well. If your vm is centos, just choose the correct file path and boot img name.