When it finds a stone of a suitable size, it secretes a liquid from its mouth to open up a hole to crawl into.
It makes a hole in a suitable rock. If that rock breaks, the Pokémon remains agitated until it locates a replacement.