Mounting an external USB drive having an existing NTFS file system in READ/WRITE mode to transport files from/to unRaid server

From unRAID
Jump to: navigation, search

It is very easy to add and remove an external USB drive to be visible in user-shares.

VERY IMPORTANT... This procedure to mount an NTFS drive to be visible through user-shares DOES NOT PROTECT THE CONTENTS OF THE NTFS DRIVE with your parity drive. The NTFS drive is not used for parity, nor is it part of the unRAID array protected by the parity drive. If you want the files to be protected, copy the files to one of your array data drives for editing, and then back to the USB drive when done, for transport once the USB drive is unplugged.

With that warning out of the way. Here is how I did it, without even rebooting the unRAID server, using an external USB enclosure on my array...

I have an external USB enclosure with a hard disk that has an NTFS file system. I use it for backups of some PCs, but let's say that is the data I want to move back and forth from home to work. We can actually use any file system that unRAID understands, but FAT and FAT32 have file size limitations, and ReiserFS does not to my knowledge have a read/write driver available for windows. That leaves NTFS. So... Get yourself an external USB enclosure, add a hard disk, and format it as NTFS.

In the past, Linux had partial support of NTFS file-systems. In fact, unRAID comes with the ntfs loadable module that can read an NTFS file system, unfortunately, it is not able to properly write to NTFS file systems. A read-only-capable drive is not too much help in this case, where I want to be able to move data to and from work, so we will NOT use the built-in module Tom supplied. (Note to Tom... might want to include the new ntfs-3g module in an upcoming release... hint-hint ... please)


NTFS-3G

Instead, we can use the newer NTFS-3G driver that has full NTFS capability and has been stable since February 2007.

You can read about it here: http://www.ntfs-3g.org/

You can download the ntfs-3g package here: http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/a/ntfs-3g-2010.3.6-i486-1.txz

The package name you will download using the link above is: ntfs-3g-2010.3.6-i486-1.txz

You may be able to download a newer version, since the ntfs-3g module is still being improved. If you download a newer file, use the appropriate file name in the following command examples. Just be aware that the specific version in slackware-current changes as newer versions of Slackware are released. http://slackware.cs.utah.edu/pub/slackware/slackware-current/slackware/a/

Older Versions of unRAID

If you are running an older version of unRAID, a .txz file must first be converted into a .tgz file. To do that, you will need to download a new compression utility xz

A link to download xz is here: http://slackware.cs.utah.edu/pub/slackware/slackware-13.0/slackware/a/xz-4.999.8beta-i486-1.tgz

Once you have the xz-4.999.8beta-i486-1.tgz file, you must install it by typing

installpkg xz-4.999.8beta-i486-1.tgz

To convert the downloaded ntfs-3g-2009.3.8-i486-1.txz file to a .tgz file use the following command:

xz -dc ntfs-3g-2010.3.6-i486-1.txz | gzip -c > ntfs-3g-2010.3.6-i486-1.tgz

Newer Versions of unRAID

As of unRAID v5.0-b14, you can install ntfs-3g via UnMENU packages. That's the easiest way to get read/write access to NTFS USB hard drives.

On newer versions of unRAID, you will not need to perform the steps to convert a .txz file into a .tgz file. Additionally the "xz" program is now part of unRAID, so there is no need to download or install it.

Installing the ntfs-3g driver

I made a folder on my flash drive for packages, downloaded the ntfs-3g package, and put it there. As an example, version 2010.3.6 is used, so you must replace it with the actual package name you download.

To create a folder for downloaded packages type:

mkdir -p /boot/packages

You can download the package from windows by clicking on the link above, or from the Linux command line after logging in as "root" To download from the Linux command line type:

wget -O /boot/packages/ntfs-3g-2010.3.6-i486-1.txz http://slackware.cs.utah.edu/pub/slackware/slackware-13.1/slackware/a/ntfs-3g-2010.3.6-i486-1.txz

To see if the package was successfully downloaded type

ls -l /boot/packages/ntfs-3g-2010.3.6-i486-1.txz

It will look something like this:

root@Tower:/~# ls -l /boot/packages/ntfs-3g-2010.3.6-i486-1.txz
total 224
-rwxrwxrwx 1 root root 259392 May 27  2010 /boot/packages/ntfs-3g-2010.3.6-i486-1.txz

You must then install the ntfs-3g package on your unRAID box. The command to do that is here:

installpkg /boot/packages/ntfs-3g-2010.3.6-i486-1.txz

You could add a line to the end of your "go" script to do this install every time you reboot.

