VMware add new hard disk to linux server without reboot
Здравейте,
Добавянето на нов хард диск във vmware по принцип не е сложно. Обаче ако следваме стъпките описани в тяхната документация ще трябва да рестартираме нашата linux машина, за да може тя да види новия диск. В този пост ще споделя как става добавянето на нов хард диск на линукс машина, без тя да бъде рестартирана след това – (VMware add new hard disk to linux server without reboot).
root@monitor:~# fdisk -l Disk /dev/sda: 160 GiB, 171798691840 bytes, 335544320 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xe52d3a30 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 999423 997376 487M 83 Linux /dev/sda2 1001470 335542271 334540802 159.5G 5 Extended /dev/sda5 1001472 335542271 334540800 159.5G 8e Linux LVM Disk /dev/mapper/monitor--vg-root: 149.5 GiB, 160545374208 bytes, 313565184 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/monitor--vg-swap_1: 10 GiB, 10737418240 bytes, 20971520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Така изглежда линукс машината ни с един 160гб хард диск.
Предполага се, че вече сме добавили диска от vSphere клиента и следва да изпълним следните команди в линукса :
for i in `ls /sys/class/scsi_host` ; do echo "- - -" > /sys/class/scsi_host/$i/scan; done
И воала! Новият ни 320гб хард диск е вече видим и може да го форматираме.
root@monitor:~# fdisk -l Disk /dev/sda: 160 GiB, 171798691840 bytes, 335544320 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xe52d3a30 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 999423 997376 487M 83 Linux /dev/sda2 1001470 335542271 334540802 159.5G 5 Extended /dev/sda5 1001472 335542271 334540800 159.5G 8e Linux LVM Disk /dev/mapper/monitor--vg-root: 149.5 GiB, 160545374208 bytes, 313565184 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/monitor--vg-swap_1: 10 GiB, 10737418240 bytes, 20971520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sdb: 320 GiB, 343597383680 bytes, 671088640 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes root@monitor:~#
Потвърждение за това може да видим и в dmesg
[2304964.198066] scsi 32:0:1:0: Direct-Access VMware Virtual disk 2.0 PQ: 0 ANSI: 6 [2304964.198077] scsi target32:0:1: Beginning Domain Validation [2304964.198752] scsi target32:0:1: Domain Validation skipping write tests [2304964.198756] scsi target32:0:1: Ending Domain Validation [2304964.198788] scsi target32:0:1: FAST-80 WIDE SCSI 160.0 MB/s DT (12.5 ns, offset 127) [2304964.199291] sd 32:0:1:0: Attached scsi generic sg2 type 0 [2304964.199357] sd 32:0:1:0: [sdb] 671088640 512-byte logical blocks: (344 GB/320 GiB) [2304964.199973] sd 32:0:1:0: [sdb] Write Protect is off [2304964.199977] sd 32:0:1:0: [sdb] Mode Sense: 61 00 00 00 [2304964.200017] sd 32:0:1:0: [sdb] Cache data unavailable [2304964.200020] sd 32:0:1:0: [sdb] Assuming drive cache: write through
Това е!