Derbyshire 221 for 2 (Godleman 86*, Lace 78*) trail Glamorgan 394 (Wagg 100, Carey 62*) by 173 runs
Derbyshire made a spirited reply to Glamorgan's first-innings score of 394 and at the close of the second day at Swansea had reached 221 for 2 - a deficit of 173.
After losing their first two wickets for 74, their captain Billy Godleman and Middlesex loanee Tom Lace shared an unbroken partnership of 147 for the third wicket, though Godleman was dropped by wicketkeeper Cullen on 48. Godleman will resume on 86 and Lace 78.
Glamorgan's earlier dominance was underpinned by a record ninth-wicket partnership of 167 in only 28.3 overs between Graham Wagg and Lukas Carey, surpassing the previous record achieved at Worcester 90 years ago. Wagg scored his fourth century for Glamorgan from 101 balls with four sixes and ten fours - his second fifty coming from only 27 balls.
Carey achieved a career-best 62 not out as the pair added 112 in 14.3 overs after lunch, with Glamorgan only six runs short of gaining maximum batting points in successive championship games.
Glamorgan had resumed on 167 for 5 with Owen Morgan, playing his first championship game of the season, scoring a fluent 43 before he was bowled by Tony Palladino. Dan Douthwaite was beginning to get into his stride before playing a careless shot against a wide ball from Logan van Beek.
When Tom Cullen went cheaply, Glamorgan were 217 for 8, and although the new ball was taken the over before lunch it made little difference to the batsmen's approach .Carey struck Ravi Rampaul for three successive fours before Wagg played an outrageous scoop off Palladino that sailed over the wicketkeeper's head for six.
Derbyshire also adopted an attacking approach as Godleman and Luis Reece set off at six runs an over, although five slips to Michael Hogan appeared an ambitious ploy that failed as the openers regularly found the boundary.
Douthwaite made the initial breakthrough when Reece was caught by Wagg on the fine leg boundary, then Carey dismissed Madsen in the final over before tea when he edged to David Lloyd at first slip.