how to include or add /dev with tar --one-file-system

You could probably simply add it to the pathnames to be included.

tar -cf - --one-file-system / /dev/

However this is usually not what you really want at all, as the dynamic /dev would include way too many completely wrong or irrelevant device nodes.

A better way (better in the sense of actually getting a complete copy of the original root filesystem, including files hidden by other mounts) to do it is to make another mount of the filesystem, which is not obstructed by submounts, and tar that.

That way you get the /dev/ (and everything else) that is actually stored on the root filesystem. That should usually include only a standard set of /dev nodes that was originally created at install time, and only needed at boot time until the system sets up the dynamic /dev/ on top of it.

mkdir /mnt/root
mount --bind / /mnt/root
cd /mnt/root
tar -cpvzf - .
cd /
umount /mnt/root

As the mount manpage states, the bind mount call attaches only (part of) a single filesystem, not possible submounts. That's why the --one-file-system is no longer needed: there are no other filesystems under this structure.


Just add /dev onto the list of files to archive:

ssh -n <hostname> sudo tar -cpvzf - --one-file-system / /dev > Bak.tar.gz

--one-file-system only prevents recursing into directories on different filesystems. You can still list files/directories on different filesystems directly as arguments to tar.