A partner of ours asked me today to help him mount storage for backups on his linux backup server
His storage was located on a Windows 2008 Server, and so the question is how to get the Windows storage visible on our White Label Online Backup Server?
Turns out it’s not hard, but it is tricky!
- create the share in Windows, and give a specific user read and write rights to that share. Let’s call that user “windowsuser” and the password “windowspassword”.
- Next, we go into Ubuntu and create a mount point directory (where the windows share will appear in the Linux system). Let’s call that /jail/home1:
mkdir /jail/home1 - In the Ubuntu system, we may need to install the samba support if it’s not there already:
apt-get install smbfs - now we will edit the /etc/fstab file to add the line to mount the share. Let’s assume that the windows box has the ip 192.168.100.1, and the share is called “windowsshare”.
nano /etc/fstab - In the /etc/fstab, we’re going to insert the following line, then hit CTRL-X and follow the prompts to save the /etc/fstab file. :
//192.168.100.1/windowsshare /jail/home1 cifs credentials=/root/.smbcredentials,uid=nobody,gid=nogroup,iocharset=utf8,codepage=unicode,unicode 0 0(Note: The first bit is the address of the server that’s got the share on Windows, then where we want to mount it, followed by the “cifs:” which tells the system this is a samba mount, and a location for the credentials file (we will get to that in a second) then the user id (UID) and group id (GID), followed by some options for codepage support so characters are mapped the right way between the two machines, and then 0 0 to instruct the Ubuntu machine to skip dumps and filechecks at boot time — we are saying we don’t want any! Note that we chose the root user and “backupusers” group for the uid and gid, respectively. Since the files are in the group backupusers, this will allow users in the backupusers group (in our case the backup accounts are all in this group by default) to read and write files to these folders. Having root as the owner is not going to affect anything: since the whole mount will have one owner and group under linux, this is the best we can do. ) - Create a file with the username and password from Windows (see step 1), using the filename specified in the /etc/fstab line from step 5:
nano /root/.smbcredentials
and enter these two lines in the file and save changes:
username=windowsuser
password=windowspassword - secure the file so only root can get in and access it:
chown root:root /root/.smbcredentials; chmod 400 /root/.smbcredentials
If you need to get more background info on how to mount samba shares on Ubuntu, try these resources:
- The Ubuntu Wiki on mounting windows shares.
- a Suse reference for setting up smb shares from Windows in fstab
- Ubuntu Fstab Help
- Ubuntu SMB Reference
Label & Launch Your Backup Software in 5 Mins
Start your all-inclusive, no-risk, free trial today