System is a CentOS 7.
I have a logical volume mounted at
While setting up the server I forgot to give
/home an own logical volume.
Now I want to move everything in
/home to its own logical volume.
What is the best process to do so? Does
lvm have a built-in way to do so?
My current way of doing things would be:
Taking it offline
- Take the server offline (so web-applications running on it are not reachable during the operation)
mv /home /old-home(to prevent file changes during the operation)
- Reboot the server, so any process that had an open file-handle in /home gives up the handle and can't start until /home is available again
Moving the data
- Create new logical volume (lv)
- Mount new lv at /mnt/new-lv
cp -rall contents from /home to /mnt/new-lv
- Mount new lv at
Checking the result
- Switch the server back online and test the application
/old-homefor a while as emergency backup if everyhing looks allright
rm -rf /old-homeat some point later
But maybe there is a less manual way? Or a way that avoides downtime?
Add the new lv to
/etc/fstab so it automatically starts with the system.
edit 2: The system in question is a virtual system in our hoster's datacenter, so afaik booting into alternative OS modes (like rescue/minimal) is not an option.