Este contenido no está disponible en el idioma seleccionado.

Chapter 20. Removing storage devices


You can safely remove a storage device from a running system, which helps prevent system memory overload and data loss.

Do not remove a storage device on a system where:

  • Free memory is less than 5% of the total memory in more than 10 samples per 100.
  • Swapping is active (non-zero si and so columns in the vmstat command output).

Before you remove a storage device, ensure that you have enough free system memory due to the increased system memory load during an I/O flush. Use the following commands to view the current memory load and free memory of the system:

+

# vmstat 1 100

+

# free

20.1. Safe removal of storage devices

Safely removing a storage device from a running system requires a top-to-bottom approach. Start from the top layer, which typically is an application or a file system, and work towards the bottom layer, which is the physical device.

You can use storage devices in multiple ways, and they can have different virtual configurations on top of physical devices. For example, you can group multiple instances of a device into a multipath device or include it in a Redundant Array of Independent Disks (RAID). You can also make the device part of a Logical Volume Manager (LVM) group. Additionally, devices can be accessed via a file system, or they can be accessed directly such as a "raw" device.

While using the top-to-bottom approach, you must ensure that:

  • the device that you want to remove is not in use
  • all pending I/O to the device is flushed
  • the operating system is not referencing the storage device

20.2. Removing block devices and associated metadata

To safely remove a block device from a running system and avoid memory overload or data loss, remove its metadata first. Address each layer, starting with the filesystem down to the disk—to ensure the system remains stable and in a consistent state.

Prerequisites

  • You have an existing block device stack containing the file system, the logical volume, and the volume group.
  • You ensured that no other applications or services are using the device that you want to remove.
  • You backed up the data from the device that you want to remove.
  • Optional: If you want to remove a multipath device, and you are unable to access its path devices, disable queueing of the multipath device by running the following command:

    # multipathd disablequeueing map multipath-device

    This enables the I/O of the device to fail, allowing the applications that are using the device to shut down.

Note

Removing devices with their metadata one layer at a time ensures no stale signatures remain on the disk.

Use specific commands depending on what type of devices you are removing:

  • For LVM, run lvremove, vgremove, and pvremove.
  • For software Redundant Array of Independent Disks (RAID), run mdadm to remove the array. For more information, see Managing RAID.
  • For block devices encrypted by using Linux Unified Key Setup (LUKS), there are specific additional steps. The following procedure will not work for the block devices encrypted by using LUKS. For more information, see Encrypting block devices by using LUKS.
Warning

Rescanning the Small Computer System Interface (SCSI) bus or performing other actions that change the operating system state without following this procedure can cause delays. These delays may result from I/O timeouts, unexpected device removal, or data loss.

Procedure

  1. Unmount the file system:

    # umount /mnt/mount-point
  2. Remove the file system:

    # wipefs -a /dev/vg0/myvol

    If you have added an entry into the /etc/fstab file to make a persistent association between the file system and a mount point, edit /etc/fstab at this point to remove that entry.

    Continue with the following steps, depending on the type of the device you want to remove:

  3. Remove the logical volume (LV) that contained the file system:

    # lvremove vg0/myvol
  4. If there are no other logical volumes remaining in the volume group (VG), you can safely remove the VG that contained the device:

    # vgremove vg0
  5. Remove the physical volume (PV) metadata from the PV device(s):

    # pvremove /dev/sdc1
    # wipefs -a /dev/sdc1
  6. Remove the partitions that contained the PVs:

    # parted /dev/sdc rm 1
  7. Remove the partition table if you want to fully wipe the device:

    # wipefs -a /dev/sdc
  8. Execute the following steps only if you want to physically remove the device:

    • If you are removing a multipath device, execute the following commands:

      1. View all the paths to the device:

        # multipath -l

        The output of this command is required in a later step.

      2. Flush the I/O and remove the multipath device:

        # multipath -f multipath-device
    • If the device is not configured as a multipath device, or if the device is configured as a multipath device and you have previously passed I/O to the individual paths, flush any outstanding I/O to all device paths that are used:

      # blockdev --flushbufs device

      This is important for devices accessed directly where the umount or vgreduce commands do not flush the I/O.

    • If you are removing a SCSI device, execute the following commands:

      1. Remove any reference to the path-based name of the device, such as /dev/sd, /dev/disk/by-path, or the major:minor number, in applications, scripts, or utilities on the system. This ensures that different devices added in the future are not mistaken for the current device.
      2. Remove each path to the device from the SCSI subsystem:

        # echo 1 > /sys/block/device-name/device/delete

        Here the device-name is retrieved from the output of the multipath -l command, if the device was previously used as a multipath device.

  9. Remove the physical device from a running system. Note that the I/O to other devices does not stop when you remove this device.

Verification

  • Verify that the devices you intended to remove are not displaying on the output of lsblk command. The following is an example output:

    # lsblk
    NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda      8:0    0    5G  0 disk
    sr0     11:0    1 1024M  0 rom
    vda    252:0    0   10G  0 disk
    |-vda1 252:1    0    1M  0 part
    |-vda2 252:2    0  100M  0 part /boot/efi
    `-vda3 252:3    0  9.9G  0 part /
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2026 Red Hat
Volver arriba