I have the same issue. Two 8GB iPods running iOS 6.1.6 and 4.2.1; MacBook Air M2, 2022, running Sonoma 14.1.2.
Some of the music is old and I uploaded it at the time to iTunes from CDs - but the songs/albums aren't available on Apple Music. (Examples are the soundtrack from the movie Toys and a CD, called Legends II, that I bought in Europe from a street-corner band.) I have no idea where the CDs are now (buried in boxes, since I've moved a couple of times since purchasing them).
I subscribe to Apple One Premier, so theoretically, I can upload the songs via the Music app, and they should appear in my Library, right? However, I tried that in the iOS 6.1.6 iPod: I turned on iTunes Match; it said it was going to delete my Library and copy it to iCloud, and turned on Show All Music. But, my music didn't appear in my iTunes library, and seemingly disappeared off the iPod. PANIC!
And, a side note at this point: after researching further, apparently only music that Apple somehow "knows" is legit will go up into my iCloud Music Library? I don't know how this is recognized, but I imported this music into iTunes from CDs I purchased legitimately years ago.
I then connected the 6.16 to my Air, thinking I could see files, as suggested in the video linked by @agk_ in this thread, along with multiple resources on the web in general. However, instead of showing as files in Finder, I get a window similar to the old iTunes app sync window. In this window, I can only delete the files. There's no way to copy or export them.
I get a slightly different window if I open the Music app that actually shows the songs are still there! Yay! However, I can select the files - but still can't copy or export them. And, for what it's worth, they're highlighted in red when I select them.
I don't want to lose my music! Might there be any further resources explaining how I might copy these files either to my computer or get them up into iCloud so I can listen on my current devices?