linux设备忙怎么解决,Linux umount 报 device is busy 的处理方法

今天在IDC辐射了半天,又弄了套DG。 在Linux挂盘这块也小学了两招。

一.umout移动硬盘

开始用sftp将安装文件copy到服务器的时候,速度太慢了,500k/s。几个G的东西,copy这些就要半个多小时,扛不住,拿移动硬盘来copy了。 结果移动硬盘的格式不对。 是NTFS格式,Linux识别不了。 只能格式化成FAT32的。 而GG的win7系统又不具备格式化成FAT32的功能。 有点小变态。让同事在XP下帮我格式化了。

安装文件copy到服务器后,同事直接将移动硬盘从服务器上拔下来了。 导致的结果是,用df命令查看,挂载的移动硬盘还存在。

[root@qs-wg-db1 ~]# df -lh

FilesystemSizeUsed Avail Use% Mounted on

/dev/sdb3125G3.3G115G3% /

/dev/sdb199M12M82M13% /boot

tmpfs3.9G03.9G0% /dev/shm

/dev/sda1275G72G189G28% /u01

/dev/sdc110G2.0G8.1G20% /datatmp

就是这个/dev/sdc1。

这时使用umount命令,会提示设备忙,无法挂载。

处理方法:

[root@qs-wg-db1 ~]# fuser -km /datatmp

[root@qs-wg-db1 ~]# df -lh

FilesystemSizeUsed Avail Use% Mounted on

/dev/sdb3125G3.3G115G3% /

/dev/sdb199M12M82M13% /boot

tmpfs3.9G03.9G0% /dev/shm

/dev/sda1275G72G189G28% /u01

/dev/sdc110G2.0G8.1G20% /datatmp

[root@qs-wg-db1 ~]# umount /datatmp

[root@qs-wg-db1 ~]# df -lh

FilesystemSizeUsed Avail Use% Mounted on

/dev/sdb3125G3.3G115G3% /

/dev/sdb199M12M82M13% /boot

tmpfs3.9G03.9G0% /dev/shm

/dev/sda1275G72G189G28% /u01

成功umount了。

二. umount光驱

安装DB之前,检查了一下相关包,少了3个。 从系统安装盘上找了包,安装了一下。 当时是直接将/dev/cdrom mount到了/mnt目录。 也是图个方便。 结果收工时去拿盘,光驱弹不出来。 同事让我把cdrom umout掉。 同样的提示,设备忙。

处理方法:

[root@qs-wg-db1 ~]#fuser –km /dev/cdrom

[root@qs-wg-db1 ~]#eject--弹出光驱

在网上搜了一下,正确挂载CD-ROM的方法应该如下:

# mkdir cdrom

# mount /dev/cdrom /mnt/cdrom或者

# mount /dev/cdrom /media/cdrom

直接挂载在/mnt,/media等系统目录下,在umount时会出现出错信息“umount: /mnt/cdrom: device is busy”的情况。

如果一个文件系统处于“busy”状态的时候,不能卸载该文件系统。如下情况将导致文件系统处于“busy”状态:

1)文件系统上面有打开的文件

2)某个进程的工作目录在此文件系统上

3)文件系统上面的缓存文件正在被使用

三. fuser命令

前面2个umout都使用了这个fuser命令。 man了一下这个命令。 内容如下:

[root@qs-wg-db1 ~]# man fuser

FUSER(1)User CommandsFUSER(1)

NAME

fuser - identify processes using files or sockets

SYNOPSIS

fuser [-a|-s|-c] [-4|-6] [-nspace ] [-k [-i] [-signal ] ] [-muvf] name

fuser -l

fuser -V

DESCRIPTION

fuser displays the PIDs of processes using the specified files or file systems.In the default display mode, each file name is followed by a letter denoting thetype

of access:

ccurrent directory.

eexecutable being run.

fopen file. f is omitted in default display mode.

Fopen file for writing. F is omitted in default display mode.

rroot directory.

mmmap'ed file or shared library.

fuserreturns a non-zero return code if none of the specified files is accessed or in case of a fatal error. If at least one accesshasbeenfound,fuserreturns zero.

Inordertolookup processes using TCP and UDP sockets, the corresponding name space has to be selected with the -n option. By default fuserwilllookinboth IPv6and IPv4 sockets. To change the default, behavior, use the -4 and -6 options. The socket(s) can be specified bythelocalandremoteport,andtheremote address.Allfieldsareoptional, but commas in front of missing fields must be present:

[lcl_port][,[rmt_host][,[rmt_port]]]

Either symbolic or numeric values can be used for IP addresses and port numbers.

fuser outputs only the PIDs to stdout, everything else is sent to stderr.

OPTIONS

-aShow all files specified on the command line. By default,onlyfilesthat are accessed by at least one process are shown.

-cSame as -m option, used for POSIX compatibility.

-fSilently ignored, used for POSIX compatibility.

-kKillprocessesaccessing the file. Unless changed with -signal, SIGKILL is sent. An fuser process never kills itself, but maykillotherfuserprocesses.Theeffective user ID of the process executing fuser is set to its real user ID before attempting to kill.

-iAsk the user for confirmation beforekillingaprocess.Thisoptionis silently ignored if -k is not present too.

-lList all known signal names.

-mnamespecifiesafileon a mounted file system or a block device that is mounted. All processes accessing files on that file system are listed.If adirectoryfileisspecified, it is automatically changed to name/. to use any file system that might be mounted on that directory.

-n space Select a different namespace.Thenamespacesfile(filenames,the default),udp(localUDP ports), and tcp (local TCP ports) are supported. For ports, either the port number or the symbolic name can be specified.If thereis no ambiguity, the shortcut notation name/Ispace (e.g. 80/tcp ) can be used.

-sSilent operation. -u and -v are ignored in this mode.-a must notbeused with -s.

-signal Usethe specified signal instead of SIGKILL when killing processes. Signals can be specified either by name (e.g. -HUP) or bynumber(e.g.-1).This option is silently ignored if the -k option is not used.

-uAppend the user name of the process owner to each PID.

-vVerbosemode.Processes are shown in a ps-like style. The fields PID, USER and COMMAND are similar to ps. ACCESS shows howtheprocessaccessesthe file.Ifthe access is by the kernel (e.g. in the case of a mount point, awap file, etc.), kernel is shown instead of the PID.

-VDisplay version information.

-4Search only for IPv4 sockets. This option mustnotbeusedwiththe-6 option and only has an effect with the tcp and udp namespaces.

-6SearchonlyforIPv6sockets.Thisoption must not be used with the -4 option and only has an effect with the tcp and udp namespaces.

-Reset all options and set the signal back to SIGKILL.

FILES

/proclocation of the proc file system

fuser命令显示访问某个文件的进程的PID.其中-k和-m参数上面红色部分有说明。-k是kill访问这个文件的进程。 没有进程访问,就可以成功umount了.

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值