Reading and Writing on a NTFS USB Drive attached on a Citrix Xenserver 6.2

Sometimes you need to backup your VMs on a USB drive to easily carry them away or because there is not enough space on your NFS/CIFS storage. So the question is, how to mount an external NTFS USB drive on Xenserver with read/write permissions.

First of all ssh to your xenserver and type in the fdisk -l command.

Fdisk command output

Fdisk command output

fdisk shows the disks that xenserver knows about. Notice that the device name of the usb drive is /dev/sdc and its first partition is /dev/sdc1. If you try to mount the device, for example let’s create a usb directory and mount the drive on it:

mkdir /mnt/usb

mount -t ntfs /dev/sdc1 /mnt/usb

The problem is that xenserver supports only read access on NTFS formatted drives. So you may read anything or restore VMs under the /mnt/usb directory, but you cannot write any file including your backups. Let’s try to import a backup file.

xe vm-import filename='/mnt/usb/myBackupFile.xva'

If your drive is ext3 formatted, you will be able to mount it in read/write mode, but it will be difficult to mount it on a windows machine. We need to install to xenserver the appropriate  NTFS-3G driver to be able to have write permission as well. Ok, let’s first unmount to USB drive.

umount /mnt/usb

The following is a summary of information from various pages regarding the installation of NTFS-3G drivers on xenserver and I successfully installed it on a xenserver 6.2.

First we need to download rpmforge package for CentOS 5. More info at this page.

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

Install DAG’s GPG key

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Verify the package

rpm -K rpmforge-release-0.5.2-2.el5.rf.i386.rpm

Install it

rpm -i rpmforge-release-0.5.2-2.el5.rf.i386.rpm

Disable it by changing the following flag: enabled = 1 to enabled = 0 in the following file

vi /etc/yum.repos.d/rpmforge.repo

Install the library/driver

yum --enablerepo=rpmforge --enablerepo=base install fuse-sshfs

yum --enablerepo=rpmforge install ntfs-3g

Finally mount the USB drive

mount -t ntfs-3g /dev/sdc1 /mnt/usb

Now the usb drive is NTFS writeable. Don’t forget to unmount the drive by issuing the umount command

umount /mnt/usb

Advertisements

4 thoughts on “Reading and Writing on a NTFS USB Drive attached on a Citrix Xenserver 6.2

  1. Nice Post, is it possible to attach this usb (NTFS) to a VM running on XenServer without losing everything on the usb disk

    • Hi there, you can attach a ntfs USB drive on a vm without losing data. You need to add the attached drive on the vm via xenCenter.

  2. I want to know Nikos Chrissostomidis if i can mount my local usb port and CD driver to a vm whish is on an other xenserver but in the same LAN?

    • is it possible to create a new SR of type ISO, which is based on an NTFS mount point? (fuse \ 3g-ntfs)

      I’ve tried this command but got an error “SR_BACKEND_FAILURE_222″

      xe sr-create content-type=iso type=iso name-label=”Local ISOs” device-config:location=/repos

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s