I want to make an exact copy of the /sys
directory, and tried the following command:
sudo cp -ra /sys ~/Documents/dir1
It does not work as I expected... I get a lot of error messages such as:
cp: error reading '/sys/fs/cgroup/memory/memory.force_empty': Invalid argument
cp: error reading '/sys/devices/system/cpu/cpu0/cache/index0/power/autosuspend_delay_ms': Input/output error
cp: cannot open '/sys/devices/system/clockevents/clockevent0/unbind_device' for reading: Permission denied
cp: error reading '/sys/devices/virtual/block/loop0/trace/enable': No such device or address
Why isn't sudo
enough to make cp
copy every file?
The
/sys
directory isn't a normal directory, but instead a "virtual" one. From "The Linux Filesystem Explained":Similar directories are
/dev
,/proc
and/run
.Since files in these directories are created, changed and removed all the time while the system is running, it doesn't make any sense to copy them.
Think more of these directories as a dynamic snapshot of the current state of the system, rather than a static medium of storage.
The reason you get errors even with
sudo
is probably that the files are either fully locked or removed by the system before thecp
command could take effect.