r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

How To: Mount a Google Nexus 7 Tablet in Linux

r3dux | November 3, 2012

In Windows you can just plug it in and it’ll mount and recognise just fine, but in Linux you need to work a little bit harder. Not that much harder, though – it’s a 4-step….

1 – Get the right tools

sudo apt-get install mtp-tools mtpfs

2 – Set up a udev rule to do the right thing on connection

gksu gedit /etc/udev/rules.d/51-android.rules

Add this text to the rule to specify the Vendor ID, Product ID and user who has access to the device (change YOUR-USERNAME-HERE to your username, obv):

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666", OWNER="YOUR-USERNAME-HERE"

3 – Restart udev and set up a mount point

sudo service udev restart
sudo mkdir /media/Nexus7
sudo chmod a+rwx /media/Nexus7

4 – Hook it up

Plug in your Nexus 7 and select MTP device as the connection type.

Then enter:

sudo mtpfs -o allow_other /media/Nexus7

At this point you should be able to read/write to your N7 via the /media/Nexus7 folder through any means you choose.

When you need to, just run either of the following for a clean dismount:

sudo umount /media/Nexus7

or

sudo umount mtpfs

Source: http://www.nexus7tablethelp.com/2012/07/connect-nexus-7-to-linux-via-mtp-using.html, I just paraphrased it a little to simplify.

Comments
1 Comment »
Categories
Linux
Tags
Android, Device, Linux, mount, MTP, Nexus, Nexus 7
Comments rss Comments rss
Trackback Trackback

How to: Get Minecraft working in Linux

r3dux | September 27, 2012

Minecraft Wallpaper

Attempt a quickfix?

If you’re trying to run Minecraft in Linux and it’s failing with errors like:

wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)

or

Could not find the main class: net.minecraft.Launcher.Frame

Then the chances are you can fix it up by performing the following actions:

  • Set your LD_LIBRARY_PATH variable with:
    export LD_LIBRARY_PATH="the-correct-path-to-your-JRE-java-binary-which-is-NOT-usr/bin"
  • (if needs be) Get rid of OpenJDK and install the official Sun/Oracle Java binaries if required.

Know how do all that? Awesome – carry on! Not so sure? Read on! ;-D

Setting the correct JRE location

First up, check if you have Java installed by typing java -version, if it comes up with something like the below, then you’re got Java installed, now we just need to find out where:

java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

If you didn’t get anything similar to the above you might want to install the official Oracle Java implementation, which I put together a brief step-by-step for here.

Assuming you have some variety of the Java Virtual Machine (JVM) install, check if your LD_LIBRARY_PATH environment variable is set with:

printenv | grep LIBRARY

If it comes up empty, then we need to find out where Java’s installed and set it correctly. To get the correct path for where your particular Java install is located, you might be tempted to try running which java:

$ which java
/usr/bin/java

However, this is a little bit of a fib, as Java is part of the alternatives setup where we can have multiple versions installed at once – which means that /usr/bin/java is really a symbolic link to the true java location. To find where it’s really pointing we can either ask update-alternatives how it’s configured like so (and pick a version different version if we want to):

$ update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
 
  Selection    Path                               Priority   Status
------------------------------------------------------------
  0            /usr/bin/gij-4.6                    1046      auto mode
  1            /usr/bin/gij-4.6                    1046      manual mode
* 2            /usr/lib/jvm/jdk1.7.0_07/bin/java   1         manual mode
 
Press enter to keep the current choice[*], or type selection number: 2

Or we can look closely at the /usr/bin/java symlink:

$ ls -alh /usr/bin/java
lrwxrwxrwx 1 root root 22 Aug 15 05:03 /usr/bin/java -> /etc/alternatives/java

Which if we then look closely at /etc/alternatives/java then points at:

ls -alh /etc/alternatives/java
lrwxrwxrwx 1 root root 33 Aug 15 16:37 /etc/alternatives/java -> /usr/lib/jvm/jdk1.7.0_07/bin/java

Same thing as what the alternatives config’s pointing at ;-)

Now that we have the correct path, we can set it in the following manner (remember to substitute your particular Java location into the below lines!):

For 64-bit Linux:

export LD_LIBRARY_PATH="/usr/lib/jvm/jdk1.7.0_07/jre/lib/amd64"

For 32-bit Linux:

export LD_LIBRARY_PATH="/usr/lib/jvm/jdk1.7.0_07/jre/lib/i386"

With that done, you should be able to see that it’s set by running:

printenv | grep LIBRARY

Which should give you something like:

$ printenv | grep LIBRARY
LD_LIBRARY_PATH=/usr/lib/jvm/jdk1.7.0_07/jre/lib/amd64

Finally, we should be fit to launch Minecraft like this (assuming the minecraft.jar file is in your home folder):

java -Xmx1024M -Xms512M -cp ~/minecraft.jar net.minecraft.LauncherFrame

Or, without setting the memory and classpath variables, like this:

java -jar ~/minecraft.jar

