Category Archives: Debian

How to compile mt7801u for OSMC

Note: This may already be fixed with latest version of OSMC.
Note: My device was not detected in Raspberry Pi Model B (older model) because apparently, it can’t provide enough power to it. It does work with powered USB hub though.

I have a USB Network Hub (WiFi 360) from a Chinese manufacturer. It is detected as “Bus 001 Device 005: ID 148f:760b Ralink Technology, Corp.”. To get it working, I had to go through the following:

First, I sshed into the machine (you can do it with ssh command from *nix machines or Putty tool from Windows machine). The default credentials are osmc/osmc.

Then I installed usbutils to use lsusb.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get -y install usbutils

Then I used lsusb to confirm that the USB WiFi Dongle is connected properly. I also ran ifconfig to check if it is already detected.

Then I installed git, gcc, make and build-essential:

sudo apt-get install git gcc make build-essential -y

Then I installed kernel headers:

set -- $(cat /proc/cmdline) && for x in "$@"; do case "$x" in osmcdev=*) sudo apt-get update && sudo apt-get install -y "${x#osmcdev=}-headers-$(uname -r)"; ;; esac; done

And then kernel source (which is ~100M so might take some time depending on your internet connection):

set -- $(cat /proc/cmdline) && for x in "$@"; do case "$x" in osmcdev=*) sudo apt-get update && sudo apt-get install -y "${x#osmcdev=}-source-$(uname -r)"; ;; esac; done

Then I fetched the source for driver:

cd
git clone https://github.com/porjo/mt7601.git

Then I prepared kernel source for compilation:

cd /usr/src
set -- $(cat /proc/cmdline) && for x in "$@"; do case "$x" in osmcdev=*) sudo tar xjvf /usr/src/"${x#osmcdev=}-source-$(uname -r).tar.bz2"; ;; esac; done
set -- $(cat /proc/cmdline) && for x in "$@"; do case "$x" in osmcdev=*) cd /usr/src/"${x#osmcdev=}-source-$(uname -r)"; ;; esac; done
sudo make mrproper
set -- $(cat /proc/cmdline) && for x in "$@"; do case "$x" in osmcdev=*) sudo cp /boot/config-"$(uname -r)" .config; ;; esac; done
sudo cp .config .config.org
sudo make modules_prepare
set -- $(cat /proc/cmdline) && for x in "$@"; do case "$x" in osmcdev=*) sudo cp /usr/src/"${x#osmcdev=}-headers-$(uname -r)"/Module.symvers ./; ;; esac; done
set -- $(cat /proc/cmdline) && for x in "$@"; do case "$x" in osmcdev=*) sudo ln -s /usr/src/"${x#osmcdev=}-source-$(uname -r)"/ /lib/modules/"$(uname -r)"/build; ;; esac; done

Then I built the driver:

cd
cd mt7601/src
make

It took some time (around 20 minutes on a Raspberry Pi 1 B+) and a lot of warnings were shown but apparently they were safe to ignore.

Finally, I installed it:

sudo mkdir -p /etc/Wireless/RT2870STA
sudo cp RT2870STA.dat /etc/Wireless/RT2870STA
sudo cp os/linux/mt7601Usta.ko /lib/modules/"$(uname -r)"/kernel/drivers/net/wireless/

Then I rebooted:

sudo reboot; exit

After reboot, I reconnected ssh and I could see the new interface ra1 when running ifconfig:

ifconfig

If you update your system and if it again stops detecting the device, you should follow the same instructions again.

Sources:
https://github.com/Shareed2k/osmc_mt7601_driver
https://osmc.tv/help/wiki/kernel-sources

[HOWTO] Run apache server with www directory in a different server

This is an experiment in which I wanted to see if it is possible to run apache on one server and have www directory in a different server (physical or virtual). I don’t know the possible benefits of such a system or a scenario where this could be helpful, neither am I aware of different ways to achieve the same. But I tried it and am posting the results anyways. 😀

The Problem

