How to make a copy of a device / socket file

I can find out the inode of the device / socket with stat, so that I can somehow "copy" this file for backup. Of course, the solution is "dd", but I have no idea what I can do if the device is infinite (for example, random). And can I somehow copy the index?

+3
source share
4 answers

They are called "special files" or "special nodes." Copying their contents does not make sense, since the contents are generated one way or another programmatically by the kernel as needed.

Programs such as tar can copy inode content that will reference a part of the kernel that supports each of these different nodes. See the mknod command documentation for more information.

+5
source

And if you need single-line copying of device nodes using tar, here it is:

cd /dev && tar -cpf- sda* | tar -xf- -C /some/destination/path/
+1
source

, , mknod . ( ). (, , , ..).

0

You can copy from a working system, as shown below, to some common place between the machines and copy from a common place to another system.

Machine A

cp -rf /dev/SRC shared_directory

Machine B

cp -rf shared_directory /dev/
-3
source

Source: https://habr.com/ru/post/1779054/


All Articles