You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7.3配置DRBD后重启报/dev/centos/root swap不存在的解决办法

Hey there, let's work through this boot issue with DRBD on your CentOS 7.3 system. From what you described, the root cause is almost certainly your initramfs lacking the necessary components to handle DRBD or your modified LVM setup, which is why it drops into the dracut shell on every reboot. Let's break down the fixes step by step:

Step 1: Validate Your Mount & DRBD Configs

First, let's make sure your system is trying to mount the right device and your DRBD setup is correctly defined:

  • Check your /etc/fstab: Ensure you're mounting /dev/drbd0 (the DRBD resource device) instead of the underlying /dev/mapper/centos-drbd LV. The LV is DRBD's backend storage and shouldn't be directly mounted. Also, add the _netdev mount option—this tells the system to wait for network/DRBD readiness before attempting to mount:
    /dev/drbd0    /your/mount/point    ext4    defaults,_netdev    0 0
    
  • Verify your DRBD resource file (usually in /etc/drbd.d/, e.g., r0.res): Confirm the device is /dev/drbd0, disk points to /dev/mapper/centos-drbd, and if you're running a single node test, add on-startup primary; to the host block so the node automatically claims primary status on boot:
    resource r0 {
        device /dev/drbd0;
        disk /dev/mapper/centos-drbd;
        meta-disk internal;
        on your-hostname {
            address 192.168.x.x:7789;
            on-startup primary;
        }
        # Add secondary node config here if applicable
    }
    
Step 2: Refresh Initramfs with DRBD & LVM Modules

CentOS 7's default initramfs doesn't include DRBD modules out of the box, and your modified LVM setup might not be reflected in the existing initramfs either. Let's fix that:

  1. Ensure you have all required DRBD packages installed:
    yum install drbd-utils kmod-drbd
    
  2. Regenerate the initramfs to include DRBD and LVM components:
    dracut -f --add drbd --add lvm /boot/initramfs-$(uname -r).img $(uname -r)
    
  3. Verify the modules were added successfully:
    lsinitrd /boot/initramfs-$(uname -r).img | grep -E '(drbd|lvm)'
    
    You should see DRBD kernel modules and LVM utilities listed.
Step 3: Ensure DRBD Starts on Boot

Make sure the DRBD service is enabled so it initializes /dev/drbd0 before the system tries to mount it:

systemctl enable drbd.service

If you still run into timing issues, you can force the local filesystem mount target to wait for DRBD:

systemctl add-requires local-fs.target drbd.service
Step 4: Pre-Reboot Validation

Before rebooting, confirm everything is in a healthy state:

  • Check DRBD resource status:
    drbdadm status
    
    You should see your resource marked as Primary/UpToDate (for single node) or Primary/Secondary if you have a cluster.
  • Verify the DRBD device mounts correctly manually:
    mount /dev/drbd0 /your/mount/point
    umount /dev/drbd0
    

If you hit the dracut shell again, pay close attention to the error messages—it will usually tell you exactly which device it can't find (either /dev/drbd0 or /dev/mapper/centos-drbd), which can narrow down if the issue is with DRBD initialization or LVM detection.

内容的提问来源于stack exchange,提问作者bakasan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:06:33