Monday, December 05, 2011

Setting up a SMB server on a HG556a router


Vodafone Huawei HG556a
I wanted to have my external 1TB harddisk available from every computer in the home LAN, but I didn’t want to have a computer running all day. To achieve this challenge I look into the specs of the Vodafone router I have (Huawei HG556a):

Apparently, if a harddisk is connected to the router, it is mounted and can be accessed via FTP or DLNA. However, although it’s not said in the router configuration page, it also runs a SAMBA server which allows MS Windows computers (and other os with smb support) to access the harddisk as a “shared folder”.

It seemed that it was exactly what I wanted, but it wasn’t. I tried to see the contents of the harddrive through a PC and I was able to do it, but when I attempted to copy a 700MB file to the drive an error message appeared saying that it wasn’t enough free space! There was obviously something wrong...
Even if I deleted files, it reported that there was only 29MB left, which made the huge harddrive useless.

Accessing the router through telnet (changing the default admin password is needed) I discoverd that the hardisk was being mount at /var/mnt/USBDrive_1/ and the content of /etc/samba/smb.conf was:
# cat /etc/samba/smb.conf[global]   workgroup = vodafone   netbios name = vodafone   server string = vodafone   security = share[Share]   path = /var/mnt/   comment = Share files   browseable = yes   public = yes   writable = yes   guest ok = yes
With these settings, when accessing through SAMBA it was reported the free space in the router (/var/mnt/), instead of the harddisk.
Changing the path to the real mount-point of the harddisk (/var/mnt/USBDrive_1/) I got ride of that “29MB left” error message, allowing me to copy bigger files.

To modify the smb.conf file I had to copy it to the harddrive, edit it in my laptop and then overwrite the original file, because the small linux installed in the router doesn’t have vi or nano to edit text files. Of course, you need to restart the smbd daemon and repeat these steps every time the adsl router is restarted.

I also improved a bit the data rate killing the snmp and ftp service. However, it is still not very good (<3MBps), but it seems to be a global problem of hg556a. So, if anybody knows how to make this fix permanent or improve the datarate, contact me!

