We present a method of constructing free self-dual codes over Z 8 and Z 16 which are extremal or optimal with respect to the Hamming weight. We first prove that every (extremal or optimal) free self-dual code over Z 2 m can be found from a binary (extremal or optimal) Type II code for any positive integer m ≥ 2. We find explicit algorithms for construction of self-dual codes over Z 8 and Z 16 . Our construction method is basically a lifting method. Furthermore, we find an upper bound of minimum Hamming weights of free self-dual codes over Z 2 m . By using our explicit algorithms, we construct extremal free self-dual codes over Z 8 and Z 16 up to lengths 40.