วันอาทิตย์ที่ 21 กันยายน พ.ศ. 2557

Resize Partition LVM

เพิ่งได้เจอมาคือว่า..ลง CentOS 6.5 มี HDD 1 TB ใช้ default แบ่งได้คือ lv_root = 50GB ,  lv_home = ที่เหลือ ประเด็นคือส่วนมากผมลงโปรแกรมไว้ /opt/ ปรากฏว่า lv_root เต็ม ทีนี้ต้องขยาย

Step 1

# df -h
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/vg_repo-lv_root 148G  113G   29G  80% /
tmpfs                       499M     0  499M   0% /dev/shm
/dev/sda1                   485M  156M  304M  34% /boot
/dev/mapper/vg_repo-lv_home 47G  181M   45G   1%  /home

Step 2

#cd /
#cp -Ra /home /home.bak  # Make a backup of home
#umount /home
#lvm lvremove /dev/vg_<hostname>/lv_home   (Remove the logical volume for home)
#lvm lvresize -l+100%FREE /dev/vg_<hostname>/lv_root  (Resize the root logical volume so it uses 100% of the now free space)
#resize2fs /dev/vg_<hostname>/lv_root  (Resize the filesystem to use the whole logical volume)

#mv /home.bak /home  (Restore the backup)

Step 3

#lvdisplay
#lvcreate -n lv_home -l 100%FREE VolGroup
#mke2fs -j /dev/VolGroup/lv_home
#mount /dev/VolGroup/lv_home /home

เสร็จ......


*******เพิ่มเติม*******

# comment out /home
แก้ไข /etc/fstab โดย คอมเม้น /home

* ถ้า boot ไม่ขึ้น
1. mount -o remount,rw / (เพื่อให้แก้ไขได้ ไม่งั้นจะ readonly)
2. แก้ไข /etc/fstab โดย คอมเม้น /home


1 ความคิดเห็น: