sphennings's mention of frangible rounds is a great way to preserve lethal rounds while avoiding hull breaches. The use of intimidation and resource preservation to avoid a fight altogether is also very pragmatic.
Curtis brings up very good points about both Hollywood bullet momentum and suggesting shifting emphasis to characters.
Building on these answers and a few comments, I'd like to shift back to the technical aspects since you asked about "safe" use of ballistics.
Soft Projectiles
Recoilless weapons
Conventional projectiles' transfer of momentum to the shooter is indeed a problem, as others have mentioned. However...
You can have almost-conventional firearms that don't impart equal and opposite momentum to the shooter and the projectile. These exist in the real world as recoilless weapons. The basic idea is that a countermass is ejected rearward at the same time that the projectile fires, negating most or all of the recoil. The most straightforward way I can imagine doing this for small arms is to essentially make each cartridge a very small rocket with its own propellant. The propellant -- and not the shooter -- is the reaction mass used to set the projectile in motion.
An ill-timed nudge can be devastating
The projectiles in question don't need to carry much momentum to cause an unprepared (e.g. floating) target to tumble wildly. A beanbag fired at much lower velocities than those used in modern crowd control weapons would easily do the trick. (Watch how effortlessly this astronaut can propel her whole body down a tunnel in the ISS.) The target would only need to tumble a little bit to completely spoil their aim, and hence, ability to return fire. That target would effectively be out of the fight until they reach a bulkhead, stop their tumble, re-orient themselves, reacquire a braced position, and re-engage.
Without covering fire, they're a sitting duck for attackers to dart into melee range for a killing/disabling attack with a close-combat weapon. Observe how helpless this astronaut is when he can't reach a bulkhead. Imagine how well he would be able to defend against something as simple as a knife if he was tumbling.
A fighter that can't move can't fight
Even braced targets aren't immune to slow-moving squishy bullets. Effectively engaging in a firefight requires some freedom of movement. Bracing against a bulkhead may keep a fighter from being thrown into a tumble, but that also means she has to stay in place, braced against a bulkhead. Unless she can maneuver to keep the pirates from reaching the cargo hold/bridge/engineering/whatever, there's little she can do to actually deter the pirates. To maneuver, a combatant has to forfeit their braced position, making them vulnerable to beanbag bullets.
The exception to this is choke points, where the defenders can simply hold position and keep invaders from breaching, which is no different than choke points on land.
Asymmetry forces action
The home-field advantage -- combatants on a ship being boarded in a universe with pirates likely have some kind of remote-operated high-powered weapons mounted internally to protect vital areas from boarders. Being remote-operated, harming friendly defenders isn't a concern, so overwhelming force can be used... ricochet and debris be damned.
That means the pirates can't simply go toe-to-toe with the ship's primary defenses without being turned into Swiss cheese. They must first disable automated defenses, requiring them to take initiative. What boarders have going in their favor is that there's a lot of ways to disable a remotely-operated system without physically approaching it. That allows them to take initiative in an unpredictable way.
Since the boarders' movements through the ship will be difficult to predict, the defenders must be able to react and move to counter the boarders' actions, meaning they can't just hunker down and wait out the boarders.
Combat doesn't require lethality
The whole point of combat is to degrade an opponent's ability and/or willingness to resist to the point where they can no longer do so effectively... ideally as quickly and decisively as possible. Throughout most of human history, that simply meant "deal physical trauma as quickly as possible."
Combine the points above, and you have effective means to use small-arms projectile weapons in space combat without needing magnetic boots, bullet-proof hulls, or vacuum suits. Moreover, neither side can simply hunker down and out-wait the other; both sides are required to be dynamic and respond to changing circumstances, even if all small-arms weapons are very low-powered.
As an added bonus, scenarios like this would ensure that the victors of a battle would be likely to take a lot of prisoners, which opens up options to escalate the stakes of a fight as needed for the story. I'm not sure if being shot and bleeding to death is any worse than choking to death in a ship whose CO2 scrubber has been disabled by sadistic pirates...
Hull Breaches
sphennings is absolutely right: hull breaches are a much bigger concern than ricochet. With that said, if metal-piercing projectiles are used, hull breaches during a firefight are practically inevitable, meaning loss of atmosphere is a problem. As Ryan_L mentions, a single hole is actually pretty tolerable.
The trouble is, a firefight is going to involve a lot of bullets that miss their target, and each is likely to punch its own hole into empty space. It won't take long for any ship to turn into an oversize cheese grater. Explosive decompression isn't an issue, but hemorrhaging air during the entire duration of a firefight means combatants will eventually be fighting in vacuum. Moreover, all a pirate has to do is punch a decent-sized hole in the hull and wait. Similarly, defenders can just hole up in a sealed compartment, dump atmosphere from the rest of the ship and wait.
For any side: fighting without wearing a suit that can protect against vacuum would be utterly suicidal.
With that said, having a suit with a hole in it is only slightly better than having a hole in the hull, so any suit intended for use in vacuum should be rugged enough to not accidentally tear open under any reasonable circumstance, including stray debris flying around. This applies to any vacuum suit, not just those intended for combat, which likely have armor that would further protect from debris.
In other words, unless a combatant is literally trying to die, they'll be wearing a suit that will protect from small-arms ricochets and spalling.