Credit…Alex Plavevski/EPA, via Shutterstock

All it took was one confirmed Covid case among the 2.4 million residents of Wuhu, a city in the farmland of eastern China, for the government there to lock down residents without warning.

After watching Shanghai — China’s richest, most sophisticated metropolis — humbled and traumatized by the spread of the Omicron variant of the coronavirus and a resulting weekslong shutdown, officials across the country have every incentive to jump early, even if residents have no time to prepare.

Inhabitants of the urban districts of Wuhu in Anhui Province awoke on Sunday morning to official orders to stay at home and get tested — daily — until the government decides that it has stamped out cases of the Omicron variant, which is straining China’s “zero Covid” policy to its limits.

The Wuhu government said it took the drastic step after one school student tested positive. Despite the stay-at-home command, many in Wuhu rushed out to stock up on food before the restrictions took full force, videos and pictures online show.

“I don’t think many people have supply shortages now, because it’s just started,” Megan Liu, a Wuhu resident who works for a foreign trade company, said in a telephone interview. “But I see many people have been madly hoarding supplies.”

While global attention has fallen on Shanghai, where 27 million people have been cooped up in their homes for weeks in China’s largest lockdown, there are over 20 other Chinese cities, large and small, under lockdowns or heavy restrictions on movement, according to Caixin, a Chinese magazine.

Many have millions of residents, but names unfamiliar to most foreigners, like Lu’an, Yongcheng and Siping. Qindong, a town with 15,000 residents in northwest China, imposed a virtual shutdown although it has not recorded any cases of Covid. One person there was identified as a close contact of a confirmed case, officials said.

The closure of each town and city, officials maintain, brings China closer to beating Covid. But each closure also burdens populations and an economy weary after over two years of pandemic restrictions.

Most residents of Wuhu contacted on Tuesday said they accepted the restrictions, provided that the government kept up food and medicine supplies and allowed chronically ill people to visit hospitals. But some said that their neighborhoods were struggling to deal with residents’ needs, especially with elderly and frail people unable to care for themselves or order food online. Some complained about sharp rises in prices for vegetables and meat.

“Ordinary folk are unhappy with the city government for not making the right arrangements for food,” said Zhu Xiaoping, a resident of Wuhu, noting the rising prices. “If you have to lock down a city, I think the government should make sure that each neighborhood is prepared to deal with all the food needs.”

Asked what could happen if people’s needs were not met, Ms. Zhu had a simple answer: “Like Shanghai.”

The comprehensive shutdown of Shanghai since early April has become a warning for people across China.

Officials want to avoid its experience of failing to snuff out the Omicron variant, prompting the central government to press for tougher measures that strangle economic life and kindle public anger. Ordinary people want to avoid the suffering of residents in Shanghai, where staple foods like rice and eggs have been in short supply, and some residents have died after being denied prompt medical care.

Senior Chinese officials and Communist Party-run newspapers have said in recent days that China will not weaken its commitment to “zero Covid.” The risk from wider spread of the coronavirus was too great, Ma Xiaowei, the director of China’s National Health Commission, wrote in a party newspaper, The Study Times.

“Our country has a big population, regional development is uneven, and medical resources are generally inadequate,” Mr. Ma wrote. China, he added, “must clearly oppose the erroneous ideas around now about ‘living with the virus.”

Such arguments have come under growing challenge from Chinese people, including medical experts. The lockdowns in Wuhu and elsewhere have drawn online criticism that they were too hasty. Chinese people have also ridiculed the bureaucratic euphemisms that officials increasingly use to describe lockdowns. Xining, a city of 1.6 million residents in northwest China, has called its restrictions “static management.”

“Logistics halted, workplaces stopped, transport halted — I really don’t get what the difference is between this and a lockdown,” said one comment responding to the Xining government’s explanation.

Residents of Wuhu voiced more stoic resignation than opposition. That may change if the shutdown there extends into the weeks, even months, of closure that some Chinese cities have endured.

“I personally think shutting down sooner makes it easier to control, and then it can be rapidly solved,” Xia Zhenxing, a businessman on the edge of Wuhu, said. He was not in the shut-down area of the city, but said his online business selling green bean cake — a local specialty — was suffering from China’s rolling restrictions.

“Every aspect of business is affected by the pandemic,” he said. “It’s tough, but it is what it is.”

Liu Yicontributed research.