Kategorie-Archiv: Howtos

Map network drive inside Windows Explorer on Windows Server 2003

How to map NFS network drive in Windows Server 2003

Network Problem Description

You have Windows Explorer open on your Windows Server 2003 R2, do a right click on “My Computer” and choose “Map Network Drive…”.

Map network drive inside Windows Explorer on Windows Server 2003

Windows Explorer on Windows Server 2003

Afterwards you choose a drive letter and the NFS share you would like to mount.

Map Network Drive Screen in Windows Explorer on Windows Server

Map Network Drive Screen in Windows Explorer

But finally when clicking “Finish” you receive following error: “The drive could not be mapped because no network was found”.

Network Error Message inside Windows Explorer on Windows Server 2003

Network Error Message inside Windows Explorer on Windows Server

Still you are able to ping your NFS server:

C:\Documents and Settings\ATCZ01admin>ping atbup002

Pinging atbup002.akron-group.local [192.168.8.29] with 32 bytes of data:

Reply from 192.168.8.29: bytes=32 time=1ms TTL=64
Reply from 192.168.8.29: bytes=32 time=1ms TTL=64
Reply from 192.168.8.29: bytes=32 time=1ms TTL=64
Reply from 192.168.8.29: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.8.29:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Check if NFS Client is installed

This indicates that there is actually no network problem but that you have simply no NFS support on your Windows server yet. So choose “Start --> Control Panel --> Add or Remove Programs”.

In the left menu bar click on “Add/Remove Windows Components”:

Add Windows Components via Add or Remove Programs Screen

Add NFS support via Add Windows Components Screen

Select “Other Network File and Print Services” and click on “Details…”:

Add Windows Components Screen on Windows Server 2003

Add Windows Components Screen

Now check if “Microsoft Services for NFS” is selected. Otherwise do so and press “Details…” again:

Add Microsoft Services for NFS Windows Components

Add Microsoft Services for NFS on Windows Server 2003

Now select all the components you need. You should be good with the same I have chosen here, except you plan to also share files via NFS from your Windows server (as you will additionally need the server components for this).

Select needed NFS components from Windows Services for NFS

Select needed NFS components on Windows Server 2003

Afterwards click “OK --> OK --> Next”. If you have just chosen the components yet, the installation will start automatically. You will need the Windows Server System CD 2 for this!

Inject Windows Server System CD 2 when asked for needed Files

Inject Windows Server System CD 2 when asked

 

Browse for the following path: CMPNENTS\R2

Component Files on Windows Server System CD 2

Component Files on Windows Server System CD

This should allow the installation to proceed:

Installation Screen for Windows Services for NFS

Installation Screen for Windows Services for NFS on Windows Server 2003

UseReservedPorts Registry Hack

If you are able to map a NFS network drive now, be happy you lucky one! If the same error from above persists, go on trying to debug via cmd. Use the following command:

C:\Documents and Settings\ATCZ01admin>mount atbup002:/mnt/BackupVol *

If you receive this:

Network Error - 53

Type 'NET HELPMSG 53' for more information.

Go on with:

C:\Documents and Settings\ATCZ01admin>NET HELPMSG 53

The network path was not found.

Now check if you have the UseReservedPorts key set in your registry. Click “Start --> Run …” and type “regedit”:

Open Windows Registry via regedit

Open Windows Registry

Press [Enter] or click on "OK". In the Registry Editor navigate to “HKEY_LOCAL_MACHINE --> SOFTWARE --> Microsoft --> Client for NFS --> Current Version”:

Windows Client for NFS in Registry Editor

Windows Client for NFS

If the key is not there, just create it. Do a right click on “Default” and choose “New --> DWORD Value”:

Create UseReservedPorts DWORD Value Key

Create UseReservedPorts DWORD Key

Name it “UseReservedPorts”:

UseReservedPorts DWORD Value Registry Key on Windows Server

UseReservedPorts DWORD Value Registry Key

Now double click it and set “Value data” to 1:

Set DWORD Value Data

Set DWORD Value

Hopefully you should be able now to map the drive via Windows Explorer or mount it with the above command. If it is still not working, you can check if there is a problem on the NFS host server:

C:\Documents and Settings\ATCZ01admin>showmount -e 192.168.8.29
Exports list on 192.168.8.29:
/mnt/BackupVol/sugar               192.168.8.0
/mnt/BackupVol/atsan000            192.168.8.0
/mnt/BackupVol/atrsp001            192.168.8.0
/mnt/BackupVol                     192.168.8.0

You can also try to restart the NFS service on your Windows server. Do not use the services.msc for this, it will show that it worked but actually it doesn’t! So type:

C:\Documents and Settings\ATCZ01admin>nfsadmin client stop
The service was stopped successfully.

C:\Documents and Settings\ATCZ01admin>nfsadmin client start

The service was started successfully.

Copying error

So finally I’m able to map my NFS network drive and access it. Creating folders, opening and deleting files works everything fine. But what I actually wanted to do is to copy a file from my Windows server onto my backup NAS.

But when trying to do so, I received the following error: “The process cannot access the file because another process has locked a portion of the file.”

Copying Error Message

Copying Error Message

