Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
detemine "which device a file is in" in chroot environment?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
fpemud
Apprentice
Apprentice


Joined: 15 Feb 2012
Posts: 272

PostPosted: Thu May 26, 2016 12:07 pm    Post subject: detemine "which device a file is in" in chroot env Reply with quote

According to the answers below:
http://stackoverflow.com/questions/5517988/linux-programming-which-device-a-file-is-in
http://unix.stackexchange.com/questions/128471/determine-what-device-a-directory-is-located-on
http://unix.stackexchange.com/questions/11311/how-do-i-find-on-which-physical-device-a-folder-is-located

I can find which device a file is in by df command in a normal environment:
Code:

fpemud-workstation / # df /bin
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/dm-0      476458008 48307576 403924640  11% /


But I can't use that method in chroot:
Code:

fpemud-workstation / # mount -t proc n /test/proc
fpemud-workstation / # mount --rbind /sys /test/sys
fpemud-workstation / # mount --make-rslave /test/sys
fpemud-workstation / # mount --rbind /dev /test/dev
fpemud-workstation / # mount --make-rslave /test/dev
fpemud-workstation / # chroot /test df /bin
Filesystem     1K-blocks     Used Available Use% Mounted on
-              476458008 48307604 403924612  11% /
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6228
Location: Room 101

PostPosted: Thu May 26, 2016 1:43 pm    Post subject: Reply with quote

fpemud ...

/test/etc/mtab points to /proc/self/mounts?

best ... khay
Back to top
View user's profile Send private message
fpemud
Apprentice
Apprentice


Joined: 15 Feb 2012
Posts: 272

PostPosted: Thu May 26, 2016 2:41 pm    Post subject: Reply with quote

Not any luck. This is the result after I added /test/etc/mtab:

Code:

fpemud-workstation / # mount -t proc n /test/proc
fpemud-workstation / # mount --rbind /sys /test/sys
fpemud-workstation / # mount --make-rslave /test/sys
fpemud-workstation / # mount --rbind /dev /test/dev
fpemud-workstation / # mount --make-rslave /test/dev

fpemud-workstation / # chroot /test ls /etc/mtab -l
lrwxrwxrwx 1 root root 19 May 26 22:37 /etc/mtab -> ../proc/self/mounts

fpemud-workstation / # chroot /test df /bin
Filesystem     1K-blocks     Used Available Use% Mounted on
-              476458008 51387464 400844752  12% /

fpemud-workstation / # chroot /test cat /proc/mounts
n /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
devtmpfs /dev devtmpfs rw,nosuid,size=1997472k,nr_inodes=499368,mode=755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum