RedHat 5.8内/home目录移植到新建的存储

本文提供了一套详细的步骤来指导如何使用LVM(逻辑卷管理器)进行硬盘扩容操作,包括检查现有空间、创建新的卷组及逻辑卷、迁移数据到新分区等关键步骤。

1. Check for available space:

     vgdisplay

     fdisk -l

     In case you don't have space available on the existent volume group, add a new disk or new partition.

2. Initialize the new disk or partition for use by LVM (in this case we are using sdb as an example name)

     pvcreate /dev/sdb1

3. Create a volume group

     vgcreate vg_newVolumeName /dev/sdb1

4. Display attributes of volume group and check the space available "Free PE / Size"

     vgdisplay vg_newVolumeName

5. Create a logical volume in vg_newVolumeName. The following will create the new logical volumes for lv_home  (adjust the size accordingly with your needs):

     lvcreate -L 5G --name lv_home vg_newVolumeName

6. Creating the file system for lv_home

     mkfs.ext4/3  /dev/mapper/vg_newVolumeName-lv_home

7. Note: Now you have the LVM ready, a few more steps to move home.

8. mount new home to /tmp/hometmp and Copy the content of home and to new home directory

        mkdir /tmp/hometmp

        mount /dev/mapper/vg_newVolumeName-lv_home /tmp/hometmp

        rsync -avz /home/ /tmp/hometmp/

 9. Check if the temporary directory matches the original directory.

      diff /home/ /tmp/hometmp/

      ls -la /home/

      ls -la /tmp/hometmp/

     du -s /home/

     du -s /tmp/hometmp/

   'du' shows the size in bytes

 10. edit /etc/fstab and use new storage as home dirctory On RHEL6:

blkid (this command will show you the UUID for lv_home). Take a note for the output.

 Edit the file /etc/fstab adding the lines:

        UUID=example-UUID-for-lv_home  /home    ext4    defaults    1 1

  Note: Make sure to inform the UUID accordingly with the blkid output:

 On RHEL 5 or older:

      /dev/vg_newVolumeName/lv_home   /home   ext3   defauls   1  1

 Remember to double check the paths and also the filesystem type, such as ext3 or ext4, accordingly with your system, the above are examples only.

 11. reboot your server and check out whether the new home directory is working properly.

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值