เพิ่ม HDD Centos7 บน vmware workstation 12
ส่วนตัวไม่เคยมีความรู้เรื่อง HDD บน linux เท่าไหร่ เนื่องจาก เล่นอย่างเดียว แต่ลองทำแล้วได้ผลตามนี้
โดยเริ่ม มี disk จาก 20 เพิ่มไปอีก 10 เป็น 30
เริ่มแรกทำที่ vm ก่อน ไป เพิ่ม HDD
- Power off the virtual machine.
- Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
- Power on the virtual machine.
จากนั้นเปิด vm ที่จะทำแล้วตำตามนี้
- Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:
# fdisk -l
-
Create a new primary partition:
- Run the command:
# fdisk /dev/sda (depending the results of the step 4)
- Press p to print the partition table to identify the number of partitions. By default there are 2: sda1 and sda2.
- Press n to create a new primary partition.
- Press p for primary.
- Press 3 for the partition number, depending the output of the partition table print.
- Press Enter two times.
- Press w to write the changes to the partition table.
- Run the command:
- Restart the virtual machine.
พอ vm on แล้วให้ทำตามนี้
- Run this command to verify that the changes were saved to the partition table and that the new partition has an 83 type:
# fdisk -l
เราจะเห็น sda3 เป็น disk ใหม่ - Run this command to convert the new partition to a physical volume:
# pvcreate /dev/sda3
ข้อต่อไป : ค่า VolGroup00 หรือก LogVol00 อาจเปลี่ยนแปลงตามที่เราติดตั้งในตอนลง OS ของเราเอง โดยใช้คำสั่ง lvdisplay
- Run this command to extend the physical volume:
# vgextend VolGroup00 /dev/sda3
Note: To determine which volume group to extend, use the command vgdisplay.
- Run this command to verify how many physical extents are available to the Volume Group:
# vgdisplay VolGroup00 | grep “Free”
- Run the following command to extend the Logical Volume:
# lvextend -L+#G /dev/VolGroup00/LogVol00
Where # is the number of Free space in GB available as per the previous command.
Note: to determine which logical volume to extend, use the command lvdisplay.
ตรง #G ให้ใส่จำนวน ที่ต้องการเพิ่มลงไป แต่เจอปัญหาว่า หากมีอยู่ 10 จะใส่ 10ไม่ได้ ผมเลยใส่ไปแค่ 9 จากนั้น
- Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:
# resize2fs /dev/VolGroup00/LogVol00
Note: Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.
จากที่ลองใช้คำสั่ง resize2fs เจอ error
resize2fs: Bad magic number in super-block while trying to open /dev/centos/root
Couldn’t find valid filesystem superblock.
เลยแก้โดย
mount | grep centos-root
xfs_growfs /dev/mapper/centos-root
จากนั้นต่อได้เลย - Run the following command to verify that the / filesystem has the new space available:
# df -h /
หลังจากเสร็จแนะนำให้ลอง restart ดูว่าหายไหม
ที่มา :https://www.vpsthai.net/knowledgebase.php?action=displayarticle&id=46