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

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

1. Check for available space:


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.


未经允许不得转载:演道网 » RedHat 5.8内/home目录移植到新建的存储

赞 (0)
分享到:更多 ()

评论 0


登陆 注册