Windows: Connect Network Drive and Copy Remote Files at Login

As the title suggests, this entry will show you how to connect a network map on your Windows machine, and copy folders from that network storage during login.

The situation: I have a NAS on the local network, but just in case, I would like to backup files from the NAS to my local desktop.

Prerequisites:

  • A network drive that can be mounted. For me, I have a local NAS that hosts a Media folder with Sambda (SMB) on address 192.168.1.100.
  • Windows 10 with a network map already created to this network drive. For this example, my network drive will be \\192.168.1.100\Media (N:).

———————————

Step 1. Write the batch script.
This batch script will mount the network drive and use robocopy to copy any new or updated time-stamped files to the C: drive destination.

@echo off
cd\
net use N: \\192.168.1.100\Media
robocopy N:\Pictures C:\Users\Dave\Pictures /FFT /Z /XA:SH /XD *. /W:5 /E

You can save the file where you like, but in my case, I use C:\Users\Dave\bin\picture_sync.bat.

I should also note that robocopy is a very robust tool, so it could be worth your time to investigate those options that work best for you.

Step 2. Wrap the batch script into a VBS script.

I wrote the following script in a file called picture_sync_wrapper.vbs:

Set shell = CreateObject(“WScript.Shell”)
shell.CurrentDirectory = “C:\Users\Dave\bin”
shell.Run “picture_sync.bat”,0,True

Q. Why write a VBS script?
A. To suppress the script when running during login. If you set the batch script to run, you will see a command window pop-up. While this window will close when finished, I like having it run to where I can forget about it. There are other options, like converting the batch script to an exe file, but I find this the easiest.

Step 3. Drop the VBS script in your user’s startup directory

In my case this will be C:\Users\Dave\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\. If you do not like all that digging down, you can also “Win Key + r ” and enter “shell:startup” and a new window will take you there. Drop your vbs script, in my case picture_sync_wrapper.vbs, here.

———————————

That’s it! Now when you login, any new files on the network drive will be copied over to your local disk. It is always nice to have a backup of a backup 🙂

DKMS: version magic $old_kernel mod_unload modversions should be $new_kernel

Upgrading from Ubuntu 16.10 to 17.04, I found that the wireless usb dongle built with DKMS to use the 8812au module no longer works. ‘dmesg’ shows the following error:

[  429.307856] 8812au: version magic '4.8.0-46-generic SMP mod_unload modversions ' should be '4.10.0-19-generic SMP mod_unload '

Checking my current DKMS status, I see two kernal versions for the 8812au:

dave@desktop:~$ dkms status
8812au, 4.2.2, 4.10.0-19-generic, x86_64: installed
8812au, 4.2.2, 4.8.0-46-generic, x86_64: installed

This should work, but it does not…The root cause looks to be that while the driver was upgraded for the new kernel, its code was not updated to reflect the new version number.

The fastest way I found to fix this was to nuke all versions of the 8812au module, and reinstall.

1. Delete all version of 8812au

dave@desktop:/usr/src/8812au-4.2.2$ sudo dkms remove 8812au/4.2.2 --all

2. Reinstall the module with DKMS

dave@desktop:/usr/src/8812au-4.2.2$ sudo dkms install -m 8812au -v 4.2.2

You should not be able to plugin your device and confirm it is now working:

Before:

[  201.755249] usb 3-3.3: SerialNumber: 123456
[  201.758747] 8812au: version magic '4.8.0-46-generic SMP mod_unload modversions ' should be '4.10.0-19-generic SMP mod_unload '

After:

[ 1032.071975] usb 3-3.3: USB disconnect, device number 11
[ 1033.575992] usb 3-3.3: new high-speed USB device number 12 using xhci_hcd
[ 1033.676357] usb 3-3.3: New USB device found, idVendor=0bda, idProduct=8812
[ 1033.676358] usb 3-3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1033.676359] usb 3-3.3: Product: 802.11n NIC
[ 1033.676360] usb 3-3.3: Manufacturer: Realtek
[ 1033.676360] usb 3-3.3: SerialNumber: 123456
[ 1033.761077] usbcore: registered new interface driver rtl8812au

Display Chinese and Japanese Characters in Team Fortress 2

Playing TF2 on Linux is great, but Japanese characters fail to display by default. I found the following font package allows Chinese and Japanese characters to be displayed.

On Ubuntu 16.10:

sudo apt install fonts-wqy-zenhei

Other distros or older Ubuntu versions may refer to this package as “wqy-zenhei”.

The description of fonts-wqy-zenhei states this is a Chinese font, but it works for Japanese characters (Hiragana and Katakana) as well.