Be aware that the LD_LIBRARY path will only be set for the current session of the current shell, so you’ll have to re-set it a lot. A quick and easy way to do this is to just knock together a quick launcher script as below (substituting your paths in) and throw it in /usr/local/bin:

minecraft.sh

#!/bin/bash
export LD_LIBRARY_PATH="/usr/lib/jvm/jdk1.7.0_07/jre/lib/amd64"
java -Xmx1024M -Xms512M -cp ~/Games/Minecraft/minecraft.jar net.minecraft.LauncherFrame

Final Notes

Not being able to set a persistent LD_LIBRARY_PATH is a pain, because it won’t take if set in the ~/.profile or ~/.bash_profile or ~/.bash_rc config files (I’m not so sure about ~/.pam_environment) – which you can read about here: https://help.ubuntu.com/community/EnvironmentVariables.

There’s a fix which involves disabling ssh-agent in this bug report (see post #21 here), but really for the sake of a two line launcher script I think it’s best to just leave it be.

Happy mining and crafting! =D

Comments
9 Comments »
Categories
Gaming, How-To, Linux
Tags
Java, LD_LIBRARY_PATH, Linux, Minecraft
Comments rss Comments rss
Trackback Trackback

How To: Install the official Oracle JRE/JDK in Linux

r3dux | September 26, 2012

Installing the official Sun/Oracle Java implementations used to be as easy as installing sun-java6-* and uninstalling all the OpenJDK and IcedTea (Java plugins based on OpenJDK) packages you could find – but you can’t get the offical “Sun” packages anymore, instead you have to go get the binaries from Oracle (who bought Sun Microsystems). You can take a swiz at the possible Java implementations here if you like.

Anyways, to get and install the official JRE or JDK (I’ll assume that most people aren’t going to be developing in Java so only want the Runtime Environment and not the full Development Kit):

  1. Head on over to: http://www.oracle.com/technetwork/java/javase/downloads/index.html and download tar.gz version of the latest JRE, which at the time of writing is 1.7 update 7 (i.e. 1.7.0_07, the Linux 64-bit version of which is called jre-7u7-linux-x64.tar.gz),
  2. Extract the downloaded archive through any way you see fit. I’ll assume you downloaded it to your Downloads folder and extracted it there for the following commands,
  3. Create a new folder for it wherever your distro likes to put Java installs, for example:
    sudo mkdir /usr/lib/jvm/jre1.7.0_07
  4. Move your extracted JRE to that location using:
    sudo mv ~/Downloads/jre7_u7/* /usr/lib/jvm/jre1.7.0_07/"
  5. Update your alternatives to prefer the new version of java by running (one line at a time):
    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.7.0_07/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.7.0_07/bin/javaws" 1

    If you’re installing the JDK you’ll prolly want to set the javac (Java Compiler) binary to the new version too using:

    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jre1.7.0_07/bin/javac" 1

    The number at the end of the line is the priority of this binary out of any other java/javac/javaws binaries alternatives knows about, and goes from 1 (most important – try to use first) to 100 (least important – use only as a last resort)

  6. If you want to set, or make sure the update-alternatives commands took, you can also run (again, one line at a time):
    sudo update-alternatives --config java
    sudo update-alternatives --config javaws
    sudo update-alternatives --config javac     <-- only if you installed the JDK
  7. Finally, to check it all really took, issue:
    java -version

    and you should see some output showing that the newest version of Java is in effect, like this:

    java version "1.7.0_07"
    Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
    Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

Done & dusted.

Comments
1 Comment »
Categories
How-To, Linux
Tags
install, Java, JDK, JRE, Official, Oracle, Sun, update-alternatives
Comments rss Comments rss
Trackback Trackback

How To: Downgrade libcairo2 in Debian (and fix Evince)

r3dux | July 25, 2012

Evince crashing with a libcairo segfault like this?

evince[3750]: segfault at 0 ip 00007f1af3de6640 sp 00007fffb9e0af38 error 4 in libcairo.so.2.11200.2[7f1af3d6e000+f4000]

It’s a libcairo2 1.12.2-2 issue – which you can thankfully fix by downgrading libcairo2 to a 1.10.2 incarnation – here’s how…

Check package availability

First check you have an alternate version to downgrade to. To do this in Synaptic select the libcairo2 package then click on the Versions tab at the bottom, or you can do the same check via a swift apt-cache policy libcairo2 as shown below:

$ apt-cache policy libcairo2
libcairo2:
  Installed: 1.12.2-2
  Candidate: 1.12.2-2
  Version table:
 *** 1.12.2-2 0
        500 http://ftp.us.debian.org/debian/ testing/main amd64 Packages
        100 /var/lib/dpkg/status
     1.10.2-2ubuntu2 0
        500 http://packages.linuxmint.com/ debian/upstream amd64 Packages

In this case the older (but functional) package 1.10-2-2ubuntu2 is available. Let’s assume there’s an older package you can use – if not, go get one from elsewhere.

Uninstall and force a different version

Uninstall libcairo2 using any manner you like – this will also force removal of things like Evince as dependencies, unless you see anything spectacular that you know you need just let it.

Then in Synaptic, search for libcairo2, select it (i.e. click on it), then from the Synaptic menu choose Package > Force Version and choose the older, working package, and install it.

Next, you’ll want to lock to that version so it doesn’t get upgraded (at least until there’s a newer working version), so again from the menu just select Package > Lock Version.

Reinstall libcairo-using things

Finally, reinstall what was ailing ya and everything should work fine. In my case at least, this means I can reinstall the Evince PDF viewer and it’ll now print to PDF without segfaulting – Huzzah! =D

I’ve no doubt you can do this entire process from the command line, but it’s easy and works through Synaptic so I’ll leave that as an exercise for the reader.

As an added bonus, if you’re experiencing slow display and/or corrupted text in Iceweasel or Chromium then the downgrade should fix that up too. You can read more about which here.

Comments
No Comments »
Categories
How-To, Linux
Tags
bug, Crash, Error, Evince, Force, libcairo2, Linux, package, Segfault, Synaptic, version
Comments rss Comments rss
Trackback Trackback

How To: Properly automount NTFS and vfat partitions in Linux using fstab

r3dux | July 21, 2012

This is more for my own notes than anything else, but to properly mount NTFS or vfat (i.e. FAT16/FAT32) partitions in Linux, first find the UUID of the drive using:

ls -l /dev/disk/by-uuid

For example:

r3dux@r3d-laptop:~$ ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 Jul 14 08:40 3f55aec7-b4be-4b51-bce7-ce32ec661eba -> ../../sda2
lrwxrwxrwx 1 root root 10 Jul 14 09:46 669A58CD9A589B7F -> ../../sdb3
lrwxrwxrwx 1 root root 10 Jul 14 08:40 bb15a473-2531-441a-a9d9-a6bbef705a57 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jul 14 08:40 C2B2D3AEB2D3A567 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Jul 14 08:40 c5364a36-80ee-495f-9379-982a2c0397ea -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 14 08:40 EA26C54026C50E8F -> ../../sdb1

To mount NTFS or vfat partitions properly, you need to specify dmask (directory mask) and fmask (file mask) values, which as you might expect are the MASKS of the values you want to use (i.e. the octal compliments). Yeah, I’m not sure why it’s done this way either, but to calculate the mask value just subtract the value you want from 7.

As long as you know the following you should be just fine:

  • Read is 4,
  • Write is 2, and
  • Execute is 1.

For example:

  • If you want to mount the drive with 777 permissions (owner, group and other all r+w+x), then the mask of that is 000 – i.e. 7-7 = 0 for read, write and execute
  • If you want to mount the drive with 751 permissions (owner r+w+x, group r+x, other x), then the mask is 026 – i.e. 7 – 7 = 0, 7 – 5 = 2, 7 – 1 = 6)

So once you’ve identified your partition, you can add the following to your /etc/fstab file to have it mount automatically on boot:

UUID=<YOUR-UUID-HERE>    <DIRECTORY-TO-MOUNT-AT>    ntfs    uid=<YOUR-UID>,gid=<YOUR-GID>,dmask=<YOUR-DMASK>,fmask=<YOUR-FMASK>    0    0

So if I want to automatically mount my sdb3 partition at boot (which I know is formatted as ntfs) at /media/DATA with 755 permissions (owner r, group r+X, other r+x, i.e. 022 mask), I could use:

UUID=669A58CD9A589B7F    /media/DATA    ntfs    uid=r3dux,gid=r3dux,dmask=022,fmask=022    0    0

For the user ID (uid) or group ID (gid) values, you can use the numerical or actual values, i.e. uid=r3dux,gid=r3dux is fine, as is uid=1000,gid=1000 etc.

The first user account and group ID for any user on a Linux system are generally 1000.

If you’re not sure of your uid or gid values, just enter id in a terminal and it’ll tell you:

r3dux@r3d-laptop:~$ id
uid=1000(r3dux) gid=1000(r3dux) groups=1000(r3dux),4(adm),20(dialout),24(cdrom),25(floppy),26(tape),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(netdev),111(fuse),113(lpadmin),116(powerdev),117(scanner),125(vboxusers)

Happy NTFS & vfat automouting ;-)

Comments
No Comments »
Categories
How-To, Linux
Tags
automount, fstab, gid, Linux, Mask, mount, ntfs, octal, permissions, uid, vfat
Comments rss Comments rss
Trackback Trackback

« Previous Entries

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Convert CS4 Effect Error Film Flash FPS GLFW Glitch GLSL Hack How-To install Java Kinect Linux Live Mash-Up Microsoft Motion mount OpenGL Particle Problem PS3 Remix Retro script Slides Sound Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“Knowledge is a process of piling up facts; wisdom lies in their simplification. ”

 - Martin H. Fischer

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox