# SAP Kernel Upgrade Steps in Linux: Command Generator

> Source: https://netray.co/tools/sap-kernel-upgrade-linux-command-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in SID, instance numbers, paths and archive names and get the ordered shell commands for a kernel patch on an ABAP system or SAP Web Dispatcher on Linux.

## Category

sap

## Erp

SAP NetWeaver / Basis

## Audience

- SAP Basis administrator
- Linux administrator

## Tool

**Kind:** template

**Output:** code

**Language:** text

**Fields:**

#### SID

**Key:** sid

**Type:** text

**Default:** PRD

#### sidadm user

**Key:** sidadm

**Type:** text

**Default:** prdadm

#### PAS instance number

**Key:** pas

**Type:** text

**Default:** 00

#### ASCS instance number

**Key:** ascs

**Type:** text

**Default:** 01

#### Kernel directory

**Key:** kdir

**Type:** text

**Default:** /usr/sap/PRD/SYS/exe/uc/linuxx86_64

#### Staging directory with the SAR files

**Key:** stage

**Type:** text

**Default:** /sapmedia/kernel_793_pl200

#### SAPEXE archive file name

**Key:** sapexe

**Type:** text

**Default:** SAPEXE.SAR

**Help:** Use the exact file name you downloaded; SAP download names include the patch level and a numeric suffix.

#### SAPEXEDB archive file name

**Key:** sapexedb

**Type:** text

**Default:** SAPEXEDB.SAR

**Help:** Database-dependent part for your database, exact downloaded file name.

#### Database

**Key:** db

**Type:** select

**Options:**

- SAP HANA
- Oracle
- SAP ASE (Sybase)
- SAP MaxDB
- IBM Db2

**Default:** SAP HANA

#### IGS archive (optional)

**Key:** igs

**Type:** text

**Default:** none

**Help:** File name of igsexe archive, or none.

#### Web Dispatcher instance number

**Key:** wd

**Type:** text

**Default:** 10

**Blocks:**

#### 0. Preparation (as {{sidadm}})

**Body:** # System {{sid}}, database {{db}}
# List archive contents before touching anything
cd {{stage}}
SAPCAR -tvf {{sapexe}} | head -20
SAPCAR -tvf {{sapexedb}} | head -20
df -h {{kdir}}

# Record the current kernel
disp+work -v | grep -E 'kernel release|patch number'
sapcontrol -nr {{pas}} -function GetVersionInfo
sapcontrol -nr {{pas}} -function GetSystemInstanceList

#### 1. Stop the SAP system (as {{sidadm}})

**Body:** # Stops all instances of {{sid}} (ASCS, PAS, AAS). The {{db}} database can stay up.
sapcontrol -nr {{pas}} -function StopSystem ALL
sapcontrol -nr {{pas}} -function WaitforStopped 600 2
sapcontrol -nr {{pas}} -function GetSystemInstanceList   # all GRAY

# Stop sapstartsrv for every instance on this host so executables are not locked
sapcontrol -nr {{pas}} -function StopService
sapcontrol -nr {{ascs}} -function StopService

# Remove leftover IPC objects
cleanipc {{pas}} remove
cleanipc {{ascs}} remove

#### 2. Back up the kernel directory (as {{sidadm}})

**Body:** cp -rp {{kdir}} {{kdir}}_bak_$(date +%Y%m%d)
ls -ld {{kdir}}_bak_*

#### 3. Extract the new kernel (as {{sidadm}})

**Body:** cd {{kdir}}
SAPCAR -xvf {{stage}}/{{sapexe}}
SAPCAR -xvf {{stage}}/{{sapexedb}}
# Optional IGS: skip if the field says none
# SAPCAR -xvf {{stage}}/{{igs}}

#### 4. Set ownership and permissions (as root)

**Body:** cd {{kdir}}
./saproot.sh {{sid}}
ls -l icmbnd sapuxuserchk   # owned by root with the set-user-ID bit after saproot.sh

#### 5. Start and verify (as {{sidadm}})

**Body:** sapcontrol -nr {{ascs}} -function StartService {{sid}}
sapcontrol -nr {{pas}} -function StartService {{sid}}
sapcontrol -nr {{pas}} -function StartSystem ALL
sapcontrol -nr {{pas}} -function WaitforStarted 900 5
sapcontrol -nr {{pas}} -function GetSystemInstanceList   # all GREEN

# Confirm the new patch level
disp+work -v | grep -E 'kernel release|patch number'
sapcontrol -nr {{pas}} -function GetVersionInfo
# Then check SM51 (release notes per server) and SM21 / dev_w0 for errors

#### Variant: standalone SAP Web Dispatcher (as the Web Dispatcher sidadm)

**Body:** sapcontrol -nr {{wd}} -function GetVersionInfo
sapcontrol -nr {{wd}} -function Stop
sapcontrol -nr {{wd}} -function WaitforStopped 300 2
sapcontrol -nr {{wd}} -function StopService
# back up and extract the SAPWEBDISP archive into the Web Dispatcher exe directory
# run saproot.sh or set icmbnd permissions as root if the archive contains it
sapcontrol -nr {{wd}} -function StartService <WDSID>
sapcontrol -nr {{wd}} -function Start
sapcontrol -nr {{wd}} -function GetVersionInfo