Once the package is installed, you must make a mount point (an empty directory) to mount the new drive. since I already had a user-share folder named "data" in my user-share file-system I made my mount point there. You can name the empty directory anything you want, I used "usb" (you only need to do this once)

mkdir /mnt/user/data/usb

I made my mount point in an existing user share so I would not have to define a new user-share for the data on my USB drive. I could have made my mount point nearly anywhere and created a new "share" under Samba. Instructions on how to do that will be added later.

Next step is to plug in the drive into a spare USB port on your unRAID server (do not unplug your flash drive), and mount the NTFS file system resident on the USB hard-disk on the mount point. Now, on my all IDE array, the USB hard-disk appears as /dev/sdb and /dev/sdb1 You will need to find the appropriate device on your system. If you have a mix of SATA and IDE drives, or only SATA drives, the USB drive will most likely get the next /dev/sd? assignment.

If you type the following command before you plug in your USB drive, and after, you should be able to find the added drive partitions.

cat /proc/partitions

My results are here, the new USB drive is detected as type 8 (scsi) and assigned sdb and sdb1 ...

root@Tower:~# cat partitions
major minor  #blocks  name

   8     0    1000944 sda
   8     1    1000912 sda1
   3     0  488386584 hda
   3     1  488386552 hda1
   3    64  488386584 hdb
   3    65  488386552 hdb1
  22     0  245117376 hdc
  22     1  245117344 hdc1
  22    64  245117376 hdd
  22    65  245117344 hdd1
  33     0  390711384 hde
  33     1  390711352 hde1
  33    64  390711384 hdf
  33    65  390711352 hdf1
  34     0  390711384 hdg
  34     1  390711352 hdg1
  34    64  488386584 hdh
  34    65  488386552 hdh1
  56     0  488386584 hdi
  56     1  488386552 hdi1
   9     1  488386552 md1
   9     2  245117344 md2
   9     3  245117344 md3
   9     4  390711352 md4
   9     5  390711352 md5
   9     6  390711352 md6
   9     7  488386552 md7
   9     8  488386552 md8
   8    16  245117376 sdb
   8    17  245111706 sdb1

Now, sdb represents the entire raw drive... most of you will not want it, as it does not contain a file-system, but instead you will want the first partition, it will be the NTFS partition and it will be the one with the "1" at the end of its name. In my case, sdb1

If you try to use the wrong partition, or use the base drive name instead of the partition name, the mount -t ntfs-3g command will fail, as it will not find an NTFS file-system. In the rare case where your USB disk has more than one partition, it will also be listed. If sdb1 is the first partition, sdb2 would be the second.

Mount the drive as READ/WRITE

Now, all that is left to do is to mount the file system on the mount point.

To do that type:

mount -t ntfs-3g -o umask=111,dmask=000  /dev/sdb1 /mnt/user/data/usb/

For the above "mount" command you will want to use your device (/dev/sd?1) and your mount point directory. If you made your mount point in an existing /mnt/user/Movies user share, and created an empty folder named "work_drive" as the mount point, then the you would use /mnt/user/Movies/work_drive instead of /mnt/user/data/usb.

Mount the drive as READ ONLY

If you only want to read files, and not write to the USB drive, add the -r option as shown here:

mount -r -t ntfs-3g -o umask=111,dmask=000  /dev/sdb1 /mnt/user/data/usb/

Now... You can see if your NTFS file-system was mounted correctly... Type the following command, the contents of your NTFS drive should be visible.

ls -l /mnt/user/data/usb

The contents of the drive will also be visible from the LAN, in the user-share folder in which you created the mount point.

Safely Unmounting the USB DRIVE

When you are done with the NTFS files in the USB enclosure YOU MUST unmount the drive before you can unplug it, otherwise, a file may only be partially written to it.

To unmount the drive, first close all programs using it... including file-explorer on windows. then type:

sync
umount /dev/sdb1

Note: the command above is umount (without the first letter "n") not unmount.

This should get you to where you can move a drive from home to work and add it to be visible on your LAN through user-shares.

VERY IMPORTANT... This procedure to mount an NTFS drive to be visible through user-shares DOES NOT PROTECT THE CONTENTS OF THE NTFS DRIVE with your parity drive. The NTFS drive is not used for parity, nor is it part of the unRAID array protected by the parity drive. If you want the files to be protected, copy the files to one of your array data drives for editing, and then back to the USB drive when done, for transport once the USB drive is unplugged.

Have fun... Use a file that is not mission critical until you are comfortable with mounting and unmounting the drive.

Joe L. Notice... I did not need to reboot the unRAID server, I did not need to stop or re-start the array. Try that on MS-Windows where it seems that anything you do requires a reboot.