เพิ่ม HDD Centos7 บน vmware workstation 12

ส่วนตัวไม่เคยมีความรู้เรื่อง HDD บน linux เท่าไหร่ เนื่องจาก เล่นอย่างเดียว แต่ลองทำแล้วได้ผลตามนี้

โดยเริ่ม มี disk จาก 20 เพิ่มไปอีก 10 เป็น 30

เริ่มแรกทำที่ vm ก่อน ไป เพิ่ม HDD

  1. Power off the virtual machine.
  2. Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047).
  3. Power on the virtual machine.

จากนั้นเปิด vm ที่จะทำแล้วตำตามนี้

  1. Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:

    # fdisk -l

  2. Create a new primary partition:
    1. Run the command:

      # fdisk /dev/sda (depending the results of the step 4)

    2. Press p to print the partition table to identify the number of partitions. By default there are 2: sda1 and sda2.
    3. Press n to create a new primary partition.
    4. Press p for primary.
    5. Press 3 for the partition number, depending the output of the partition table print.
    6. Press Enter two times.
    7. Press w to write the changes to the partition table.
  3. Restart the virtual machine.

พอ vm on แล้วให้ทำตามนี้

  1. 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 ใหม่

  2. Run this command to convert the new partition to a physical volume:

    # pvcreate /dev/sda3

ข้อต่อไป : ค่า VolGroup00 หรือก LogVol00 อาจเปลี่ยนแปลงตามที่เราติดตั้งในตอนลง OS ของเราเอง โดยใช้คำสั่ง lvdisplay

  1. Run this command to extend the physical volume:

    # vgextend VolGroup00 /dev/sda3

    Note: To determine which volume group to extend, use the command vgdisplay.

  2. Run this command to verify how many physical extents are available to the Volume Group:

    # vgdisplay VolGroup00 | grep “Free”

  3. 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 จากนั้น

  1. 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
    จากนั้นต่อได้เลย

  2. 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

ที่มา : http://www.systemadmin.me.uk/?p=434

ใส่ความเห็น

อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องที่ต้องการถูกทำเครื่องหมาย *