Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to CentOS add a new hard disk to its virtual machine without rebooting

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to add a new hard disk to CentOS's virtual machine without rebooting". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Add a new 20g hard drive to ESXi or vCenter:

Show the current disk partition:

The code is as follows:

[root@centos7 ~] # fdisk-l

Disk / dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x0006b96a

Device Boot Start End Blocks Id System

/ dev/sda1 * 2048 1026047 512000 83 Linux

/ dev/sda2 1026048 62914559 30944256 8e Linux LVM

Disk / dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk / dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Determine the host bus number

The code is as follows:

[root@centos7 ~] # ls / sys/class/scsi_host/

Host0 host1 host2

Rescan the SCSI bus to add devices

The code is as follows:

[root@centos7 ~] # echo "- -" > / sys/class/scsi_host/host0/scan

[root@centos7 ~] # echo "- -" > / sys/class/scsi_host/host1/scan

[root@centos7 ~] # echo "- -" > / sys/class/scsi_host/host2/scan

Verify the disk and partition and make sure that the 20GB hard drive has been added. In this example, the following line "Disk / dev/sdb: 21.5GB, 21474836480 bytes, 41943040 sectors" appears and you can confirm that a new disk has been added without restarting the server:

The code is as follows:

[root@centos7 ~] # fdisk-l

Disk / dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x0006b96a

Device Boot Start End Blocks Id System

/ dev/sda1 * 2048 1026047 512000 83 Linux

/ dev/sda2 1026048 62914559 30944256 8e Linux LVM

Disk / dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk / dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk / dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

This is the end of how to add a new hard disk to CentOS's virtual machine without rebooting. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report