I am assuming a hypothetical problem where a user wants to run apache server in one machine and have the www directory in a different system. Let’s call the machine with apache2 installed as Web Server (WS) and for the system with www directory, lets use the name File Server (FS).

The Plan

The plan is to mount the www directory of FS to a directory of WS with sshfs and configure apache in WS to use that sshfs directory.

Working Environment

I am using my Debian Testing system as FS and Ubuntu 10.10 Maverick Meerkat inside VirtualBox virtual machine (using Bridged connection) as WS which has apache installed. I have openssh server installed in FS and openssh client and sshfs installed in WS.

Plan Execution

Apache Configuration
First, lets login to WS and configure apache to use a directory in normal user’s home directory (/home/ws_username/www) by editing /etc/apache2/sites/available/default. The DocumentRoot is set to /home/ws_username/www and a Directory is set to /home/ws_username/www/ (no virtual hosts, however, using virtual hosts should not be much different either).
Stop apache server for now:

sudo service apache2 stop

Testing SSH connection from WS to FS
Now, connect from WS to FS using:

ssh fs_username@fs_ip_or_domain_name

and verify connection is OK. Add to known hosts (if connecting for the first time). Then type

exit

to disconnect.
Setting up SSH connection without password
If not already created, create a ssh key pair using the command in WS:

ssh-keygen

That should ask you where to store the rsa public key (it is stored by default in /home/ws_username/.ssh/id_rsa/ as /home/ws_username/.ssh/id_rsa/id_rsa.pub). Use a blank password. If you use a password, you may have to use ssh-agent for authentication later (not covered in this article). Now, transfer the pub key to FS using scp.

scp ~/.ssh/id_rsa/id_rsa.pub fs_username@fs_ip_or_domain_name:

Then, ssh to FS:

ssh fs_username@fs_ip_or_domain_name

Now, add the rsa keys copied from WS earlier to authorized_keys file in FS:

cat id_rsa.pub >>~/.ssh/authroized_keys
rm id_rsa.pub

Exit to disconnect and drop to WS shell.
Testing SSH connection from WS to FS without password
If you followed the instructions correctly, you will be able to connect to FS from WS without password when you use SSH.

ssh fs_username@fs_ip_or_domain_name

Exit to disconnect:

exit

Manually mount the www directory in FS to WS using sshfs
Now, test if sshfs is able to mount the directory from FS to WS. Let us assume the www directory is in /home/fs_username/webprojects and is properly readable/writable (as required) by fs_username.
First, allow the user to mount by adding the ws_username to fuse group by running the following command:

sudo gpasswd -a ws_username fuse

Mount the directory to /home/ws_username/www using sshfs:

sshfs -o idmap=ws_username fs_username@fs_ip_or_domain_name:/home/fs_username/webprojects  /home/ws_user/www

Confirm successful mounting by listing the contents:

ls /home/ws_username/www

Unmount when done testing:

fusermount -u /home/ws_username/www

Setup /etc/fstab to be able to mount and unmount using mount and unmount instead
Open up /etc/fstab and add the following line:

sshfs#fs_username@fs_ip_or_domain_name:/home/fs_username/webprojects /home/ws_username/www fuse fsname=sshfs#fs_username@fs_ip_or_domain_name:/home/fs_username/webprojects,users,allow_other,uid=1000,gid=104,comment=sshfs,exec,reconnect,transform_symlinks,BatchMode=yes,noauto 0 0

Don’t use uid and gid values as they appear above. Instead, get those values by running the following command in terminal:

id

Make sure to use the uid and gid (of fuse group) from the output of the above command. Save the file.
Then open up /etc/fuse.conf and add or uncomment the line:

user_allow_other

Try mounting and unmounting using mount and unmount

mount /home/ws_username/www
ls /home/ws_username/www
umount /home/ws_username/www

Setup auto-mount on connection (ifup) and auto-unmount on disconnect (ifdown)
Create a file /etc/network/if-up.d/mountsshfs with the following contents:

#!/bin/sh

