Move page number and headigns to margin

How can I move page number and headings to the margin using KOMA-Script?

I'm looking for this layout:

where red circle means position of the page number after the section (or chapter) name.

So far i have following code:

\documentclass[12pt,parskip=half, DIV=calc]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, libertine}

\usepackage{geometry}
\geometry{includemp,showframe}

\usepackage{blindtext}

\begin{document}
\section{test}
\blindtext[1]
\marginpar{\blindtext[1]}
\blindtext[3]
\end{document}


Note that scrpage2 is outdated. Its successor is package scrlayer-scrpage. This package sets \pagestyle{scrheadings} automatically.

\documentclass[12pt,parskip=half]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, libertine}

\usepackage{geometry}
\geometry{includemp,showframe}

\usepackage[
]{scrlayer-scrpage}% modern version

\usepackage{blindtext}

\begin{document}
\section{test}
\blindtext[1]
\marginpar{\raggedright No Wombat can be found here, please be aware of that}
\blindtext[3]
\end{document}


With outdated package scrpage2 you have to activate the page style scrheadings manually.

\documentclass[12pt,parskip=half]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern, libertine}

\usepackage{geometry}
\geometry{includemp,showframe}


• Maybe better \usepackage[headsepline, headwidth=textwithmarginpar, footwidth=textwithmarginpar]{scrlayer-scrpage}. Commands \setheadwidth and \setfootwidth are not mentioned in the documentation of scrlayer-scrpage. AFAIK \setheadwidth and \setfootwidth are defined for compatibility with scrpage2. Both commands are not mentioned in the documentation. They set only the related KOMA options.