I received [an answer](https://tex.stackexchange.com/a/530044/2288) on TEX.SX as follows:
```
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepackage{siunitx}
% http://tex.stackexchange.com/a/15002/100384
\newcommand*{\getlength}[2]{%
% Convert to `cm` and round to two fractional digits:
\pgfmathsetmacro#1{round(0.0351459804*#2)}%
}
\newsavebox{\gridbox}
\savebox\gridbox{\begin{tikzpicture}
\pgfmathsetmacro{\width}{\paperwidth-2cm}
\pgfmathsetmacro{\height}{\paperheight-2cm}
% we will need some length in `cm`, without units, and rounded
\getlength{\yMax}{\height}
\getlength{\xMax}{\width}
\begin{axis}[
set layers,
width=\width, height=\height,
scale only axis, name=border,
x = 1cm, y = 1cm,
xtick={0,1,...,\xMax},
ytick={0,1,...,\yMax},
minor xtick={0,0.1,0.2,...,\xMax},
minor ytick={0,0.1,0.2,...,\yMax},
tick style = {line width = 0.6pt, black!40!white},
minor tick style = {draw = none},
major tick style = {draw = none},
ticklabel style = {draw = none},
xticklabels=\empty, %xlabel = \empty,
yticklabels=\empty, %ylabel = \empty,
axis line style = {-latex},
grid = both,
minor grid style={line width=0.2pt, black!20!white},
major grid style={line width=0.6pt, black!60!white},
ymin=0, ymax=\yMax,
xmin=0, xmax=\xMax,
]
%\begin{pgfonlayer}{axis grid}% redundant
%\draw[line width=0.40pt, step=0.5cm, black!40!white] (axis cs: 0, 0) grid (axis cs: \xMax, \yMax);
%\end{pgfonlayer}
\end{axis}
\pgfresetboundingbox
\path (border.south west) (border.north east);
\end{tikzpicture}}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\usebox\gridbox};
\end{tikzpicture}
\end{document}
```
Or
```
\documentclass[a4paper]{article}
\usepackage{pgfplots}
\usepackage{siunitx}
% http://tex.stackexchange.com/a/15002/100384
\newsavebox{\gridbox}
\savebox\gridbox{\begin{tikzpicture}
% we will need some length in `cm`, without units, and rounded
\pgfmathsetmacro{\xMax}{round((\paperwidth-2cm)/1cm)}
\pgfmathsetmacro{\yMax}{round((\paperheight-2cm)/1cm)}
\begin{axis}[
set layers,
width=\paperwidth-2cm, height=\paperheight-2cm,
scale only axis, name=border,
x = 1cm, y = 1cm,
xtick={0,1,...,\xMax},
ytick={0,1,...,\yMax},
minor xtick={0,0.1,0.2,...,\xMax},
minor ytick={0,0.1,0.2,...,\yMax},
tick style = {line width = 0.6pt, black!40!white},
minor tick style = {draw = none},
major tick style = {draw = none},
ticklabel style = {draw = none},
xticklabels=\empty, %xlabel = \empty,
yticklabels=\empty, %ylabel = \empty,
axis line style = {-latex},
grid = both,
minor grid style={line width=0.2pt, black!20!white},
major grid style={line width=0.6pt, black!60!white},
ymin=0, ymax=\yMax,
xmin=0, xmax=\xMax,
]
%\begin{pgfonlayer}{axis grid}% redundant
%\draw[line width=0.40pt, step=0.5cm, black!40!white] (axis cs: 0, 0) grid (axis cs: \xMax, \yMax);
%\end{pgfonlayer}
\end{axis}
\pgfresetboundingbox
\path (border.south west) (border.north east);
\end{tikzpicture}}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[overlay,remember picture]
\node at (current page.center) {\usebox\gridbox};
\end{tikzpicture}
\end{document}
```