While removing old kernels to free /boot space we are getting an error: "Read-only file system"

Solution Unverified - Updated -

Issue

  • We are trying to apply quaterly patch to our RHEL servers but getting space issue in the /boot filesystem.
  • While removing old kernel ( dnf remove --oldinstallonly --setopt installonly_limit=2 kernel -y) its throwing an error:

    # dnf remove --oldinstallonly --setopt installonly_limit=2 kernel -y
    Updating Subscription Management repositories.
    
    This system has release set to 9 and it receives updates only for this release.
    
    Dependencies resolved.
    =============================================================================================================================================================================================================================================
    Package                                                 Architecture                               Version                                                      Repository                                                             Size
    =============================================================================================================================================================================================================================================
    Removing:
    kernel                                                  x86_64                                     5.14.0-503.19.1.el9_5                                        @rhel-9-for-x86_64-baseos-rpms                                          0
    kernel-core                                             x86_64                                     5.14.0-503.19.1.el9_5                                        @rhel-9-for-x86_64-baseos-rpms                                         66 M
    kernel-devel                                            x86_64                                     5.14.0-503.19.1.el9_5                                        @rhel-9-for-x86_64-appstream-rpms                                      68 M
    kernel-modules                                          x86_64                                     5.14.0-503.19.1.el9_5                                        @rhel-9-for-x86_64-baseos-rpms                                         33 M
    kernel-modules-core                                     x86_64                                     5.14.0-503.19.1.el9_5                                        @rhel-9-for-x86_64-baseos-rpms                                         27 M
    
    Transaction Summary
    =============================================================================================================================================================================================================================================
    Remove  5 Packages
    
    Freed space: 194 M
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
    Preparing        :                                                                                                                                                                                                                     1/1
    Erasing          : kernel-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                                 1/5
    Running scriptlet: kernel-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                                 1/5
    Erasing          : kernel-modules-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                         2/5
    Running scriptlet: kernel-modules-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                         2/5
    Erasing          : kernel-modules-core-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                    3/5
    Running scriptlet: kernel-core-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                            4/5
    rm: cannot remove '/boot/vmlinuz-5.14.0-503.19.1.el9_5.x86_64': Read-only file system
    rm: cannot remove '/boot/System.map-5.14.0-503.19.1.el9_5.x86_64': Read-only file system
    rm: cannot remove '/boot/config-5.14.0-503.19.1.el9_5.x86_64': Read-only file system
    rm: cannot remove '/boot/.vmlinuz-5.14.0-503.19.1.el9_5.x86_64.hmac': Read-only file system
    rm: cannot remove '/boot/symvers-5.14.0-503.19.1.el9_5.x86_64.gz': Read-only file system
    rm: cannot remove '/boot/initramfs-5.14.0-503.19.1.el9_5.x86_64.img': Read-only file system
    error: %preun(kernel-core-5.14.0-503.19.1.el9_5.x86_64) scriptlet failed, exit status 1
    
    Error in PREUN scriptlet in rpm package kernel-core
    Erasing          : kernel-devel-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                           5/5
    error: kernel-core-5.14.0-503.19.1.el9_5.x86_64: erase failed
    
    Running scriptlet: kernel-devel-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                           5/5
    Verifying        : kernel-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                                 1/5
    Verifying        : kernel-core-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                            2/5
    Verifying        : kernel-devel-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                           3/5
    Verifying        : kernel-modules-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                         4/5
    Verifying        : kernel-modules-core-5.14.0-503.19.1.el9_5.x86_64                                                                                                                                                                    5/5
    Installed products updated.
    Uploading Tracer Profile
    
    Removed:
    kernel-5.14.0-503.19.1.el9_5.x86_64                 kernel-devel-5.14.0-503.19.1.el9_5.x86_64                 kernel-modules-5.14.0-503.19.1.el9_5.x86_64                 kernel-modules-core-5.14.0-503.19.1.el9_5.x86_64
    Failed:
    kernel-core-5.14.0-503.19.1.el9_5.x86_64
    
    Error: Transaction failed
    

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content