How to add a new hard disk without shutting down a Linux Server
Method 1:
1. After the disk is inserted, run echo "---">/sys/class/scsi_host/host0/scan
2. Check whether the command in step 1 takes effect. You can verify it in/var/log/messages.
3. Run the fdisk-l command to check whether the new disk can be seen. If not, replace host0 with host1 or host2 and try again.
Method 2:
1. Insert the disk, run the/proc/scsi directory, and then less./scsi to check the current SCSI disk usage.
Root @ debian:/proc/scsi # ls
Device_info scsi
Root @ debian:/proc/scsi # less scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: KINGSTON SVP200S Rev: 501A
Type: Direct-Access ansi scsi revision: 05
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: ATA Model: TOSHIBA DT01ACA2 Rev: MX4O
Type: Direct-Access ansi scsi revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: WDC WD20EURS-63S Rev.: 80.0
Type: Direct-Access ansi scsi revision: 05
You can find the four parameters used by the disk, namely the primary adapter ID, the SCSI channel on the primary adapter, the scsi id of the device, and the LUN Number of the device.
2. Run the command to add a disk: echo "scsi add-single-device w x y z">/proc/scsi
The specified parameter values w, x, y, and z are as follows:
W is the host adapter identifier, and the first adapter is zero (0)
X is the SCSI channel on the host Adapter. The first channel is zero (0)
Y is the scsi id of the device.
Z is the LUN number, and the first LUN is zero (0)
Note: You can use this command to delete a disk: echo "scsi remove-single-device w x y z">/proc/scsi
3. Use the fdisk-l command to partition and format the disk.