Please note this still does not fix the Japanese input issue.

問題:新しいシステム パーティションを作成できなかったか、既存のシステム パーティションが見つかりませんでした。

気分転換で、Windows10をデスクトップにインストールしようとしたら、パーティションを選んでインストールするところで、次のエラーが発生しました:

新しいシステム パーティションを作成できなかったか、既存のシステム パーティションが見つかりませんでした。

私の場合、マザーボードに複数のディスクを接続して、その中にLinuxOSなど入っていました。そのせいで、Windowsインストーラが迷ってきたようです。解決方法、単に使わないディスクを切断することです。そうしましたら、インストールは無事に終わります。

ちなみに、インストール後で、切断されたディスクを再接続しても起動に影響ありません。

Postfix: Lost Connection After AUTH from Unknown

I thought I would give Windows 10 a try, and found that while any client can receive email from my mail server, sending mail via Submission (port 587) would always fail with the following error within mail.log.

Lost Connection After AUTH from Unknown

While I am not sure of the root cause (Something inside Windows), the fix requires enabling SMTPS on port 465.

1. Edit master.cf

$ sudo vi /etc/postfix/master.cf

2. Uncomment the following lines

#smtps     inet  n       -       n       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
↓
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes

3. Restart Postfix

$ sudo /etc/init.d/postfix restart

Even on Windows 10, sending email from a Windows client does not play well with Submission (port 587), so it is better to use SMTPS.

Mount remote file shares on a wireless network.

Working with my Raspberry Pi, one issue I always had was mounting my remote Samba server after the wireless was up. There are a couple ways this can be completed, but I find a simple script running after the wifi is up to be the easiest. This works for both Redhat and Debian based Linux distros. Here are the steps I used.

1. Determine the SSID

dave@dai-pi-2:~$ iwconfig | grep ESSID
lo no wireless extensions.

eth0 no wireless extensions.

wlan0 IEEE 802.11bgn ESSID:"Daves-Network"

So my SSID is “Daves-Network”, with the interface of “wlan0”.

2. Add the following mount script under /etc/network/if-up.d/050mountsmb. In this case, I used 050mountsmb, with the header number being the order in which the script is run compared to other scripts in this directory.

#!/bin/bash
if [ "$IFACE" = "wlan0" ]
then
    if iwconfig|grep -c "Daves-Network"
    then
        sleep 10s
        sudo mount -t cifs //192.168.1.100/smb_mount /mnt/backup -o username=dave,password="MySuperSecrectPassword",uid=1000,gid=1000
    fi
fi

Breaking down the mount command:

  • We confirm the interface is “wlan0”
  • If we can then confirm the SSID “Daves-Network”, we then perform the mount.
  • 192.168.1.100 is the Samba share IP
  • smb_mount will be the Samba share’s name.
  • /mnt/backup will be where the file share will be mounted.
  • The options will identify the user/password in order to access the share, and the user/group permissions for the share on the local device.
  • If the mount fails, try again in 10 seconds.

 

3. Secure the script

Since this script uses a password, you need to make sure only root has read/write access.

sudo chown root:root /etc/network/if-up.d/050mountsmb
sudo chmod 600 /etc/network/if-up.d/050mountsmb

That’s it! Now when the host is rebooted or the network reloaded, the share will be mounted after wifi is confirmed as up. If not, the script will sleep for 10 seconds and try again.

“The system is running in low-graphics mode” error upon Ubuntu Upgrade (Nvidia Graphics Card)

I found this issue today while upgrading my Ubuntu desktop from 14.10 to 15.04. The upgrade went by smoothly, until I rebooted and X failed to start with the dreaded error message: “The system is running in low-graphics mode”. I currently have a NVIDIA GeForce GTS 450, which is using the nvidia-304 driver. After digging around, I found that the x.org file had been delete(?), so I took the following steps to recover.

  1. Assuming you cannot login to GUI, choose either the console terminal from the presented options, or drop to the terminal with (control)+(alt)+(f1)
  2. Ensure the latest driver is installed. You will need to reboot if this is required.
    $ sudo apt-get install nvidia-current
  3. Install the tool “nvidia-settings”. This will create the x.org file.
    $ sudo apt-get install nvidia-settings
  4. Run the nvidia-settings command and restart.
    $ sudo nvidia-settings
    $ sudo shutdown -r
  5. Change permission of .Xauthority. This might not be required, but in my case, the .Xauthority in my user directory became owned by root, so this needed to corrected.
    $ sudo chmod $USER:USER ~/.Xauthority

Now back to playing some TF2 🙂