Let me tell you it was so hard to find a solution for this it almost drove me nuts. It shouldn’t be a big deal if you really know how NFS works, but for me it was more luck than skills until I actually stumbled across the fix.

First I had to disconnect my drive again by doing a right click and choosing “Disconnect”:

Disconnect already mapped network drive

Disconnect mapped network drive

Afterwards I had to mount it again with the option nolock enabled:

C:\Documents and Settings\ATCZ01>mount atbup002:/mnt/BackupVol Z: -o nolock
Z: is now successfully connected to atbup002:/mnt/BackupVol

The command completed successfully.
Postfix package installation and configuration

How to configure Auto-Updates on Linux Ubuntu Servers

If you install Ubuntu you get asked if you want to install security updates automatically. This is a nice feature, but you can even configure your new setup to install all updates you want without intervention and letting you know via email.

When you select to install auto-updates, then you will have the correct package already. Otherwise you have to install it first:

sudo apt-get install unattended-upgrades
[sudo] password for atcz01admin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
unattended-upgrades is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

As you can see, I had it installed already. Now you can edit your configuration:

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

As mentioned in my last blog post, you can use any text editor you like, but for me nano is the easiest one. So check for the following part:

// Automatically upgrade packages from these (origin, archive) pairs
Unattended-Upgrade::Allowed-Origins {
        "Ubuntu lucid-security";
        "Ubuntu lucid-updates";
};

updates will most probably be commented out, so remove the // or # if you would like to install all current updates automatically. Now you can configure email notifications by editing the following part:

// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. The package 'mailx'
// must be installed or anything that provides /usr/bin/mail.
Unattended-Upgrade::Mail "c.zartl@***.com";

Just change it to your email address. To be able to send emails from your fresh Ubuntu install, you will need to install and configure Postfix first:

sudo apt-get install postfix

Postfix package installation and configuration
This configuration depends on how you want to send emails, if you have a running mail server already and so on, so I won't go into much detail here. If you do something wrong or forget a setting, just run:

sudo dpkg-reconfigure postfix

Still there is one general step left you should do: set the correct sender. First edit main.cf:

sudo nano /etc/postfix/main.cf

Simply add the following lines:

# Set correct sender
sender_canonical_maps = hash:/etc/postfix/sender_canonical

Now you have to create this senders file:

sudo nano /etc/postfix/sender_canonical

For me the file looks like this:

root sugar@***.com
atcz01admin sugar@***.com

First you provide the name of the user you want to set a sender email address. Then, seperated by a space, add the email address you want to use for this person.

Finally run the following command:

sudo postmap /etc/postfix/sender_canonical

And reload the Postfix configuration:

sudo /etc/init.d/postfix reload
 * Reloading Postfix configuration...

At last you will have to install mailutils:

sudo apt-get install mailutils

Now you can send a test mail if you like:

sudo nano testmail.txt

Type any text you like here, close the file, and send it:

mail -s "Test" c.zartl@***.com < testmail.txt

Finally go back to the configuration file:

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

You can also configure to auto-remove old dependencies:

// Do automatic removal of new unused dependencies after the upgrade
// (equivalent to apt-get autoremove)
Unattended-Upgrade::Remove-Unused-Dependencies "true";

At last set the update schedule:

sudo nano /etc/apt/apt.conf.d/10periodic

Here is my config:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

How to access Microsoft Windows Shares from Linux Ubuntu

First of all create a folder where you want to mount the shared Windows directory to:

sudo mkdir -p /mnt/win
[sudo] password for atcz01admin:

Type in your password when asked to do so. Now you will need to install smbfs to be able to access the shared folder:

sudo apt-get install smbfs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  keyutils libtalloc2 libwbclient0 samba-common samba-common-bin
Suggested packages:
  smbclient
The following NEW packages will be installed:
  keyutils libtalloc2 libwbclient0 samba-common samba-common-bin smbfs
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,831kB of archives.
After this operation, 21.3MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://at.archive.ubuntu.com/ubuntu/ lucid/main keyutils 1.2-12 [28.2kB]
Get:2 http://at.archive.ubuntu.com/ubuntu/ lucid/main libtalloc2 2.0.1-1 [20.7kB]
[...]
Setting up smbfs (2:3.4.7~dfsg-1ubuntu3.8) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Just type Y to confirm the installation of the new packages. Afterwards you can instantly mount the share:

sudo mount -t smbfs -o username=ATCZ01admin,password=*** //atser003/c$/Buffer /mnt/win

Therefore you will need a Windows user who has access rights to this folder and the Uniform Naming Convention (UNC network) path. This will be exactly the same as inside the Windows network, except that the backslashes (\) have to be changed to slashes (/) for Linux. Finally you can navigate to the mounted folder and access its content:

cd /mnt/win

ls –l
total 5060240
-rwxr-xr-x 1 root root  100010496 2010-12-13 16:12 20101213_Ebanking_Backup
drwxr-xr-x 1 root root          0 2007-08-27 13:02 Adobe
-rwxr-xr-x 1 root root    4447744 2007-06-06 09:42 apache_2.2.4-win32-x86-no_ssl.msi
[...]

You will take over the access rights of the Windows user you have provided within the mount command.