How do I specify in which directory Bitcoin blocks and other data should be stored?
I believe you can specify this directory using the datadir configuration in bitcoin.conf.

-datadir=&lt;dir&gt;         Specify data directory


See Running Bitcoin.