How to set Hostname?

With the default settings my Pis do not appear in the Windows Network connections, which is itself a pain. Furthermore the allocated IP address can vary according to the switch on order used, which makes using SSH connections awkward. With Raspbian the “” file used to set up Samba shares corrects this. I would therefore like to allocate a name to my OSMC Pi 2, but can’t see how to do this - running “sudo hostname XXX” via SSH and rebooting does not have the desired effect.


Sounds like you want a Samba server.

apt-get install smb-app-osmc

would take care of that.

Changing hostname can be done by editing /etc/hostname and /etc/hosts


@sam_nazarko why I get

Mar 31 20:13:33 osmc systemd-hostnamed[347]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable.

in sudo journalctl?

if samba is installed, edit to etc/samba/smb.conf and add the lines “server string = hostname” and “netbios name = hostname” (where hostname = the name you want to use) and then edit the etc/hostname file to the name you want. Then restart and all should be good. (I have been using this method since the alpha of raspbmc and works fine)

what about /etc/smb.conf ?
I have both. What’s the diff between this and /etc/samba/smb.conf ?

I am not sure about the one in /etc. I always just edited the one in /etc/samba/ you could just make them both match.

I have read a bunch about this samba / hostname Device name “issue”… will having a rbp1 and a rbp2 on the same LAN mess up the way that samba shares are added? or just the samba service on the pi’s?

Getting a second TV and got my old pi1 ready today…i set a static IP in OSMC settings and don’t foresee a problem… can set up sources by IP right? (none of my shares are attached to a pi/pi2) and i have Kodi on Android, Win7, OSX on the same LAN, they don’t have samba issues… If i need to xfer files to a pi it would be wallpaper maybe and i could use FTP. Well I suppose i’ll find out soon. Can I use a crossover cable from a laptop to a pi/pi2 if I mess them up???

Any advice would help.

Thanks, all.


It helps avoid confusion to have these Pi installations with different hostnames, and also have the samba set to use different bios names - it doesn’t matter here whether they are Pi1 or Pi2.
You can transfer files as a network with a crossover cable connecting (possibly with a straight cable, as most devices current-sense to get things right) - but you do need to get the IPs compatible (on same ‘network’) and be prepared to sort out routing problems.

[quote=“goober, post:7, topic:1018”]
can set up sources by IP right?
[/quote] - if you mean name IP addresses in sources, yes you can, but you’ll need to know how to quote smb,nfs or whatever for these sources.

Kind Sir,

I understand what you are saying. When installing workstations in a DC environment every PC needs a unique name, and the same is true for a small LAN sharing a workgroup. However, I plan to have MY LAN using “WORKGROUP” on a typical 192.168.1.n network, and establishing an “off-site” (remote office) that will have a different workgroup name, as well as be on a 192.168.2.n schema. So all requests for SMB shares at the main site will route out the VPN to the 192.168.1.n network. I have done this using “sonicwalls” (Firewall/Router/VPN devices, now owned by Dell) for doctor’s offices that have multiple locations and need access to the “1” network (where the server/database is located.
So (on this much smaller scale), as long as the RBPi2 on the remote site is in a different workgroup and, of course, has a route from it’s remote 192.168.2.n to the server’s 192.168.1.n network (where all the media backups are housed) then both workgroups (named for example workgroup1 and remote1) will show up under video, files, SMB, and then there will be two workgroups to choose from, and the simple routing would look for (i think as I do not have the GUI in front of me) and when it reaches the remote site, it will look for a node named OSMC. Since it’s on a different subnet and over a VPN i don’t see a problem.

If i missed something please let me know. Like SSH, as long as you don’t type osmc@osmc and just use the osmc@ipaddress i don’t foresee a problem. A route will tell a request from the “2” network looking for a node on the “1” network to take the VPN tunnel. Both sites will use the VPN connection to share the storage drives, (and maybe printers) and all class C (“Public”) IP requests (websites that are off the 192.168.n.n schema, etc.) To use their local gateway.

If, say, a RBPi2 on the remote site (say it is tries to leave the LAN (for a destination on the “1” network, the VPN client will redirect it to the tunnel, and the VPN device on the other side SHOULD tell it where to go. Depending on the speed between locations, I am thinking of changing the buffer settings. Bridge both site’s docsis3 modems so that the ASUS RT-AC3200’s can connect without a problem. PS The ASUS RT-AC3200 allows you to switch a LAN port into a dual WAN port for I suppose load balancing and such. Plus there’s CFW by Merlin for it. Sorry to sound like a salesman but I cannot wait to get this up and going.

Thanks, @dandnsmith for the refresher…

Any interest in this router heres a link…
and here’s “Merlin’s” homepage that will show screenshots and has links to forums and firmwares:

Again thanks I shall keep you posted on this work in progress, as I am SURE to mess it up somehow–but that’s half the fun :wink:

EDIT: one thing I overlooked after updating my LAN router’s FW was that when it came back up, no SMB shares could be found on any nodes, wireless OR wired. Turned out that the radio button on the router for “Force as master browser” had ben undone, and not wanting to wait to see if a discovery protocol would eventually find the shares, I re-enabled that radio button and every node saw the shares in seconds. Just in case that happens to anyone else, I just saved you a headache and 10-20 minutes. :stuck_out_tongue_winking_eye:

I’ll have to get back to your post when my head is a bit clearer, but a couple of quick thoughts occur:
a) the whole of the IP4 addressing and routing was founded on the stated assumption that 3 sets of addresses would be treated as local and should never be routed (192.168.x.x, 10.x.x.x,172.?). This might generate a few oddities for you. I’m not up-to-date on IP6 assumptions, nor have I checked them.
b)my experience says that any node can assert that it is a master browser for smb, but any Windows install tends to plough over anything set outside. The rough rule used to be that any later Windows could override any earlier, any linux would get overridden by Windows, and the latest booted Windows machine would get treated as the master browser. For some versions of Windows it was known how to change these rules - but I’m not current with that.