Preheat the oven to 200C/450F/Gas 6.
Heat a frying pan until hot then add half the butter and all the onions.
Sweat for 3-4 minutes until just softened.
Place a layer of celeriac slices into the bottom of a buttered ovenproof dish.
Top with a layer of onions, then potatoes, then onions again, seasoning with salt and freshly ground black pepper as you go.
Repeat with the remaining celeriac, onions and potatoes, finishing with a layer of potatoes.
Dot with the remaining butter.
Pour over the hot stock so all the layers are covered.
Transfer to the oven and cook for 45-60 minutes, checking occasionally to make sure the stock hasn't completely evaporated, and pressing the layers down with the back of a spoon.
Bake until nearly all the stock is absorbed and the top layer is golden brown.
Serve.