Why is the /proc folder recursively nested?

I was doing a scp to copy my Yun's filesystem to my local computer and it kept going for hours - I then found that there's a loop in the file structure:

proc/self/task/1870/fd/3/proc/self/task/1870/fd/3/proc/self/task/1870/fd/3/... and so on.

Can anyone explain why this is the case, and whether there's any reason this recursiveness is needed beyond the first ../fd/3?

Why were you copying /proc anyway?

I'm trying to make a disk image of my Yun so I can copy it precisely to other Yuns.

/proc/self is a symlink to the process ID of the process trying to read the file. Then file descriptor /fd/3 is the descriptor that you're using to read /proc... and yay recursion.

The better way to handle this would be to run a "mount -l", iterate through the mounts listed, and then only copy those paths that have "normal" filesystem types (ext3, fat, zfs, whatever).

sscirrus:
I'm trying to make a disk image of my Yun so I can copy it precisely to other Yuns.

You don't want to copy /sys or /proc, ever.

AWOL:
You don't want to copy /sys or /proc, ever.

Is it correct then that if I copy everything except /sys and /proc over to a brand new Yun, it'd be identical in terms of function, support, packages, etc.?

I don't know - I don't have a Yun.

AWOL:
I don't know - I don't have a Yun.

I'm new to some of this stuff and I assume there's a reason why /sys and /proc should not, in general, be copied when backing up. What is that reason?

They're not true filesystems related to storage devices (unlike ext4), they're dynamic reflections of the state of that particular device at that particular moment, generated by the device drivers and the kernel itself.
Try something simple like cat /process/meminfo over time, and load, and notice how it changes.

sonnyyu:
The original Yun:

root@Arduino:/# cat /proc/mtd

dev:    size   erasesize  name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00e50000 00010000 "rootfs"
mtd3: 006f0000 00010000 "rootfs_data"
mtd4: 00140000 00010000 "kernel"
mtd5: 00010000 00010000 "nvram"
mtd6: 00010000 00010000 "art"
mtd7: 00f90000 00010000 "firmware"




"rootfs_data" has every thing you modify.



dd if=/dev/mtd3 of=/tmp/rootfs_data.backup




copy "/tmp/rootfs_data.backup" to PC

**The copied Yun**:

copy "/tmp/rootfs_data.backup" of PC to Yun



mtd -r write /tmp/rootfs_data.backup rootfs_data

Or copy "/tmp/rootfs_data.backup" of PC to an other Yun.