Linux

Linux fsck.ext3 說“設備或資源忙”雖然我沒有掛載磁碟

  • May 2, 2012

編輯這個老問題可能不值得一讀,因為解決方案很簡單。我在整個驅動器上使用了 checkdisk,而不是在該驅動器的分區上,僅此而已。matnagel /編輯

我在 vmware 1.0.9 上執行帶有 8GB 虛擬磁碟的 ubuntu 8.04 伺服器實例。

對於磁碟維護,我製作了虛擬磁碟的副本(通過在主機上停止的 vm 上複製 sda 的 2 個 vmdk 文件)並將其添加到原始 vm。現在這個 vm 有它的原始虛擬磁碟 sda 加上一個 1:1 副本 (sdd)。我忽略了另外 2 個磁碟 sdb 和 sdc。)

我希望啟動 vm 時不會掛載 sdb。所以我嘗試 tp 從正在執行的 vm 在 sdd 上執行 ext2 fsck,但它報告 fsck 報告 sdb 已安裝。

$ sudo fsck.ext3 -b 8193 /dev/sdd
e2fsck 1.40.8 (13-Mar-2008)
fsck.ext3: Device or resource busy while trying to open /dev/sdd
Filesystem mounted or opened exclusively by another program?

“mount”命令沒有告訴我 sdd 已安裝:

$ sudo mount
/dev/sda1 on / type ext3 (rw,relatime,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sdc1 on /mnt/r1 type ext3 (rw,relatime,errors=remount-ro)
/dev/sdb1 on /mnt/k1 type ext3 (rw,relatime,errors=remount-ro)
securityfs on /sys/kernel/security type securityfs (rw)

當我忽略警告並繼續 fsck 時,它報告了許多錯誤。

我該如何控制這種情況?有沒有更好的方法來確定 sdd 是否已安裝?或者它是如何“忙?如何解除安裝它?如何防止 ubuntu 自動掛載。或者我還缺少什麼?另外從 /var/log/syslog 我看不到它已掛載,這是最後一部分啟動順序:

kernel: [   14.229494] ACPI: Power Button (FF) [PWRF]
kernel: [   14.230326] ACPI: AC Adapter [ACAD] (on-line)
kernel: [   14.460136] input: PC Speaker as /devices/platform/pcspkr/input/input3
kernel: [   14.639366] udev: renamed network interface eth0 to eth1
kernel: [   14.670187] eth1: link up
kernel: [   16.329607] input: ImPS/2 Generic Wheel Mouse as /devices/platform/i8042/serio1/
kernel: [   16.367540] parport_pc 00:08: reported by Plug and Play ACPI
kernel: [   16.367670] parport0: PC-style at 0x378, irq 7 [PCSPP,TRISTATE]
kernel: [   19.425637] NET: Registered protocol family 10
kernel: [   19.437550] lo: Disabled Privacy Extensions
kernel: [   24.328857] loop: module loaded
kernel: [   24.449293] lp0: using parport0 (interrupt-driven).
kernel: [   26.075499] EXT3 FS on sda1, internal journal
kernel: [   28.380299] kjournald starting.  Commit interval 5 seconds
kernel: [   28.381706] EXT3 FS on sdc1, internal journal
kernel: [   28.381747] EXT3-fs: mounted filesystem with ordered data mode.
kernel: [   28.444867] kjournald starting.  Commit interval 5 seconds
kernel: [   28.445436] EXT3 FS on sdb1, internal journal
kernel: [   28.445444] EXT3-fs: mounted filesystem with ordered data mode.
kernel: [   31.309766] eth1: no IPv6 routers present
kernel: [   35.054268] ip_tables: (C) 2000-2006 Netfilter Core Team
mysqld_safe[4367]: started
mysqld[4370]: 100124 14:40:21  InnoDB: Started; log sequence number 0 10130914
mysqld[4370]: 100124 14:40:21 [Note] /usr/sbin/mysqld: ready for connections.
mysqld[4370]: Version: '5.0.51a-3ubuntu5.4'  socket: '/var/run/mysqld/mysqld.sock'  port: 3
/etc/mysql/debian-start[4417]: Upgrading MySQL tables if necessary.
/etc/mysql/debian-start[4422]: Looking for 'mysql' in: /usr/bin/mysql
/etc/mysql/debian-start[4422]: Looking for 'mysqlcheck' in: /usr/bin/mysqlcheck
/etc/mysql/debian-start[4422]: This installation of MySQL is already upgraded to 5.0.51a, u
/etc/mysql/debian-start[4436]: Checking for insecure root accounts.
/etc/mysql/debian-start[4444]: Checking for crashed MySQL tables.

是的,您是對的,因為您在整個驅動器而不是分區上執行 fsck。要檢查文件系統是否已掛載,您可以檢查 /etc/mtab 並 grep lsof 的輸出,以確保沒有程序打開您的分區。

我才意識到我輸入了

$ sudo fsck.ext3 /dev/sdd

它告訴檢查整個磁碟而不是分區:它應該是

$ sudo fsck.ext3 /dev/sdd1

我認為這使這個問題過時了。我只是在檢查…

引用自:https://serverfault.com/questions/105829