In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how linux does not change the directory structure to move the home directory to the new partition, the article introduces in great detail, has a certain reference value, interested friends must read it!
Question raised
The company's development and test server is deployed in Aliyun. The examples given by Aliyun generally have only one partition, 20g to 40G, and then buy storage and mount it to other directories.
The home directory is under the 20 G directory partition. As the number of developers increased, the root partition was quickly filled.
Because it is a multi-site research and development, so we need an imperceptible solution for everyone to move home.
Basic principles
When I receive this task, the first thing that comes to mind is bind mount:
Mount-- bind / some/where / else/where
Can achieve imperceptible moving home.
I feel that the search Chinese does not explain this command too clearly. This question and answer is relatively clear, students who are good at English can refer to it.
Of course, you can also ask "man": man mount
Concrete operation
First of all, choose a time in the dead of night, use the who command to check that those children are still stuck in the server and refuse to leave, and make a phone call to clear the room one by one:
$whoFrodo pts/0 2017-04-17 09:07 (xx.xxx.xxx.xx) Sam pts/1 2017-04-18 08:45 (xx.xxx.xxx.xx) Pippin pts/3 2017-04-18 09:06 (xx.xxx.xxx.xx) Merry pts/4 2017-04-18 09:07 (xx.xxx.xxx.xx)
After making sure that there is no one around, start to move (copy). When using the cp command to copy, remember to take the-p parameter with you and keep the file permission settings. Use root permissions, assuming the target partition is / new_disk:
# cp-p-r / home / new_disk/
The new home has been built, let's get another house number for the old home, lest we can't find it after giving it to the new home. Use mount-- bind to mount the original home directory to a new directory:
# mkdir / home_bkp# mount-- bind / home / home_bkp
At this point, we can find all the files in our hometown in the directory / home_bkp. You can give the house number / home to the new home:
# mount-- bind / new_disk/home / home
The move is complete! You can tell your friends to work happily. In fact, there is no need to inform everyone that the move is actually unperceptible to everyone.
Of course, some students will ask, the house number of the new home and hometown is the same, all / home, how do I know whether the move is successful? You can use the df command to confirm:
# cd / home_bkp# df-h .Filesystem Size Used Avail Use% Mounted on/dev/xvda1 20G 17G 2.1G 90% / # cd / home# df-h .Filesystem Size Used Avail Use% Mounted on/dev/xvdb1 296G 42G 240G 15% / new_disk
-h is human-readable, if not added, then the anti-human block is listed as the unit.
The above command, first go to the hometown to have a look, the mount point is /; then go to the new home to see, the mount point is / new_disk. This can be relieved.
Persistence
The work is not finished yet. The above work only ensures that the current new home changes its address. But after restarting, this information will be lost and the home address will be changed back. We need to find a way to keep this information.
Just modify the / etc/fstab file. Open the file and add the following two lines at the end:
/ home / home_bkp none bind 0 0/new_disk/home / home none bind 0 0
In this way, the whole home switching partition work is completed.
The above is all the contents of the article "how linux does not change the directory structure to move home directories to a new partition". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.