GlassFoxowo
作者
2025年1月21日
约 3 分钟
Music
TL;DR(太长不看版)
关键错误信息:ERROR: unable to open /dev/sda2: Device or resource busy
解决方案:
dmsetup remove ArchinstallVg-root
问题描述
在使用 archinstall 安装 Arch Linux 时,我启用了 LVM(逻辑卷管理),但因意外中断了安装过程。在尝试重新安装时,遇到了严重的问题,报错信息如下:
ERROR: unable to open /dev/sda2: Device or resource busy
更详细的日志输出:
File "/usr/lib/python3.13/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/usr/lib/python3.13/site-packages/archinstall/scripts/guided.py", line 186, in <module>
guided()
~~~~~~^^
File "/usr/lib/python3.13/site-packages/archinstall/scripts/guided.py", line 182, in guided
fs_handler.perform_filesystem_operations()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/site-packages/archinstall/lib/disk/filesystem.py", line 84, in perform_filesystem_operations
self._format_partitions(
~~~~~~~~~~~~~~~~~~~~~~~^
mod.partitions,
^^^^^^^^^^^^^^^
mod.device_path
^^^^^^^^^^^^^^^
)
^
File "/usr/lib/python3.13/site-packages/archinstall/lib/disk/filesystem.py", line 118, in _format_partitions
device_handler.format(part_mod.safe_fs_type, part_mod.safe_dev_path)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/site-packages/archinstall/lib/disk/device_handler.py", line 296, in format
raise DiskError(msg) from err
archinstall.lib.exceptions.DiskError: Could not format /dev/sda2 with btrfs: ['/usr/bin/mkfs.btrfs', '-f', '/dev/sda2'] exited with abnormal exit code [1]: btrfs-progs v6.12
See https://btrfs.readthedocs.io for more information.
ERROR: unable to open /dev/sda2: Device or resource busy
Archinstall experienced the above error. If you think this is a bug, please report it to
https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".
Hint: To extract the log from a live ISO
curl -F'file=@/var/log/archinstall/install.log' https://0x0.st
排查步骤
通过以下方法尝试解决问题:
-
移除物理卷:
pvremove /dev/sda返回错误信息:
Cannot use /dev/sda: device is partitioned -
擦除文件系统签名:
wipefs -a /dev/sda返回错误信息:
error: /dev/sda: probing initialization failed: Device or resource busy -
卸载挂载点:
umount /dev/sda2但发现设备未挂载,继续排查资源占用问题。
-
查看占用情况:
lsof /dev/sda2无输出,表明没有活跃进程占用。
-
停用卷组:
vgchange -an
解决方案
最终,通过以下命令解决问题:
dmsetup ls
列出活动设备映射项,发现 ArchinstallVg-root 存在。使用以下命令移除:
dmsetup remove ArchinstallVg-root
此后,重新运行安装流程问题得到解决。
总结
问题原因:意外中断安装后,LVM 的设备映射未被正确清理,导致设备被占用。 解决方法:手动清理设备映射。
此问题的经验教训在于,LVM 的设备管理需要谨慎操作,尤其在自动化工具意外中止的情况下,手动介入尤为重要。希望这篇记录对遇到类似问题的朋友有所帮助。
若无特殊说明,本站内容遵循 CC BY-NC-SA 4.0 国际许可证分发