Teachers at the school in Hunan became suspicious of a whirring noise that continued day and night, local media report.
This led to the discovery of the machines, which were mining the crypto-currency Ethereum.
They racked up an electricity bill of 14,700 yuan (£1,600).
The excessive electricity consumption had previously been reported to the headmaster, Lei Hua, but he reportedly dismissed it as being caused by air conditioners and heating devices.
Mining crypto-currencies such as Bitcoin and Ethereum involves connecting computers, usually specialised “mining machines”, to the currency network.
By providing computing power for validating transactions on that network, mining-machine owners are rewarded with newly generated coins, making it a potentially lucrative exercise – especially when done at scale.
In this case, a total of eight mining machines were installed in the Hunan school’s computer room between summer 2017 and summer 2018.
The headmaster had originally spent 10,000 yuan on a single machine for use at home, but allegedly decided to move it to the school after he saw how much electricity it consumed.
The deputy headmaster also became involved in the scheme and allegedly acquired a ninth machine for himself in January, which was also installed at the school.
The computer network in the building became overloaded as a result of the mining activity, according to reports, and this “interfered” with teaching.
The headmaster was fired in October and his deputy received an official warning.
A local authority responsible for “discipline inspection” has claimed the money that was made through the mining activities.
“The noise and heat of nine actively running mining machines would have been very noticeable,” said Matthew Hickey, a cyber-security expert at Hacker House.
“Sadly, stealing electricity is one way that people have tried to maximize their revenue – by avoiding those costs it can drastically improve returns on a mining operation.”
Surreptitious crypto-currency mining has been discovered elsewhere. In February, several scientists at a top-secret Russian nuclear warhead facility were arrested for allegedly mining Bitcoin with the facility’s supercomputers.