dd to a different filesystem
Is it possible to use dd to copy data from an NTFS drive to an XFS formatted drive?
No, dd
reads/writes blocks, not files. When writing a backup image from a source NTFS drive to a target (XFS/EXT4/FAT32) drive, the target drive would become NTFS no matter what FS it was formated with before.
It's possible to mount an dd
image and copy the data:
mount -o ro,loop -t ntfs myimage.img /mnt/
but then better just tar
your data = archive it without compression but save user, group and permission!
tar cvf /foo/bar/my_backup.tar /
But what if I copy /dev/sad1 to a partition thats in a different format?
Yes, you can mount two drives with different filesystems and copy files between them. ie: /dev/sda
with NTFS and /dev/sdb
with XFS .
But what if I copy /dev/sad1 to a partition that[']s in a different format?
(Presumably a typo, meaning /dev/sda1)
If you copy with dd, the result is that the new partition uses the same format, because dd preserves the filesystem's formatting. So, the result doesn't end up being "in a different format".
Is it possible to use dd to copy data from an NTFS drive to an XFS formatted drive?
Yes, you can do what you asked.
However, from your description, it's not clear that what you're asking (can you store data from NTFS onto XFS) will do exactly what you want.
From a comment made on Michael D's answer:
dd if=a of=b
is equivalent tocp a b
I typically think of dd
as being designed to work well with devices. If "a" and "b" (in the prior examples) are files, then what you said is true. However, dd is typically used when "a" or "b" is a "device" object (or, if both "a" and b" are devices). In this context, the term "device" refers to a type of object on the filesystem. Most commonly/traditionally, interacting with such devices will involve communicating to hardware, e.g. /dev/sda may refer to a hard drive. As software is highly customizable, there can be other cases, like /dev/sda1 which communicates with just a section of data on the hard drive.
So, this can work well:
dd if=/dev/sda1 of=~/ntfscopy.img
This stores the entire NTFS partition, including the "metadata" like the internal structures of the filesystem, into a file called ~/ntfscopy. You could then copy that to a XFS drive:
cp ~/ntfscopy.img /mnt/xfsdrive/ntfscopy.img
Or, you could skip that separate step:
dd if=/dev/sda1 of=/mnt/xfsdrive/ntfscopy.img
Now, this may be useful to back up data. When you find some empty space on a partition, you can write it out. (Of course, this example involves writing to a partition, so you've got to be VERY CAREFUL that you don't end up overwriting data.)
dd if=/mnt/xfsdrive/ntfscopy.img of=/dev/sdb2
This shows a useful example of having data copied from an NTFS drive to an XFS drive, and that works.
Now, what if you just wanted the files copied from an NTFS drive, and not the entire NTFS partition (including the internal filesystem structure which is what makes the partition use NTFS formatting)? In that case, you wouldn't want to have used dd. By using a different tool, you can avoid unnecessarily reading/copying all of the NTFS internal filesystem structures. e.g., you could mount the NTFS drive (read-only, if you like), and then use "cp" to copy data from the NTFS drive (or maybe "tar", if you want the output to be one convenient file).