====== HOWTO Mount an External USB Disc ====== The DNS-323 does not support external discs, but a small //hack// allows you to use them on the unit anyway. Before you even try this, you need to have [[telnet]] access to your device. Note: If you're a linux newbie and the steps below are too difficult for you, there is more background information and a set of "steps for dummies" to connect external USB drives to the DNS-323 at [[http://dns323.kood.org/forum/viewtopic.php?pid=3221#p3221|Attaching USB Storage to the DNS-323 for Linux Newbies & Dummies.]] ===== WARNING ===== **I just want to issue a small warning here as we currently don't know what happens when the unit is powered down. There is a risk that connected USB discs are not unmounted properly at shutdown or reboot. ** ===== Load USB Storage Module ===== The first thing you need to do is to add an extra module to your system. [[http://dns323.kood.org/forum/profile.php?id=173|Paul]] has been so kind that he has produced such a module for you to [[http://dev.skcserver.de/dns323/modules_v1.03/kernel/drivers/usb/storage/usb-storage.ko|download for v1.03]] (working for 1.04 too). [[http://dns323.kood.org/forum/t764-usb-storage.ko-module-without-debugging-enable.html|Here]] you can find a discussion about usb-storage module compiled without debugging enable. Download optimizing module [[http://www.domaigne.com/download/dns-323/|here]] (firmware >=1.03). Store that file somewhere on your disc, e.g. in the ../lnx_bin/.. directory of your unit. Next step is to [[telnet]] to the device and load the module to the kernel: # cd /mnt/HD_a2/lnx_bin # insmod usb-storage.ko Then plug your USB disc into the USB slot and watch your system log, i.e. issue command ''dmesg''. It'll look something like this: Initializing USB Mass Storage driver... scsi4 : SCSI emulation for USB Mass Storage devices Vendor: LEXAR Model: GEYSER JUMPDRIVE Rev: 1.00 Type: Direct-Access ANSI SCSI revision: 02 SCSI device sdc: 1001952 512-byte hdwr sectors (513 MB) sdc: assuming Write Enabled sdc: assuming drive cache: write through sdc: sdc1 Attached scsi removable disk sdc at scsi4, channel 0, id 0, lun 0 Attached scsi generic sg2 at scsi4, channel 0, id 0, lun 0, type 0 USB Mass Storage device found at 2 usbcore: registered new driver usb-storage USB Mass Storage support registered. Please note the 'sdc' above as it might differ when you insert your disc. Use //your// device. ===== Explicit Export===== Next step is to create a mount point for the disc and to mount it: mkdir /mnt/ext mount -t vfat /dev/sdc1 /mnt/ext Please note the ''-t vfat'' here as it is a [[wp>VFAT|FAT]] volume in this example. Example of mount for external drive with one ext2 partition: mkdir /mnt/usb1 mount -t ext2 /dev/sdc1 /mnt/usb1 If you need [[wp>UTF8|UTF8]] support for a FAT32 file system in order to handle an extended character set (greek, chinese, german umlauts, ...), add the -o utf8 option to your mount command: mkdir /mnt/usb1 mount -t vfat -o utf8 /dev/sdc1 /mnt/usb1 If you also want to share this disc to your other computers you'll have to make it visible through samba. Edit the ''/etc/samba/smb.conf'' file and add the following: [EXT_1] comment = External VFAT Disc path = /mnt/ext valid users = read only = no guest ok = yes After this, restart the samba deamon using the command: # smb restart. ===== Implicit Export ===== If you don't want to go all the trouble editing samba files and restarting samba server you can instead create the mount point on an already exported disc: # mkdir /mnt/HD_a2/usb_disc # mount -t vfat /dev/sdc1 /mnt/HD_a2/usb_disc If you don't want the whole drive in one share, you can add symbolic links to existing shares, that will take on their users and permissions. Mount the disc to a point that exists, but outside the shares, then add a link inside the share. In this example, there is a folder on the USB drive called "Public" and an already shared folder on the first hard drive called "Public/Share". There will be a new "folder" (the link) created and it will be visible at "Public/Share/USB_Drive". # mount -t ext2 /dev/sdc1 /mnt/usb1 # cd /mnt/HD_a2/Public/Share # ln -s /mnt/usb1/Public USB_Drive You might need to chmod 777 or 755 your usb drive. You only need to make the links once. Then you can mount and umount your drive after that without changing anything. ===== Unmount ===== If you want to safely unplug your USB harddrive, you can use the umount command (**not** unmount). It's probably a good idea to do this if you are turning off or restarting your DNS-323. Example: umount /dev/sdc1 ===== Fun_plugging ===== And; you can of course do all this in your [[fun_plug]]. The following is the contents of of a [[fun_plug]] which resides on a machine which has two external USB discs and a printer connected through a USB hub: # # fun_plug for sharing two external USB Discs # DIR=/mnt/HD_a2 if [ ! -d lnx_bin ] then exit 0 fi if [ -f $DIR/lnx_bin/usb-storage.ko ] then insmod $DIR/lnx_bin/usb-storage.ko # wait a few seconds for the usb drive to be detected sleep 15 dmesg > $DIR/lnx_bin/logs/dmesg.out mkdir $DIR/usb_120 mkdir $DIR/usb_240 mount /dev/sdc1 $DIR/usb_120 mount /dev/sdd1 $DIR/usb_240 fi ===== Proposed Functionality ===== An obvious (and very useful) extension to the work you guys have put into USB functionality would be a plugin which automatically copies the entire contents of a USB stick to a directory on the drive. It would be pretty simple to code, I imagine Another useful extension would be automatic backup to a usb disk which afterwards can be carried off site. Is it technically possible to use the USB to connect DNS-323 to PC, as an external USB hard drive? The reason to do this would be to get better throughput when playing HD movies in Windows. I understand DNS-323 is using EXT2 which is supported by Windows using ext2fsd (http://ext2fsd.sourceforge.net) or ext2ifs (http://www.fs-driver.org). => I think that would require the USB port to be working in host mode which I don't believe is electrically possible in this case. ===== Partitioning and formating of external hard disk drives ===== The external drives need to be partitioned and the partition which should be mounted needs to be formated with one of the possible file systems, i.e. EXT2, FAT16, FAT32 or NTFS. If your drive isn't already partitioned or formated as needed there are the following possibilities to achieve this need: 1. Connect the drive to a linux pc and partition and format it there, using i.e tools like GParted. 2. Partitioning and formating can even be done with the DNS323 itself in a telnet session using the command line tool fdisk. **Please be very careful with this tool, because if used wrongly you could lose all your data.** You need an up to date version of the fdisk tool; otherwise, you may get a segmentation fault. You can get a working version from this post in the forum: "[[http://dns323.kood.org/forum/t3375-ffp%27s-fdisk-dies-with-segfault.html|ffp's fdisk dies with segfault]]" fdisk /dev/sdX # with X standing for "b" or "c" (one or two internal disks) Take a look at your internal disks /dev/sda or /dev/sdb as a reference and exit with "q". You may want to create a linux partition (partition type 83) similar to the internal drives. If you want to format a partition with EXT2 filesystem, use mke2fs /dev/sdXn # with X standing for "b" or "c" and n being a number 1,2,... After partitioning and formating you can check you partition with e2fsck /dev/sdXn Finally, try to mount the newly created partition.