17 comments:

  1. HI been looking for a fix to this for a while and this is the closest that I have come across (kudos to you!) I have yet to repeat your findings as I do not know how to restart the smbd daemon - wondering if you can please have a walk through of the commands that you have used to get this far please? - thanks for the good work - there are alot of people wondering about this...

    ReplyDelete
  2. To modify the smb.conf file, I just moved it to the harddrive:
    mv /etc/samba/smb.conf /var/mnt/USBDrive_1/
    Then opened it in my PC, changed it and copied it again:
    mv /var/mnt/USBDrive_1/smb.conf /etc/samba/

    To restart the service, I just killed it and started it again, because I couldn't find a "cleaner" way to do it:
    killall smbd
    or ps -e, and then kill smbd's id.
    To start it again:
    /bin/smbd -D

    Maybe using the "-s" option, you could use an external configuration file. This way, you wouldn't have to edit the conf file each time the router is rebooted.
    However I haven't tried it! "/bin/smbd -D -s /var/mnt/USBDrive_1/smb.conf"

    Please, if you find an easier solution, tell me!

    ReplyDelete
    Replies
    1. Hola Miguel,

      Estoy en un caso parecido, con las fuentes del HG556 para cambiarle el Twonky y si pudiese la versión del Samba.

      Al leer tu entrada, me ha surgido la curiosidad: ¿Cómo haces para poder machacar un archivo de sólo escritura? Te lo comento, porque he intentado habilitar la configuración web de Twonky que se hace desde el directorio /sbin/vp/ y me devuelve error de escritura.

      Delete
  3. hi miguel! i was following your solution to edit smb.conf but i cant seem to get it to work on mine? what am i doing wrong? i did telnet #ip add port 23... listd all the commands no command such as u noted. here is VF forum where i posted stuffs or commands that i can see http://forum.vodafone.co.nz/topic/9555-filenames-in-lower-case/ hope u can help

    ReplyDelete
    Replies
    1. The first command you have to type is "sh". Then you'll get a busybox with more commands ;)

      Delete
  4. many thanks Miguel! it did show the commands.. however i did kill and rerun the smbd service but the filenames didnt seem to work. same thing with the harddrive capacity, it didnt update. do i need to reboot the router? here is what i got now... can i also change the workgroup to my homegroup HOME so its in my home workgroup?

    [global]
    workgroup = vodafone
    netbios name = vodafone
    server string = vodafone


    security = share
    [Share]
    path = /var/mnt/USBDisk_1/
    comment = Share files


    browseable = yes
    public = yes
    writable = yes
    guest ok = yes
    case sensitive =

    yes preserve case = yes short preserve case = yes

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Great stuff for this fix Miguel! To add on my comment above, your trick worked now where I get to change the path so I see the actual volume of the harddrive. however, its only seing 4gigs instead of 40gigs worth of free space. I attached a 2.5" external drive with 160GB capacity. Updating with the letter case, got it working. the spacing has to do with it. i rewrite it as my comment above and corrected the cases, moved them to another line so each code has its own row. all sweet now! just the harddrive capacity still not showing right... unless there is a limitation?

    ReplyDelete
    Replies
    1. There's a limit of 4GB in old implementations of SMB, so you won't be able to copy bigger files.
      Nevertheless, it doesn't affect the quantity of information you can store, I mean:
      In your 160GB HDD you would be able to copy 40 files of 4GB each (but not bigger). The "free space" doesn't decrease with each copy. Try it and you'll see what I mean!
      So, if you are not using big files, you won't have any problem!

      Thanks for the info about the letter case!
      And yes, you can change the workgroup name.

      Delete
  7. Hi, I have problems to access by samba to a hdd connected to the router, using "snow leopard", it works with "win xp" but with mac it asks me for user and password, and I can´t enter as guest or with a password. I don´t know if it´s needed to edit the smbpasswd and smbusers, and also I don´t know how to do this, my smb.conf is like this:

    [global]
    workgroup = workgroup netbios name = vodafone server string = vodafone
    security = share null passwords = yes [Share] path = /var/mnt/USBDisk_1/
    comment = Share files browseable = yes public = yes writable = yes
    guest ok = yes case sensitive = yes preserve case = yes short preserve case = yes
    usershare allow guests = yes guest only = yes only user = no username = none

    Many thanks, my mind is quite numb: sorry for my english and this things

    ReplyDelete
    Replies
    1. http://www.freeviewshop.co.nz/forum/index.php/topic,1505.html

      Remember to do that on your home folder.

      Delete
  8. Hi.
    Can I start DLNA service from telnet or add something to routers config files
    Thanks

    ReplyDelete
  9. Thanks for posting this guide very helpful. Also if you want to save transferring the smb.conf file it is possible to update it using sed.
    sed -i 's/\/var\/mnt\//\/var\/mnt\/USBDisk_1\//g' /etc/samba/smb.conf

    ReplyDelete
  10. Exactly, which login and password did you write? I tried admin, root, vodafone, toor with the default password, my new password, other new password, and with VF-EShg556 i found on internet

    Gracias

    ReplyDelete
  11. I changed the passwords using a known bug in the firmware. You just have to edit and follow these links:
    admin: http://192.168.0.1/password.cgi?sysPassword=newPass
    support: http://192.168.0.1/password.cgi?sptPassword=newPass
    vodafone: http://192.168.0.1/password.cgi?usrPassword=newPass

    ReplyDelete
  12. Thanks Miguel but they didn't work :( I tried other variationes of URL and read http://wiki.bandaancha.st/Huawei_HG556a_de_Vodafone. After follow the links I get an empty white page and telnet with new password is refuse. Perhaps I need to do a bruteforce guess/attack.

    Thanks.

    ReplyDelete
  13. Hi Miguel there is a big limit inside samba version of hg556a, file bigger than 2gb are not showed perhaps because it's a very old version. Do you know if is possible to find samba 3 compiled for this router? The new firmware version b085 seems to have this issue resolved but vodafone ha choosen to send it directly to their routers and not publish it.

    ReplyDelete