Hacker News new | past | comments | ask | show | jobs | submit login

Please show me how you cp a raw device without the concept of files. I’d love to learn.

$ cp /dev/nvme0n1p1 /mnt/my-special-backup

?




dd can copy block by block from one block device to another

ddrescue can do the same, but will handle errors better

e2image understands ext2/3/4 filesystems and can copy only the blocks in use, which can really help (though don't know how it works if it encounters an error)


A device is a file. That's the power and elegance of Unix-like systems.


The correct abstraction is that a file is a device. A file is a section of a hard disk which behaves like a whole disk. It also happens to be expandable.

cp's default behaviour for device files also happens to be very stupid.


Yes


Ha. Today I learned. Is this a portable approach across macOS, Linux and BSD family ?


> Is this a portable approach across macOS, Linux and BSD family ?

I think that feature relies in the concept of a device file, which is a direct reflection of the UNIX trait of everything being a file.

https://en.wikipedia.org/wiki/Device_file




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: