6.3. Moving a swap file system from a single path device to a multipath device


Move swap file system from single-path to multipath storage to ensure redundancy and prevent performance issues. If swap uses LVM, no special steps are needed, but non-LVM swap devices may require editing /etc/fstab to use the correct multipath device name.

Procedure

  1. Create the /etc/multipath.conf configuration file:

    # mpathconf --enable
  2. Enable the multipathd service:

    # systemctl enable multipathd.service
  3. If the find_multipaths configuration parameter is not set to on, edit the blacklist and blacklist_exceptions sections of the /etc/multipath.conf file, as described in Preventing devices from multipathing.
  4. Add the WWID of the device to the /etc/multipath/wwids file:

    # multipath -a /dev/sdb
    wwid '3600d02300069c9ce09d41c4ac9c53200' added

    Replace /dev/sdb with the swap device name.

  5. Confirm that your configuration file is set up correctly:

    # multipath -d 3600d02300069c9ce09d41c4ac9c53200
    : mpatha (3600d02300069c9ce09d41c4ac9c53200) undef 3PARdata,VV
    size=446M features='1 queue_if_no_path' hwhandler='1 alua' wp=undef
    `-+- policy='service-time 0' prio=50 status=undef
      `- 5:0:0:0 sdb 8:16 undef ready running

    Replace 3600d02300069c9ce09d41c4ac9c53200 with the WWID of your swap device.

  6. Set up an alias for the swap device in the /etc/multipath.conf file:

    multipaths {
        multipath {
            wwid WWID_of_swap_device
            alias swapdev
        }
    }
  7. Edit the /etc/fstab file and replace the old device path to the root device with the multipath device.

    For example, if you had the following entry in the /etc/fstab file:

    /dev/sdb2 swap                    swap    defaults        0 0

    Change the entry to the following:

    /dev/mapper/swapdev swap          swap    defaults        0 0
  8. Rebuild the initramfs file system with multipath:

    # dracut --force --add multipath
  9. Shut the machine down.
  10. Boot the machine.
  11. Make the other paths visible to the machine.

Verification

  • Verify if the swap device is on the multipath device:

    # swapon -s
    
    Filename                Type          Size Used    Priority
    /dev/dm-3               partition     4169724 0    -2

    The file name should match the multipath swap device.

    # readlink -f /dev/mapper/swapdev
    /dev/dm-3
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部