I used a retrofit fan brace kit to install a fan rated ceiling electrical box. There are several brands available, but most of them mount the same way by expanding two pieces of the metal brace between two wood ceiling joists to form a strong tight wedge. The ends of the brace have teeth on them to bite into the wood joist. Other types of fan boxes mount directly on the side of the joist or on the bottom of the joist.
A 3/8″ nut driver was used to tighten the nuts that hold the fan box onto the fan brace. Notice that the bare ground wire is under a green screw that is in tight against the metal box. All metal electrical boxes are required to be grounded.
I try to leave the wires a little long for ceiling fan installations so that it is easier to make splices out in the open. The ceiling fan canopy’s tend to be big enough to cover the wires.
I used two 2″ x 3″ x 3 1/2″ deep metal switch boxes connected together to create a two gang switch box. This type of electrical box is made to be joined together by removing one side from each box and then putting the boxes together and tightening the screws. This can also be done if more gangs are needed. The limitation of gangs is determined by how big of a switch plate you can get.
I think up to 20 gangs is available for switch and receptacle wall plates, by special order from an electrical supply company. The problem with such large switch and receptacle wall plates is lining everything up so that they look straight and you can catch all of the wall plate screws in the designated holes on the wiring devices.
I installed the above two gang metal switch box using one Madison Bar on the left side and two #8 sheet metal screws on the right side. I drilled two holes in the box to get the screws where I wanted them to be. Having the box secured to the wood stud is much better than being secured by drywall only. I installed the Madison Bar first. See my post on Madison Bars.
In the photo above you will notice that the ears have been removed from each switch bracket. This was done to keep the switches from protruding from the wall too much due to the ears on the electrical box being on the wall surface. The existing hot wires were spliced together and pig-tailed to provide a hot lead to each switch. The existing red wire was spliced to the hot wires so that the former switch controlled outlet would now be on at all times. All of the white neutral wires were spliced together. The grounding wires were pig-tailed to have a ground connection to the green screw of each switch.
I have another post where I remove a one gang plastic switch box and install a two gang plastic switch box in its place. You can read all about it here.
My post about light switch wiring diagrams will be helpful.
You should also read my switched outlet wiring diagrams post.
My post about installing a ceiling fan box may be of interest to you.
Here is my post about fishing wires in the wall or ceiling.