You could always wear a mask when you grate the soap to prevent inhaling the dust, just about everyone has a mask somewhere since the Pandemic.
I would be careful though in regularly using a homemade “detergent” made with soap in a modern automatic washer. It could cause a build up of soap...