linux查找目录的inode号,查找inode 对应的文件

在linux 下我们可能因为某一个文件(socket,pipe....)进程阻塞,这种情况需要找到拿这个文件的进程:

例查找setup.sh

E5450:~/opengrok_env$ ls -i setup.sh

12326181 setup.sh

1,一种方法 sudo lsof |grep 12326181 查找比较。

E5450:~/opengrok_env$ sudo lsof |grep 12326181

[sudo] password for zhixinlyl:

lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs

Output information may be incomplete.

sh         4964              zhixinlyl   10r      REG                8,8      649   12326181 /home/zhixinlyl/opengrok_env/setup.sh

2, 第二种方法知道inode ,通过debugfs 的脑filename 可操作性更强。

查找/home 属于的fs

E5450:~/opengrok_env$ mount -l

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)

udev on /dev type devtmpfs (rw,nosuid,relatime,size=4017452k,nr_inodes=1004363,mode=755)

devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)

tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=807724k,mode=755)

/dev/sda7 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)

securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)

tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)

tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)

tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)

cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)

pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)

cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)

cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)

cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)

cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)

cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)

cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)

cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)

cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)

cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)

cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)

systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=12340)

fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)

hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)

mqueue on /dev/mqueue type mqueue (rw,relatime)

debugfs on /sys/kernel/debug type debugfs (rw,relatime)

tracefs on /sys/kernel/debug/tracing type tracefs (rw,relatime)

/dev/sda8 on /home type ext4 (rw,relatime,data=ordered)

tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=807724k,mode=700,uid=1000,gid=1000)

gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)

E5450:~/opengrok_env$ sudo debugfs /dev/sda8

[sudo] password for zhixinlyl:

debugfs 1.42.13 (17-May-2015)

debugfs:  help

Available debugfs requests:

show_debugfs_params, params

Show debugfs parameters

open_filesys, open       Open a filesystem

close_filesys, close     Close the filesystem

freefrag, e2freefrag     Report free space fragmentation

feature, features        Set/print superblock features

dirty_filesys, dirty     Mark the filesystem as dirty

init_filesys             Initialize a filesystem (DESTROYS DATA)

show_super_stats, stats  Show superblock statistics

ncheck                   Do inode->name translation

icheck                   Do block->inode translation

change_root_directory, chroot

Change root directory

change_working_directory, cd

Change working directory

list_directory, ls       List directory

show_inode_info, stat    Show inode information

dump_extents, extents, ex

Dump extents information

blocks                   Dump blocks used by an inode

filefrag                 Report fragmentation information for an inode

link, ln                 Create directory link

unlink                   Delete a directory link

mkdir                    Create a directory

rmdir                    Remove a directory

rm                       Remove a file (unlink and kill_file, if appropriate)

kill_file                Deallocate an inode and its blocks

clri                     Clear an inode's contents

freei                    Clear an inode's in-use flag

seti                     Set an inode's in-use flag

testi                    Test an inode's in-use flag

debugfs:  ncheck 12326181

Inode    Pathname

12326181    /zhixinlyl/opengrok_env/setup.sh

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值