You tell the INS or IRS system where in the world it is. Magnetic north can be obtained from the aircraft compasses, and the clever little box of tricks will convert that info into a true north reference. Whether you have accelerometers and rate gyros(INS) or ring laser gyros(IRS), these are acceleration sensing systems which tell you how far you have travelled from your initial position. As alapt says, the laser gyros are far more accurate.