Expand Disk Linux Server without reboot

1. Find out which SCSI devices are involved:
    ls /sys/class/scsi_device/

    Result example:
    0:0:0:0  2:0:0:0  2:0:1:0

2. Provoke a re-sync of the kernel for all the SCSI devices (unless you know exactly which one is concerned). That also finds new disks if it’s the case.

    echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan
    echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
    echo 1 > /sys/class/scsi_device/2\:0\:1\:0/device/rescan

3. In case that doesn’t work you can tell the kernel to re-scan the already known disks only:
Find out how many ‘hostX’ there are:

    ls /sys/class/scsi_host/

   Result example:
    host0  host1  host2

4. Now rescan every host listed above:
    echo "- - -" > /sys/class/scsi_host/host0/scan
    echo "- - -" > /sys/class/scsi_host/host1/scan
    echo "- - -" > /sys/class/scsi_host/host2/scan

5. This should display a bigger size of the hard disk:

    fdisk -l

6. cfdisk /dev/sda

(อาจต้อง run คำส้่ง partprobe หรือ partx -a /dev/sda เพื่อให้มองเห็น Disk /dev/sda3 ถ้าไม่ซีเรียสสามารถ Reboot VM โดยข้ามขั้นตอนนี้ได้)

7. pvcreate /dev/sda3

8. vgextend vg_centos6 /dev/sda3

9. lvextend /dev/vg_centos6/lv_root /dev/sda3

10. resize2fs /dev/vg_centos6/lv_root

Disk ควรจะถูกเพิ่ม ตรวจสอบได้จาก df -h


Add Disk Linux Server Without reboot

1. run command: 

    #ls -l /sys/class/scsi_host/

    Result example:

    # ls -l /sys/class/scsi_host/

    total 0

    lrwxrwxrwx 1 root root 0 2017-07-27 16:39 host0 -> ../../devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0

    lrwxrwxrwx 1 root root 0 2017-07-27 16:39 host1 -> ../../devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1

    lrwxrwxrwx 1 root root 0 2017-07-27 16:39 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2

2. But to detect a new hard drive attached you need to first get your host bus number used which you can get by using below command

    #grep mpt /sys/class/scsi_host/host?/proc_name

3. You should get a output like below

    #grep mpt /sys/class/scsi_host/host2/proc_name


4. So as you see your host2 is the relevant fiels where you need to reset the storage buffer values. Run the below command

    # echo "- - -" > /sys/class/scsi_host/host2/scan


*** Here "- - -" defines the three values stored inside host*/scan i.e. channel number, SCSI target ID, and LUN values. We are simply replacing the values with wild cards so that it can detect new changes attached to the Linux box. This procedure will add LUNs, but not remove them.

    # fdisk -l

เราควรจะเจอ Disk หลังจากใช้คำสั่งนี้

    # cfdisk /dev/sdb

    # fdisk -l

    # mkfs.ext4 /dev/sdb1

    # fdisk -l

    # mount /dev/sdb1 /backup


Expand Disk Windows Server without reboot

1. Expand Disk บน vSphere Client

2. In Computer Management, right-click Disk Management and click Rescan Disks.


Ref: http://techgenix.com/how-extend-vsphere-windows-vm-disk-volume/