Copy files from a NTFS drive

From unRAID
Jump to: navigation, search

From forum by Joe L. Edited to wiki format and tweaked.

!!!!!!!!!!!!WARNING Danger of data loss. Be sure you understand this before proceeding!!!!!!!!!!!!

You can install drives in the unRaid server but DO NOT ASSIGN THEM in the disks page on the web-management utility. Instead, write down their disk assignment slots.

In other words, they will be at /dev/hda, /dev/hdb, /dev/hdc, etc... but the actual hd will be listed along side of the drive's serial number in the drop-down-field on the disk assignment page. Again, do not assign the disks, but write down their position in the array. (you must temporarally stop the array to see the physical device names of the disks in the drop-down-lists, but leave them unassigned to unRaid slots)

As an example... let's assume your old data disk was put in the physical device /dev/hdj ... type the following...

NTFS

First step, load the NTFS driver module into memory.

modprobe ntfs

Next step, create a mount point (an empty directory)

mkdir /mnt/old_data

Last, mount the drive on the mount point.

mount -r -t ntfs /dev/hdj1 /mnt/old_data -o umask=111,dmask=000 -v 

The umask and dmask options will prevent the unix "execute" bit being set when you copy files to other disks, which will translate as a hidden/system file under Samba.

Once the file-system is mounted, you can use the "cp" (copy) command to copy files from the NTFS drive. The root of the file-system will be at /mnt/old_data.

Note that the previous mount command will result in all the files being read-only. The NTFS driver supplied with unRAID is not able to be used in a read/write mode. This is a limitation of the driver, not one of unRAID. Do not attempt to mount the built-in ntfs driver in a read/write mode. It is unable to create files or to expand the size of existing files without corrupting the file-system.

There is a new ntfs-3g driver that can be used to both read and write to an NTFS file-system, but it is not supplied with unRAID. It can be downloaded to your server and installed if it is necessary to write to a mounted NTFS file-system.


EDIT(by cirkator - 14.05.2013)

If you want to mount HDDs above 2.2GB formated with NTFS file format, you need to install the "ntfs-3g driver" via unMENU and then mount the disk with

mount -t ntfs-3g /dev/hdj1 /mnt/old_data -o umask=111,dmask=000 -v 

Since I am a Linux Newbie and just figured this out myself after getting following error, can you Pros please verify my information and clarify if the "-o umask=111,dmask=000 -v" statements are also valid with my new method. Thank you!

When using the "old command", I got this error:
(I of course edited it according to my /dev/sdX)

root@Tower:/boot/unmenu# mount -r -t ntfs /dev/hdj1 /mnt/old_data -o umask=111,dmask=000 -v
mount: wrong fs type, bad option, bad superblock on /dev/sdc,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

FAT

mkdir /mnt/old_data
mount -r -t vfat /dev/hdj1 /mnt/old_data

Copy Files

then, you can use the unix cp command to copy your files to an existing data drive you previously added to your unRaid array.

To copy all your files to disk1 type this:

cd /mnt/old_data
cp -r * /mnt/disk1

However all of the files will have the current date/timestamp. To preserve the original date/timestamp of the files, use this command instead:

cd /mnt/old_data
cp -r --no-preserve=mode --preserve=timestamps * /mnt/disk1

Another useful option is to turn on verbose mode, and save the output to a file so you can check the results of the copy for any errors:

cd /mnt/old_data
cp -v -r --no-preserve=mode --preserve=timestamps * /mnt/disk1 | tee /boot/copyresults.txt

Unmount Drives

The first step in unmounting a drive is to ensure all buffered data has been written to it. The command to request that all buffered data be written to the physical disks is the sync command, so type:

sync

This will have the side effect of spinning up any disks, so it might take a few seconds to complete and return to a prompt.

Next, you will be unable to un-mount a disk if it is in use. The un-mount command will issue an error message stating that the device is "busy." A disk is considered busy if anybody is reading or writing it, or if anybody or any program has it as the current directory. If you followed instructions earlier, you used the "cd" command to change directory to the old disk you were copying from. You will now need to change directory so that your current directory is not on the old disk you will be unmounting. (previously, you changed directory to it to issue the copy command, now you need to change directory to someplace else so you can unmount it)

To change directory back to your home directory of /root you can type:

cd /root


Lastly, to unmount the old disk after copying all the files from it type:

 
umount /dev/hdj1

(Yes, it is umount, not unmount)

Once the data is off of the old NTFS/FAT drive and copied to an unraid data drive, and the old drive is then unmounted, you can then use the devices web-management page to asssign the old drive to a slot in the unraid array. (you must stop the array to assign it) It will then be cleared and formatted and made available as part of the unRaid array.

Now, just to let you know... I've never done this on my array, but I see no reason why it should not work. use of the -r option to the mount command will mount the drive as read-only so you should be safe... only way to mess up would be to assign the old drive to unRaid and clear/reformat it before you got your data copied from it.