大网数据广告活动
服务器运维问答

Mount /home to another disk in Azure VM

· 52CE 我爱测

I have a CentOS 7.4 and I followed this guide to mount the new disk on my system. https://docs.microsoft.com/en-us/azure/virtual-machines/linux/add-disk At first I made a symbolic link but can't achieve what I want because /home …

问题原文

原帖链接 · Otto · CC BY-SA 3.0

I have a CentOS 7.4 and I followed this guide to mount the new disk on my system. https://docs.microsoft.com/en-us/azure/virtual-machines/linux/add-disk

At first I made a symbolic link but can't achieve what I want because /home already exists, how can I mount safely /home in the new disk without losing the current data?

My objective is to easily migrate this disk in the future to another VM, should I need to know anything else before mounting this disk in another VM?

已采纳解答

原帖链接 · Bruno Faria · CC BY-SA 3.0

I assume you already have the partition setup and working. What you need to do first is to copy the home dir from root partition to the new partition. Let's say its mounted on /mnt/disk1

1) Copy /Home (Replace variables accordingly)

sudo rsync -aXS --exclude='/*/.gvfs' /home/. /mnt/disk1/home/.

2) Find uuid of new partition

sudo blkid

3) Update fstab /home path

UUID=<UUID_from_blkid>   /home    <partition_type>          defaults       0       2

4) Move old home

cd / && sudo mv /home /old_home && sudo mkdir /home

5) Reboot

After that, you should have your home working as intended but located in a different partition.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-04-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。