Looks good to me. The -w option to grep is a simpler solution than putting \< and > in the patterns, so nicely done.
Bug with matching codes for extended partitions