## http://ubuntuforums.org/showthread.php?t=430312
## The script will attempt to mount any fstab entry with an option
## "...,comment=$SELECTED_STRING,..."
## Use this to select specific sshfs mounts rather than all of them.
SELECTED_STRING="sshfs"

# Not for loopback
[ "$IFACE" != "lo" ] || exit 0

## define a number of useful functions

## returns true if input contains nothing but the digits 0-9, false otherwise
## so realy, more like isa_positive_integer 
isa_number () {
    ! echo $1 | egrep -q '[^0-9]'
    return $?
}

## returns true if the given uid or username is that of the current user
am_i () {
	[ "$1" = "`id -u`" ] || [ "$1" = "`id -un`" ]
}

## takes a username or uid and finds it in /etc/passwd
## echoes the name and returns true on success
## echoes nothing and returns false on failure 
user_from_uid () {
    if isa_number "$1"
    then
		# look for the corresponding name in /etc/passwd
    	local IFS=":"
    	while read name x uid the_rest
    	do
        	if [ "$1" = "$uid" ]
			then 
				echo "$name"
				return 0
			fi
    	done 

Create another file /etc/network/if-down.d/umountsshfs with the following contents:

#!/bin/bash

# Not for loopback!
[ "$IFACE" != "lo" ] || exit 0

# comment this for testing
exec 1>/dev/null # squelch output for non-interactive

# umount all sshfs mounts
mounted=`grep 'fuse.sshfs\|sshfs#' /etc/mtab | awk '{ print $2 }'`
[ -n "$mounted" ] && { for mount in $mounted; do umount -l $mount; done; }

Make both files executable and owned by root:

sudo chmod 755 /etc/network/if-up.d/mountsshfs /etc/network/if-down.d/umountsshfs
sudo chown root:root /etc/network/if-up.d/mountsshfs /etc/network/if-down.d/umountsshfs

Test the working of scripts
Enter the commands (assuming the ethernet interface as eth0):

sudo ifdown eth0   #disconnect
sudo ifup eth0   #connect

Test if the directory is mounted:

ls /home/ws_user/www #should list files

Disconnect:

sudo ifdown eth0

Test if the directory is unmounted:

ls /home/ws_user/www #should not list files

Connect back:

sudo ifup eth0   #connect

You can also reboot the system to test if the directory properly mounts at startup.

Start Apache and Test

sudo service apache2 restart

Test using a web browser.

References

http://ubuntuforums.org/showthread.php?t=430312
https://bugs.launchpad.net/ubuntu/+source/sshfs-fuse/+bug/243298
http://linux.dsplabs.com.au/sshfs-read-connection-reset-by-peer-p73/
http://www.debian-administration.org/articles/152
https://help.ubuntu.com/community/SSHFS

[HOWTO] Bring back “Network”, “Services”, “Time and Date” and “Users and Groups” in Gnome Menu

If you have installed your system via netinstall or by selecting packages one by one, or if you somehow removed some gnome packages, you may be missing some menu items. I noticed that I did not have some entries in System>Administration menu, namely, “Network”, “Services”, “Time and Date” and “Users and Groups”. I tried to search for them in Synaptic and Apt-file but failed to locate the exact package. So, I did some hit and trial and found the package was “gnome-system-tools”. I just installed it via synaptic and the menu entries were back.

[HOWTO] Properly install VirtualBox 4 beta in Ubuntu/Debian/Linux Mint (and other Debian/Ubuntu derivatives)

I downloaded deb of VirtualBox beta 1 from the beta packages page of Oracle website and installed it. However, while launching Virtual Machines created with Oracle VirtualBox 3.x (closed source version), I got the following error:

Failed to open a session for the virtual machine [machine name].
A virtual device is configured in the VM settings but the device implementation is missing.
A possible reason for this error is a missing extension pack. Note that as of VirtualBox 4.0, certain features (for example USB 2.0 support and remote desktop) are only available from an ‘extension pack’ which must be downloaded and installed separately (VERR_PDM_DEVICE_NOT_FOUND).

Details:
Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
Console
Interface:
IConsole {515e8e8d-f932-4d8e-9f32-79a52aead882}

It was clear that it requires an extension pack. I went back to the download page and found an extension pack named “Oracle_VM_VirtualBox_Extension_Pack-4.0.0_BETA1-68572.vbox-extpack” (newer versions may be available now so name may be different) and downloaded it. I installed it by double clicking it. It opens with VirtualBox by default (if it doesn’t, open with and select VirtualBox). The following error popped up:

Failed to install the Extension Pack /path/Oracle_VM_VirtualBox_Extension_Pack-4.0.0_BETA1-68572.vbox-extpack.
Failed to locate load the main module (‘/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.x86/VBoxPuelMain.so’): VERR_FILE_NOT_FOUND.

Details:
Result Code:
NS_ERROR_FAILURE (0x80004005)
Component:
ExtPackManager
Interface:
IExtPackManager {8104df65-74d6-4e33-b374-50aa062b4afd}

When I tried to launch a Virtual Machine, I got the previous error. However, when I tried to reinstall the Extension, I got the following error:

Extension pack ‘Oracle VM VirtualBox Extension Pack’ is already installed. In case of a reinstallation, please uninstall it first.

I learned from WebUpd8 that libstdc++5 was required for it. So, I just installed it by typing the following in terminal:

 sudo apt-get install libstdc++5

Then, after restarting VirtualBox, I was able to launch my Virtual Machines again.

[HOWTO] Enable sound in Mac OS X Snow Leopard 10.5.x or 10.6.x running in VirtualBox

I have recently installed Mac OS X Snow Leopard 10.6.3 with iATKOS 3 v2 disk as guest OS in VirtualBox 3.2.12 with Debian host. After fixing the video resolution issue, I noticed that there was no sound. However, VirtualBox Forum user OmegaX has written a sound driver for Mac OS X 10.5.x and 10.6.x. It can be downloaded from here. Since I don’t have Xcode installed, and since I did not want to go through the hassle of installing the kext manually, I downloaded the binary installer, unpacked it by double clicking on it and installed it. It seems to take forever, but it installs successfully. The sound is working fine after a reboot.

[HOWTO] Increase/Change Resolution of Mac OS X Leopard inside VirtualBox

I have installed iATKOS S3 v2 inside VirtualBox running on Debian. It can be simply installed like any other Operating Systems, but if you choose Operating System as Mac OS X Server, you must uncheck Enable EFI in the settings dialog.

If you wish to install, make sure to install latest VirtualBox (at least v3.2.x) first.

After the installation is ready, I was having problems with resolution. The only resolution that was available was 1024×768. To change it, I performed the following process.

I. Change com.apple.Boot.plist
1. Open up Finder from the dock (left most icon by default).
2. Open the Partition where you have installed Mac OS X under Devices.
3. Now, if you have an Extras directory in root, look for com.apple.Boot.plist. If you don’t, go to /Library/Preferences/SystemConfiguration/. You should see com.apple.Boot.plist
4. Copy the file com.apple.Boot.plist to Desktop.
5. Open the file on the Desktop with text editor (TextEdit).
6. Look for the following text:

GraphicsEnabler

If this value exists, the next line should have something like this:

 1280x768x32

Change it to whatever resolution your monitor supports.
If the value does not exist, add the following before </dict>

        Graphics Mode
        1360x768x32
        GraphicsEnabler
        y

Make sure, you have entered proper resolution for your monitor.

The following is my complete com.apple.Boot.plist:





	Kernel
	mach_kernel
	Kernel Flags
	
	Boot Graphics
	Yes
        Quiet Boot
        No
        Timeout
        5
        Graphics Mode
        1360x768x32
        GraphicsEnabler
        y

7. Save the file to Desktop and close TextEdit.
8. Now, drag the file on the Desktop to the folder you copied it from. Confirm to Authenticate and Enter your password. Confirm to replace file.
9. Shut down Mac OS X.

II. Add Custom Video Mode as extradata to VirtualBox Configuration
1. Note your Virtual Machine Name for Mac OS X and quit VirtualBox. It is the name displayed in the Left Pane of the VirtualBox window.
2. Now, open up Terminal (or command prompt if you are using Windows) and run the following command (not as it is, make sure to make modifications. See below):

VBoxManage setextradata "Virtual Machine Name" "CustomVideoMode1" "_required_X_resolution_X_colordepth"

For example, if you have a virtual machine named “Mac Test” and want to set a resolution of 1440×900, you must run the following command:

VBoxManage setextradata "Mac Test" "CustomVideoMode1" "1440x900x32"

Now, start VirtualBox and start the Virtual Machine, Mac OS X should now use the new resolution.

Hope this helps.

[HOWTO] Enable “Mark All Upgrades” in Synaptic on Linux Mint

If you are using Linux Mint Gnome or Linux Mint Debian Edition, you will notice that Ctrl+G or Mark All Upgrades is disabled. This has been done to prevent users from installing upgrades that have not been tested and verified to work by Linux Mint team. Read more in this discussion.

However, if you can take care of your packages and the problems that may arise, you may want to enable the handy feature. It can be done by following the instructions below.

Open up the terminal and remove synaptic completely:

sudo apt-get purge synaptic

Then edit out the line in the following file or remove it completely. However, if you want to be able to enable it, it is recommended to just disable the line using a # in the beginning of the line.

/etc/linuxmint/adjustments/10-mintsystem-synaptic.overwrite

To edit it, you can open in any text editor as root. For example, to edit it using gedit, you may press Alt+F2 and enter the following:

gksu gedit /etc/linuxmint/adjustments/10-mintsystem-synaptic.overwrite

Make sure the line looks like the following by adding a # in the beginning of the line:

#/usr/lib/linuxmint/mintSystem/adjustments/synaptic.glade /usr/share/synaptic/glade/window_main.glade

Save the file and exit.
Then, install synaptic again:

sudo apt-get install synaptic

While removing Synaptic, note the packages being removed and install them back:

sudo apt-get install aptoncd apturl jockey-gtk mint-meta-gnome mint-meta-main mintupdate

That’s it. Open up synaptic and you should be able to use “Mark All Upgrades” again.

If you wish to disable the mark all upgrades again, just remove synaptic and then remove the # from the same file and save it. Then, re-install synaptic again.

Hope it helps.

[SOLVED] “Error: Dependency is not satisfiable: libnautilus-extension1 (>= 1:2.22.2)” while installing dropbox

I downloaded nautilux-dropbox Ubuntu deb package from Dropbox Linux Download Page. When I tried to install it via gdebi deb installer in Debian, I got the following error:

Error: Dependency is not satisfiable: libnautilus-extension1 (>= 1:2.22.2)

If you add repos and try to install it from there via Synaptic, you will get the error:

nautilus-dropbox:
Depends: libnautilus-extension1 (>=1:2.22.2) but 2.30.1-2 is to be installed

If you install it with dpkg -i, you will get the following error:

Selecting previously deselected package nautilus-dropbox.
(Reading database … 229404 files and directories currently installed.)
Unpacking nautilus-dropbox (from nautilus-dropbox_0.6.7_i386.deb) …
dpkg: dependency problems prevent configuration of nautilus-dropbox:
nautilus-dropbox depends on libnautilus-extension1 (>= 1:2.22.2); however:
Version of libnautilus-extension1 on system is 2.30.1-2.
dpkg: error processing nautilus-dropbox (–install):
dependency problems – leaving unconfigured
Processing triggers for gnome-menus …
Processing triggers for desktop-file-utils …
Processing triggers for hicolor-icon-theme …
Processing triggers for man-db …
Errors were encountered while processing:
nautilus-dropbox

Using the dpkg method will result in broken packages.

I had downloaded the version 0.6.7 32 bit (i386) i.e. nautilus-dropbox_0.6.7_i386.deb and was unable to install it cleanly. However, when I ran it by force installing, it ran without problems but the package was broken. So, the problem was not with the unmet dependencies but the deb file wrongly specifying dependencies.

So, I decided to fix the deb file. I unpacked the deb:

mkdir -p extract/DEBIAN
dpkg-deb -x nautilus-dropbox_0.6.7_i386.deb extract/
dpkg-deb -e nautilus-dropbox_0.6.7_i386.deb extract/DEBIAN/

Then edited the extract/DEBIAN/control file with gedit. You can use any other text editor of your choice.
The “Depends:” line looks like the following:

Depends: libatk1.0-0 (>= 1.20.0), libc6 (>= 2.4), libcairo2 (>= 1.6.0), libglib2.0-0 (>= 2.16.0), libgtk2.0-0 (>= 2.12.0), libnautilus-extension1 (>= 1:2.22.2), libpango1.0-0 (>= 1.20.1), python (>= 2.5), python-gtk2 (>= 2.12)

Notice the entry “libnautilus-extension1 (>= 1:2.22.2)”. In my installation, the version of libnautilus-extension1 is 2.30.1 and not 1:2.30.1 (which is the version format for libnautilus-extension1 in Ubuntu). So, I edited the version number to 2.22.2 instead of 1:2.22.2. So, the new depends line looks like the following:

Depends: libatk1.0-0 (>= 1.20.0), libc6 (>= 2.4), libcairo2 (>= 1.6.0), libglib2.0-0 (>= 2.16.0), libgtk2.0-0 (>= 2.12.0), libnautilus-extension1 (>= 2.22.2), libpango1.0-0 (>= 1.20.1), python (>= 2.5), python-gtk2 (>= 2.12)

After the change, create a directory called build and run the dpkg-deb command with -b switch to build the new deb file:

mkdir build
dpkg-deb -b extract/ build/

You will find a deb file in build/ directory which should install without dependency problems.

After installing, install the service by running the following as root and you are all done:

dropbox start -i

Hope this helps.

[HOWTO] Install Greasemonkey Firefox Addon in Firefox 4

I have installed Firefox 4 in my Debian Testing installation from Launchpad PPA. It is quite stable and I have decided to use it instead of Firefox 3. Most of the addons I used is compatible with Firefox 4 by now. However, the version of Greasemonkey available in Mozilla Firefox Addons Site is not compatible with Mozilla Firefox v4 latest build. To install the latest nightly build of Greasemonkey, I went to Greasemonkey Nightly Download and installed it. However Greasefire is not available, we can install userscripts directly from Userscripts website for now.

[HOWTO] Change Debian Testing to Linux Mint Debian Edition (LMDE)

Linux Mint Debian Edition is a rolling release distro based on Debian Testing. It is currently only available in 32bit and not for other architectures.

If you already have a Debian Testing installation, you will not have problems changing it to Linux Mint, if you wish to. This can be achieved by changing apt sources and preferences and installing Linux Mint meta packages.

Open /etc/apt/sources.list as root and append the following line at the end of the file:

deb http://packages.linuxmint.com/ debian main upstream import

If you want real Linux Mint Debian, you will need to remove other software sources like Unstable repos but have the following at least:

deb http://ftp.debian.org/debian testing main contrib non-free
deb http://security.debian.org/ testing/updates main contrib non-free
deb http://www.debian-multimedia.org testing main non-free

Now, open up /etc/apt/preferences and add the following:

Package: *
Pin: release o=linuxmint
Pin-Priority: 700

Package: *
Pin: origin packages.linuxmint.com
Pin-Priority: 700

Package: *
Pin: release o=Debian
Pin-Priority: 500

The above change will make sure that Linux Mint repos will be favored over Debian.

First upgrade your installation:

apt-get update
apt-get upgrade

Now, install the following packages:

mint-meta-debian
mint-wallpapers-extra
mint-wallpapers-previous-releases

by running:

apt-get install mint-meta-debian mint-wallpapers-extra mint-wallpapers-previous-releases

If some installed packages conflict with the new packages, remove them and try again.

Now, change the default theme to Shiki-wise, remove upper panel and add notification area, mintmenu to lower panel and you are done.