Pretty much what I did when I fitted the 10 shot mag to my Sako 22, I used nylon coated cable (such as used when fishing for fish with trace cutting teeth!)
And soldered a small wire loop to the mag to attach one end of the cable to and the other end around the trigger guard, the cable already had tight coils so it tucked out the way pretty good.
To remove the mag you just pull it back then down and I was worried it could do that while carrying the rifle or when slung over my shoulder.
Murphy’s Law - it’s never looked like coming loose by itself!!
Bookmarks