25.9. Removing a Storage Device
vmstat 1 100; device removal is not recommended if:
- Free memory is less than 5% of the total memory in more than 10 samples per 100 (the command
freecan also be used to display the total memory).
- Swapping is active (non-zero
socolumns in the
Procedure 25.11. Ensuring a Clean Device Removal
- Close all users of the device and backup device data as needed.
umountto unmount any file systems that mounted the device.
- Remove the device from any
mdand LVM volume using it. If the device is a member of an LVM Volume group, then it may be necessary to move data off the device using the
pvmovecommand, then use the
vgreducecommand to remove the physical volume, and (optionally)
pvremoveto remove the LVM metadata from the disk.
multipath -lcommand to find the list of devices which are configured as
multipathdevice. If the device is configured as a multipath device, run
multipath -f devicecommand to flush any outstanding I/O and to remove the multipath device.
- Flush any outstanding I/O to the used paths. This is important for raw devices, where there is no
vgreduceoperation to cause an I/O flush. You need to do this step only if:
Use the following command to flush any outstanding I/O:
- the device is not configured as a multipath device, or
- the device is configured as a multipath device and I/O has been issued directly to its individual paths at some point in the past.
#blockdev --flushbufs device
- Remove any reference to the device's path-based name, like
major:minornumber, in applications, scripts, or utilities on the system. This is important in ensuring that different devices added in the future will not be mistaken for the current device.
- Finally, remove each path to the device from the SCSI subsystem. To do so, use the command
echo 1 > /sys/block/device-name/device/deletewhere
sde, for example.Another variation of this operation is
echo 1 > /sys/class/scsi_device/h:c:t:l/device/delete, where
his the HBA number,
cis the channel on the HBA,
tis the SCSI target ID, and
lis the LUN.
NoteThe older form of these commands,
echo "scsi remove-single-device 0 0 0 0" > /proc/scsi/scsi, is deprecated.
device-name, HBA number, HBA channel, SCSI target ID and LUN for a device from various commands, such as
multipath -l, and
ls -l /dev/disk/by-*.