It is my understanding that when the Tokugawa shogunate came into being it enforced strict laws that said that only members of the warrior class could carry or keep weapons. (with maybe a few exceptions). These were the same law that Hideyoshi first formulated and put into action during his reign. (like the famous "sword-hunt" episode). Hideyoshi collected swords and weapons in this "hunt" as to minimize the risk of peasant-rebellions, which was quite understandable.
But peasants and warrior monks aside, how did this apply to the numerous Ronin that travelled the countryside? The most obvious example that springs to mind is Miyamoto Musashi, arguebly the most famous single Ronin in japanese history. He obviously carried weapons of some sorts for his many duels, eventhough he fought with a bokken from time to time.
So how was the law enforced? During the first 30 years of the Edo-period there were thousands of Ronin. Was there even a possibility of disarming all those thousands? And even later still there were plenty armed Ronin on the country-side