NSLU2-Linux
view · edit · print · history

Foreword

I recently had success in building NTFS-3G and the accompanying FUSE kernel module for Unslung 6.10. The NTFS-3G driver so far appears to provide better performance, and is well tested in the Linux community. It also doesn't suffer from the Linksys proprietary driver bug where the driver locks up under heavy load.

As of right now, I haven't had the time to learn how to create an optware package, but I thought I would provide some guidance on how to compile the software yourself. If someone has a place for me to upload the software - particularly the FUSE driver which is tough to build - then I'd be happy to share! Hopefully one day I will have time to create an optware package for easy installation, as I think a lot of people would love to use NTFS-3G.

What follows is my best recollection of what I did to set up the proper build environment, and what I did to build the software. There may be some missing details, so if you run into any issues, please speak up. I may also not be doing this in the most efficient way, so if there are extra steps or an easier way to do a step, please share.

Since Unslung runs a 2.4 kernel, we have to use FUSE v2.5.3 - Try to use the latest version of NTFS-3G which is v1.2812 as of this writing.

Okay - to the good stuff!

Setting up a kernel build environment to build the FUSE kernel module

We must first build a kernel module for FUSE. FUSE is a driver that allows filesystems in user space, and is used by the NTFS-3G software. I didn't have much luck getting the module to build properly by compiling natively on the NSLU2 - I would get two unresolved symbols when I tried to insmod it. So what you must do is set up a cross-compiler build environment on an external Linux workstation. I found Sun's VirtualBox a perfect solution for creating a quick and easy VirtualPC on my Windows workstation to install Linux on. I used Ubuntu v8.04 as my Linux distro.

  • Set up a VirtualPC with VirtualBox (http://www.virtualbox.org/) or get an unused workstation to install Linux on.
  • Install Ubuntu v8.04 or whatever Linux distro you like (remember some steps may be different if you use a different distro)
  • Log into Ubuntu. Since this is just a build machine, I tend to log in as root.
  • Make a /usr/local/src directory
    mkdir /usr/local/src
    
  • Make a directory to hold the unslung code and then cd to it
     mkdir /usr/local/src/unslung
     cd /usr/local/src/unslung
    
  • Get the master Makefile
    wget --cache=off http://www.nslu2-linux.org/Makefile
    
  • Install the necessary support packages. Note that this step will try to install a long list of software. Some of the packages may not necessarily have the same names anymore so you may run into errors. Do your best to install as much of the software as you can. Try to find alternatives for the missing packages.
    make setup-host-ubuntu
    
  • Download fuse-2.5.3.tar.gz and untar it to /usr/local/src
  • cd to fuse-2.5.3/kernel
    cd /usr/local/src/fuse-2.5.3/kernel
    
  • run configure
./configure --with-kernel= /usr/local/src/unslung/unslung/tmp/work/unslung-kernel-2.4.22.l2.3r63-r22/linux-2.4.22/ --prefix=/opt
  • edit the Makefile. Use you favorite text editor and change the lines that read:
    CC = gcc
    LD = ld
    
to
CC = /usr/local/src/unslung/unslung/tmp/cross/bin/armeb-linux-gcc
LD = /usr/local/src/unslung/unslung/tmp/cross/bin/armeb-linux-ld
  • There is a bug in the dev.c file that must be addressed. Open the file in your favorite text editor, and at around line 546 make it read the following:
                 unsigned ncpy = min(*size, cs->len);
                 if (val) {
                         flush_cache_all();
                         if (cs->write)
    
  • make the kernel driver
    make
    
  • If all goes well, you will have fuse.o in the directory. Copy this file from the development machine to the /lib/modules/2.4.22-xfs/kernel/fs/fuse directory on your NSLU2.

Setting up a native build environment for NTFS-3G

I don't know if you can build the NTFS-3G user-tools on the Ubuntu machine (I assume you can, but I didn't try it), but you can build it right on your NSLU2 and use it in conjunction with the fuse.o kernel module to mount your NTFS drive.

  • First set up a native build environment
    ipkg install optware-devel
    
  • Download ntfs-3g-1.2812.tgz and untar it to /usr/local/src
  • configure, make, and install
    ./configure
    make
    make install
    

Usage

I like to do my custom startup stuff in /unslung/rc.local so open your favorite editor and add the following, changing /dev/sdb1 to whatever drive you want to use

#!/bin/sh

/bin/umount /dev/sdb1
/sbin/insmod fuse
/bin/ntfs-3g /dev/sdb1 /share/hdd/data/HDD_1_1_1 -o rw,noatime

If you are creating your script from scratch, don't forget to make the script executable:

chmod a+x /unslung/rc.local

Reboot and this should mount your NTFS drive using the new NTFS-3G driver.

To verify, run "mount" and it should say something similar to:

/dev/sdb1 on /share/hdd/data/HDD_1_1_1 type fuse (rw,allow_other)

Troubleshooting

So far, I've had mixed results using the NTFS-3G driver. Occasionally the ntfs-3g user-space executable crashes or just locks up and the drive goes away (or locks any process that attempts to access it) until remounted. I've tried to narrow down the issue and this is what I have observed:

  1. It seems to happen more often when using AFP instead of SMB, but it happens with both
  2. Using the 2.6.0-PRE fuse driver doesn't seem to help, nor does the patch below
  3. Using the latest ntfs-3g code doesn't seem to help either
  4. If you are experiencing crashes, you may want to plug your NTFS drive into a regular windows installation and do a disk check/repair on it

For the most part, I am giving up on getting it to be stable. The Unslung kernel is too old (2.4) to run the fuse driver reliably, so I am going to switch to another distro with a 2.6 kernel. I would suggest other Unslung users try this out and see if they get better results.

Update to fix crashing?

I think I have a patch that fixes the remaining instability issues. Apply the following patch to dev.c in the fuse source code before compiling:

--- dev.c.org   2006-05-03 17:12:39.000000000 +0200
+++ dev.c       2006-05-03 17:24:53.000000000 +0200
@@ -489,6 +489,7 @@
 static int fuse_copy_fill(struct fuse_copy_state *cs)
 {
        unsigned long offset;
+       struct vm_area_struct *vma;
        int err;

        unlock_request(cs->fc, cs->req);
@@ -502,13 +503,14 @@
        }
        down_read(&current->mm->mmap_sem);
        err = get_user_pages(current, current->mm, cs->addr, 1, cs->write, 0,
-                            &cs->pg, NULL);
+                            &cs->pg, &vma);
        up_read(&current->mm->mmap_sem);
        if (err < 0)
                return err;
        BUG_ON(err != 1);
        offset = cs->addr % PAGE_SIZE;
        cs->mapaddr = kmap_atomic(cs->pg, KM_USER0);
+       flush_cache_page(vma, cs->addr); //, page_to_pfn(cs->pg));
        cs->buf = cs->mapaddr + offset;
        cs->len = min(PAGE_SIZE - offset, cs->seglen);
        cs->seglen -= cs->len;

Update: This doesn't appear to do the trick for me... Anyone else have any luck?

Probably. Look at http://forum.openwrt.org/viewtopic.php?pid=75156

view · edit · print · history · Last edited by MoD.
Based on work by MoD and mkurtz.
Originally by mkurtz.
Page last modified on October 23, 2008, at 06:45 AM