**Notes:** Verify for your landscape: the kernel line and patch you need (SAP Note 2083594 lists kernel versions and patch levels, SAP Note 19466 covers downloading kernel patches), the SAPEXE and SAPEXEDB archive names, and the kernel path (older systems may use /sapmnt/SID/exe). On start, sapcpe copies the central kernel to each instance exe directory. In a Pacemaker or other HA cluster, put the cluster in maintenance mode before stopping instances. Repeat steps on every host that has its own local kernel.

## Content

**Intro:** This generator writes the ordered Linux commands for an SAP kernel patch on an ABAP system or standalone SAP Web Dispatcher, using sapcontrol, SAPCAR and saproot.sh. Fill in your SID, instance numbers, paths and the archive names you downloaded.

**Sections:**

#### How to use it

**Body:** Enter the SID, the sidadm user, the PAS and ASCS instance numbers, the central kernel directory and the staging directory that holds the SAR files. Paste the exact SAPEXE and SAPEXEDB file names from your download basket so the extract lines run as written. Run block 0 a day before the window: it lists the archive contents, checks free space and records the current kernel release and patch number for your change ticket. Blocks 1 to 5 are the downtime steps, in order. Each block says which user runs it; only saproot.sh needs root.

**Bullets:**

- Keep the backup directory until the system has run a full business cycle.
- Patch the database-dependent part (SAPEXEDB) together with SAPEXE.
- Patch application server hosts with local kernels separately.

#### Where the kernel lives

**Body:** On current NetWeaver systems the central kernel is in /usr/sap/SID/SYS/exe/uc/linuxx86_64, which is usually a link into /sapmnt/SID/exe. Each instance has its own exe directory under /usr/sap/SID/<instance>/exe, filled by sapcpe from the central directory when the instance starts. That is why you only extract into the central directory and why sapstartsrv must be stopped: it runs from the instance copy and holds files open. sapcontrol talks to sapstartsrv on port 5<nr>13, so StopService is the last sapcontrol call that works until you start the service again.

#### Worked example

**Body:** System PRD has ASCS 01 and PAS 00 on one host with HANA as the database. After block 0 shows kernel release 793 and the current patch, StopSystem ALL stops ABAP instances and WaitforStopped 600 2 polls every 2 seconds for up to 600 seconds. GetSystemInstanceList should show every instance GRAY before you stop the services. The backup is a dated copy of the kernel directory. Both archives are extracted into the kernel directory, root runs saproot.sh PRD, and StartService plus StartSystem ALL bring PRD back. disp+work -v must now show the new patch number.

#### Gotchas and how to check the result

**Body:** The most common failure is a missing saproot.sh run: icmbnd then cannot bind ports below 1024 and ICM fails. The second is extracting SAPEXE without the matching SAPEXEDB, which leaves an old database library. If an instance does not start, look in the work directory (dev_disp, dev_w0, sapstart.log) and compare against the backup. To roll back, stop again, move the backup directory into place and restart. After the start, check SM51 for the release on every server, SM21 for errors and transaction SICK.

**Cta:** If you want your Basis team to ask your SAP landscape questions such as kernel levels or failed jobs in plain English on your own servers, we can set that up.

**Faq:**

#### What are the SAP kernel upgrade steps in Linux?

**Answer:** Check the current kernel with disp+work -v, stop the system with sapcontrol StopSystem ALL and wait for it, stop sapstartsrv per instance, back up the kernel directory, extract SAPEXE and SAPEXEDB with SAPCAR -xvf, run saproot.sh SID as root, then start the services and the system and verify the new patch level.

#### Do I need to stop the database for a kernel patch?

**Answer:** Normally no. The kernel patch replaces SAP executables, and StopSystem ALL stops the SAP instances, not a separate HANA, Oracle or Db2 database. Stop the database only if you are also patching the database client or the database itself, or if your vendor documentation says so.

#### How do I upgrade the SAP Web Dispatcher kernel?

**Answer:** Stop the Web Dispatcher instance with sapcontrol -nr <wd> -function Stop, stop its sapstartsrv with StopService, back up its exe directory, extract the SAPWEBDISP archive there, fix icmbnd permissions as root, then StartService and Start. Confirm with GetVersionInfo. The Web Dispatcher is patched independently of the ABAP kernel.

#### Why does my instance not start after the kernel upgrade?

**Answer:** Check dev_disp, dev_w0 and sapstart.log in the instance work directory. Typical causes are a skipped saproot.sh, a missing SAPEXEDB extract, a kernel line not supported for your NetWeaver release, or sapstartsrv still running the old binary. Restore the backup directory to get running again while you investigate.

## Search terms

sap kernel upgrade steps in linux, how to upgrade sap kernel in linux, sap kernel upgrade in linux step by step, sap kernel patch upgrade in linux, how to upgrade sap web dispatcher kernel, sapcar extract kernel, saproot.sh, sapcontrol stopsystem

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
