questions raised
The company's development test server is deployed in Aliyun, Aliyun given examples are generally only one partition, 20G to 40G appearance, and then buy storage mount to other directories.
And the home directory is under this 20G directory partition. As the number of developers grows, the root directory partitions are quickly filled with people.
Because it's a lot of research and development, you need an imperceptible solution for everyone's home move. Fundamentals
In this task, the first thought is the bind Mount method:
Mount--bind/some/where/else/where
You can move home without awareness.
The feeling search Chinese did not explain this command too clearly. This question and answer is more clear, English good students can refer to.
Of course, you can also ask "men": Man mount specific operation
First of all, choose a dead night, use the WHO command to see and the children are not willing to go on the server, call one by one clear:
$ who
Frodo 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)
Make sure no one is around and start moving (copy). When replicating using the CP command, remember to bring the-p argument and preserve the file permission settings. Using root permissions, assume that the target partition is/new_disk:
# cp-p-r/home/new_disk/
The new home has been built, we first to the home to get a separate number, lest the number to the new home, can not find home. Use Mount–bind to mount the original home directory to a new directory:
# MKDIR/HOME_BKP
# Mount--BIND/HOME/HOME_BKP
Then we can find all the files in our hometown in the/HOME_BKP directory. You can give/home this number to a new home:
# Mount--bind/new_disk/home/home
Move complete! Can inform the small friends happy work. In fact, we can not inform everyone, moving this matter is in fact no sense to everyone.
Of course, there are alumni asked, the new home, the same number, is/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 for Human-readable, not add words also can, that list is "anti-human" block for the unit.
The above command, first go home to see, mount point is/; Go to the new home to see, the mount point is/new_disk. This can be relieved. Persistence of
The work is not finished yet. The above work only guarantees the current new home Exchange address. But after the reboot, this information will be lost, home address will be changed back. We need to find a way to keep this information.
You can modify the/etc/fstab file. Open this file and add the following two lines to the last side:
/home /home_bkp None bind 0 0
/new_disk/home /home None bind 0 0
This completes the entire home switching partition. PostScript
The plan was thought out on a whim and failed to find a precedent. At present, there is no problem, we work very happy, and even many people do not know this thing.
Have a master pass to find the problem, also please leave a message pointing twos.
Also postscript: Under this scheme has been working for six months, no problems occurred.
Original article, reproduced please indicate the source: http://blog.csdn.net/liuxu0703/article/details/70225591