Western Digital and Kioxia Holdings — after months of talks — aim to reach a merger agreement by August, according to people familiar with the matter.

The deal would be structured as a tax-free spinoff of Western Digital’s flash business, which would merge with Kioxia, said the people, who asked to not be identified because the details are private. Western Digital shareholders would own slightly more than 50% of the merged entity, the people said.

Shares of Western Digital, which had fallen more than 14% in the past year, rose as much as 6.5% in trading Friday. The shares closed up 0.8% to $39.66 in New York, giving the company a market value of about $12.7 billion.