Linux上でrtl8812auチップのUSB-WIFIサポート

今回は日本語でブログを挑戦してみます。なぜかというと、今回共有したい情報は既に英語で書いているブログがありますが、日本でも役に立つと思います。

トピックはLinuxの上にrtl8812auチップのwifiサポートです。rtl8812auのUSBWifiは現在Linuxでサポートされていませんため、ドライバーはインストールする必要があります。ドライバーをインストールしましたら、日本で売っているGW-900Dシリーズの無線LAN子機でも使います。

http://www.planex.co.jp/products/gw-900d

PlanexでLinuxドライバーを提供していますが、簡単にインストールはできません。そのため、次のブログをお勧めします。

http://blog.danielscrivano.com/installing-rtl8812au-on-linux-for-wireless-dual-band-usb-adapters

英語で書いているので、日本語で簡単説明します。全てのコマンドはTerminalからです。

1. ビルドできるため、次のソフトをインストール

$ sudo apt-get install linux-headers-generic build-essential git

2. ドライバーのコードをダウンロードする

$ git clone https://github.com/scrivy/rtl8812AU_8821AU_linux.git

3. ドライバーをビルドする

$ cd rtl8812AU_8821AU_linux
$ make

4. ドライバーをインストール

$ sudo make install
$ sudo modprobe 8812au

上の手順はUbuntu14.10でテストして確認できました。以上になります。USBWifiを挿して、使いましょう!かなり簡単で、LinuxでPLANEX-GW-900Dでも使えます!

Tagged with: ,

Configuring Japanese Input in Gnome (Debian/Ubuntu)

I tested this on Gnome2 with Debian 7.0, but it should transfer over to other distros.

Step 0. (Optional) Setup Japanese Keyboard

From the Regional and Language Setup, click on the “+” and find your keyboard. In my case, it is a standard/boring Japanese 106 key keyboard.

Screenshot from 2014-10-12 23:25:27

Step 1. Install “ibus-anthy”

Open up a “terminal” and install “ibus-anthy”

$ sudo apt-get install ibus-anthy

Step 2. ibus setup

Again from the terminal, run “ibus-setup”.

$ ibus-setup

Within ibus-setup, you will want to go to the second tab “Input Method”. From the drop down, select “Anthy” and add. The result should look like the screenshot:

Screenshot from 2014-10-12 23:22:31

Step 3. Test

Open up a terminal, gedit, etc. and make sure it works.

Screenshot from 2014-10-12 23:33:08

Possible issues:

Issue 1. Cannot change between change and English

This will depend on the keyboard you have set and the keyboard shortcuts. To double-check this, open up the ibus setup.

$ ibus-setup

Under the first tab “general”, you should see “keyboard shortcuts”, “enable or disable”. In my case, I can flip between Japanese and English with either “Control+Space” or “Zenkaku_Hankaku”.

Issue 2. Ibus is not starting on boot

Ibus should start automatically, but I have seen cases where ibus remains off. Two ways you can handle this (there are many more).

Solution 1.  im-config

You can set the system to use ibus though the im-config. Just get im-config running and select ibus:

$ im-config

Screenshot from 2014-10-12 23:40:00

Solution 2. Startup Application

You can also create a startup item to get the ibus-daemon running.

Screenshot from 2014-10-12 23:43:46

日本語でコンピューター生活を盛り上げましょう!!

Working with ownCloud on Ubuntu

For the past couple of months, I have been working with ownCloud . For those who do not know, ownCloud is a program that you can run on top of a web server to create your own cloud.  For anyone who is running their own website, this package is a must.

This post is not how to get your personal cloud started, but more of a list of items I have found while working with this software. For now, this is a work in progress.

  1. Adding further directories to sync with ownCloud
    I am working on Ubuntu 14.04 at the moment, but I hope this is similar for all platforms. This assumes you have the ownCloud client installed on your computer.

    $ sudo apt-get install owncloud-client
    

    All your ownCloud local settings will be found in the following path:

    /home/$USER/.local/share/data/ownCloud
    

    By default, it will sync all files placed in /home/$USER/ownCloud. This is set by the file /home/$USER/.local/share/data/ownCloud/folders/ownCloud. So say you want to have another path on your current system automatically sync to your ownCloud. Just create a new file in /home/$USER/.local/share/data/ownCloud/folders, or edit the current file. Using pictures as an example, I added the following:

    [Pictures]
    localPath=/home/$USER/Pictures
    targetPath=/photos
    backend=owncloud
    connection=ownCloud

    Now my picture path is syncing to /photos on my ownCloud!

Top