With a Riemann-integrable function $f:[a,b]\to\Bbb R$, we are given that we know for every $\sigma\gt 0$ there exists a partition $\mathcal P$ with $N$ sub-intervals $[x_0,x_1],[x_1,x_2],\dots,[x_{N-1},x_N]$ such that $U(f,\mathcal P)-L(f,\mathcal P)\lt\sigma$. Let such a $\sigma_0,\mathcal P_0,N_0$ be given satisfying these conditions for a given $f$. The Upper and Lower sums arise from the Darboux integral, and are defined as follows:
$$\begin{align}M_i &= \sup_{x\in[x_{i-1},x_i]}f(x)\\
m_i &= \inf_{x\in[x_{i-1},x_i]}f(x)\\
U(f,\mathcal P_0)&=\sum_{i=1}^{N_0}(x_i-x_{i-1})M_i\\
L(f,\mathcal P_0)&=\sum_{i=1}^{N_0}(x_i-x_{i-1})m_i\end{align}$$
Putting these together, we have
$$\sigma_0\gt U(f,\mathcal P_0)-L(f,\mathcal P_0)=\sum_{i=1}^{N_0}(x_i-x_{i-1})(M_i-m_i)$$
and note we also have $\forall i,M_i\ge m_i$, and therefore $\forall i, (x_i-x_{i-1})(M_i-m_i)\lt \sigma_0$.
Our main concern is that the overall value of $U(f,\mathcal P_i)-L(f,\mathcal P_i)$ be maintained or reduced relative to $U(f,\mathcal P_0)-L(f,\mathcal P_0)$ with any partition $\mathcal P_i$ that we choose. In particular, we know that creating new sub-intervals of each interval in the given partition $\mathcal P_0$ produces a refinement of $\mathcal P_0$ and reduces or preserves the difference between the upper and lower sums.
With this in mind, define a new set of values as follows:
$$\begin{align}\delta&=\inf_{i\in[1,N_0]}(x_i-x_{i-1})\\
\lambda&=\sup_{x\in[a,b]}f(x)-\inf_{x\in[a,b]}f(x)\\
\kappa&=\left[\frac 1{\sigma_0-U(f,\mathcal P_0)+L(f,\mathcal P_0)}\right]+1\\
N_1&=(b-a)^2\frac{\kappa\lambda}{\delta}\\
y_k&=a+\frac{k(b-a)}{N_1}\\
\mathcal P_1&=\{[y_0,y_1],[y_1,y_2],\dots,[y_{N_1-1},y_{N_1}]\}\\
L_k&=\sup_{y\in[y_{k-1},y_k]}f(y)\\
\ell_k&=\inf_{y\in[y_{k-1},y_k]}f(y)\\
U(f,\mathcal P_1)&=\sum_{i=1}^{N_1}(y_i-y_{i-1})L_i\\
L(f,\mathcal P_1)&=\sum_{i=1}^{N_1}(y_i-y_{i-1})\ell_i\end{align}$$
With this as the definition of a partition $\mathcal P_1$, we have guaranteed that every interval of partition $\mathcal P_0$ has at least one cut point either inside it or at each endpoint in our new partition (by factor $\frac{b-a}{\delta}$). The factor $\lambda$ ensures that the maximum possible upper and lower values are accounted for. We cannot guarantee that $U(f,\mathcal P_0)-L(f,\mathcal P_0)\gt 0$, but we can say that $U(f,\mathcal P_1)-L(f,\mathcal P_1)\lt \sigma_0$ by factor $\kappa$. Therefore, we have constructed the required partition with congruent intervals and such that $U(f,\mathcal P_1)-L(f,\mathcal P_1)\lt \sigma_0$. Note that we have $y_{k+1}-y_k=a+\frac{(k+1)(b-a)\delta}{\kappa(b-a)^2\lambda}-\left(a+\frac{k(b-a)\delta}{\kappa(b-a)^2\lambda}\right)=\frac{\delta}{\kappa(b-a)\lambda}$.
So now all that remains is to evaluate $\mathcal P_1$ in light of $\mathcal P_0$ and $\sigma_0$ to demonstrate the correctness of our partition. Recall that $U(f,\mathcal P_0)-L(f,\mathcal P_0)\lt \sigma_0$, i.e.,
$$\sum_{i=1}^{N_0}(x_i-x_{i-1})(M_i-m_i)\lt\sigma_0$$
and therefore consider
$$\begin{align}U(f,\mathcal P_1)-L(f,\mathcal P_1)&=\sum_{i=1}^{N_1}(y_i-y_{i-1})(L_i-\ell_i)\\
&=\sum_{i=1}^{N_1}\frac{\delta}{\kappa(b-a)\lambda}(L_i-\ell_i)\end{align}$$
Now we split our set of indices $i=1,2,\dots,N_1$ into two subsets: $Q=\{i:\exists j\in[1,N_0]\text{ s.t. }[y_{i-1},y_i]\subseteq[x_{j-1},x_j]\}$ as the set of those indices where an interval of partition $\mathcal P_1$ is a subset of an interval of partition $\mathcal P_0$, and $R=\{1,2,\dots,N_1\}\setminus Q$ the set of indices where this is not the case. By our definition, each interval of $\mathcal P_1$ is no larger than any interval in $\mathcal P_0$, and therefore there are no cases of intervals of $\mathcal P_0$ being proper subsets of intervals of $\mathcal P_1$. Thus we can immediately state
$$\sum_{i\in Q}\frac{\delta}{\kappa(b-a)\lambda}(L_i-\ell_i)\le\sum_{i=1}^{N_0}(x_i-x_{i-1})(M_i-m_i)\lt\sigma_0$$
Note that there are $N_0-1$ cuts of $[a,b]$ associated with partition $\mathcal P_0$, and therefore we have $|R|\le N_0-1$. By straight evaluation, we have $L_i-\ell_i\le \lambda, {b-a\over \delta}\ge N_0$, so we get
$$\frac{\delta}{\kappa(b-a)\lambda}\sum_{i\in R}(L_i-\ell_i)\le \frac{N_0}{\kappa N_0}=\frac {1}{\kappa}\\
\sum_{i=1}^{N_1}(y_i-y_{i-1})(L_i-\ell_i)\le \sum_{i=1}^{N_0}(x_i-x_{i-1})(M_i-m_i)+\frac{1}{\kappa}\\
=\sum_{i=1}^{N_0}(x_i-x_{i-1})(M_i-m_i)+\frac{1}{\left[\frac 1{\sigma_0-U(f,\mathcal P_0)+L(f,\mathcal P_0)}\right]+1}\\
\lt \sum_{i=1}^{N_0}(x_i-x_{i-1})(M_i-m_i)+(\sigma_0-U(f,\mathcal P_0)+L(f,\mathcal P_0))= \sigma_0$$
This can be described as the "brute-force" approach, where we merely squeezed the set of "boundary values" into the space between the previous sum and the given $\sigma_0$, and let the non-boundary values do no worse than preserving the value of the previous sum.