Page 1 of 1

Move /home partition to /var/www/vhosts?

Posted: 2019/03/15 17:57:03
by tech0925
Hi all,

I keep my web server files under /var/www/vhosts and I notice my space is allocated to the /home directory instead.

Code: Select all

# lsblk -io NAME,TYPE,SIZE,MOUNTPOINT,FSTYPE,MODEL

NAME            TYPE  SIZE MOUNTPOINT FSTYPE      MODEL
sdb             disk  477G                        Samsung SSD 860 
`-sdb1          part  477G            LVM2_member 
  `-centos-home lvm   1.3T /home      xfs         
sr0             rom  1024M                        DRW-24B1ST   j  
sdc             disk  477G                        Samsung SSD 860 
`-sdc1          part  477G            LVM2_member 
  `-centos-home lvm   1.3T /home      xfs         
sda             disk  477G                        Samsung SSD 860 
|-sda2          part  476G            LVM2_member 
| |-centos-swap lvm  31.5G [SWAP]     swap        
| |-centos-home lvm   1.3T /home      xfs         
| `-centos-root lvm    50G /          xfs         
`-sda1          part    1G /boot      xfs 

Code: Select all

# df -h

Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                  32G     0   32G   0% /dev
tmpfs                     32G     0   32G   0% /dev/shm
tmpfs                     32G  1.4M   32G   1% /run
tmpfs                     32G     0   32G   0% /sys/fs/cgroup
/dev/mapper/centos-root   50G  3.1G   47G   7% /
/dev/sda1               1014M  253M  762M  25% /boot
/dev/mapper/centos-home  1.4T   33M  1.4T   1% /home
tmpfs                    6.3G     0  6.3G   0% /run/user/1000
How can I use the 1.4T for /var/www/vhosts instead of the /home directory?

Can I simply edit the /etc/fstab file and change

Code: Select all

/dev/mapper/centos-home /home                   xfs     defaults        0 0
to

Code: Select all

/dev/mapper/centos-home /var/www/vhosts                   xfs     defaults        0 0
without losing what is in the /var/www/vhosts directory?

Re: Move /home partition to /var/www/vhosts?

Posted: 2019/03/18 07:41:08
by jlehtone
tech0925 wrote:
2019/03/15 17:57:03
Can I simply edit the /etc/fstab file and change

without losing what is in the /var/www/vhosts directory?
When the kernel mounts /dev/bbb/ddd to /path/mountpoint you will see only the content of /dev/bbb/ddd in /path/mountpoint/
The files in the filesystem /path are not touched, but you cannot reach them unless you umount /path/mountpoint.

How about this:

Code: Select all

# stop httpd
rsync -aviPHAS --delete /var/www/vhosts/ /home/vhosts/
# erase content of /var/www/vhosts once sync is complete
Append to /etc/fstab:

Code: Select all

/home/vhosts  /var/www/vhosts  none  bind  0 0
Then:

Code: Select all

mount /var/www/vhosts
restorecon -R /var/www/vhosts
# restart httpd


PS. This is not a hardware question.