Start by cleaning the ribs and trimming off any excess fat. In a mixing bowl, combine sugar, 1/4 cup of salt, black pepper, paprika, cayenne pepper, and garlic powder. Generously rub this spice blend all over the ribs. Place the ribs into two roasting pans, stacking two racks per pan. Cover and let them marinate in the refrigerator for at least 8 hours.
Preheat your oven to 275°F (135°C). Bake the ribs uncovered for 3 to 4 hours until they become tender and almost fall off the bone.
In a skillet, take out 5 tablespoons of the drippings from the roasting pans and heat it over medium heat. Sauté chopped onion in the drippings until they're softened and lightly browned. Mix in ketchup and let it cook for an additional 3 to 4 minutes while stirring continuously. Add water and brown sugar, then season with cayenne, salt, and pepper to taste. Lower the heat, cover the skillet, and let it simmer for about 1 hour, adding more water as needed to reach your desired sauce thickness.
Prepare your grill by heating it to medium-low.
Once the grill is ready, add soaked wood chips to the coals or to the smoker box if using a gas grill. Lightly grease the grill grate. Grill the ribs in batches of two racks at a time, ensuring there's enough space between them. Cook for 20 minutes, turning them occasionally. In the last 10 minutes of grilling, baste the ribs with the prepared sauce to enhance flavor without burning.