I have a bike with a 7 speed cassette. My question is can I swap it to a cassette with more speeds (like 10). I will change the derailleur to a compatible one.
EDIT As ojs points out in the comments below, the freehub's width of 7-speed systems mismatches those of 8- to 10-speeds. This means the rear hub/wheel has to be changed as well, in addition to everything listed below. Clearly a cost of such change now would exceed the price of a half new bike.
It would require changing the complete drivetrain and the rear wheel.
However, the good news are that a freewheel coming with 7-speed Shimano cassettes is compatible with 10-speed systems, so you won't need changing the rear hub/wheel.
The reason why the complete drivetrain has to be changed is that the front chainrings may not be working well with a narrower 10-speed chain.
- The rear cassette has to be changed for obvious reasons to have more cogs
- The rear derailleur has to be changed because of a different cable pull, range and tolerances required by a 10-speed system.
- The rear shifter has to be changed to have 10 indexed positions and matching cable pull
- The shifter cables/housings might be preserved, but they are cheap and it is recommended to change cables periodically to have better shifting experience, so it is highly recommended to get new ones.
- The chain is to be changed because 10-speed chains are narrower, and a 7-speed one will be too wide and will jump all over the cassette.
- The front chainrings are spaced to match a wider 7-speed chain. There is little possibility it will work nice with a narrower chain.
- The front derailleur matches the front chainring spacing.
- The front shifter goes away together with the derailleur.
What you need for drivetrain parts is called "a new groupset" — a name that encompasses all the parts I've mentioned.
Converting the rear wheel to a new hub would require a complete wheel rebuild. Oftentimes it means that buying a new complete inexpensive rear wheel would be cheaper.