Archive for the 'Servers and Services' Category

13
Jul
12

Galaxy S3 access files in Linux

I’ve gotten myself a Samsung Galaxy S3 recently, and wanted to change the ringtones and upload some music.

The problem is, I use mainly linux (read: ‘I don’t have Windows’).

So what with the MTP/PTP?

Apparently libmtp and jmtpfs don’t work with the S3 very well. The error is something like:

$ mtp-detect
libmtp version: 1.1.3

Listing raw device(s)
Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
Found 1 device(s):
Samsung: GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note (04e8:6860) @ bus 2, dev 21
Attempting to connect device(s)
PTP_ERROR_IO: failed to open session, trying again after resetting USB interface
LIBMTP libusb: Attempt to reset device
LIBMTP PANIC: failed to open session on second attempt
Unable to open raw device 0
OK.

And since Kies is not available for linux (afaik) and running it on Wine is not really something I’m fond of, I had been searching for a way to access the phones files in a fast way.

There is a way, through rooting your phone, and installing an app, but my phone is new so I didn’t want that…yet 😀

Since the access would have to be fast to be of my liking, it would have to be through USB cable, not Wifi. So I would probably have to do sth with ADB (Android Debug Bridge, google it)..

There is an adbfs solution already there:
http://collectskin.com/adbfs/

But it seems to be extremely slow. Adb was NOT designed for this kind of usage (continuous I/O access).

So I went on using an app I already knew, SSHDroid:
https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid&hl=en

But doesn’t this create a SSH server for remote shell login? Yeah, kinda does… but it’s SSH! This means you can run SSHFS through it! And better, forward the listening port through ADB to your own machine, via USB cable, so no Wifi is needed.

Here are the steps:
1. Install SSHDroid and run it
2. With the phone connected via USB, test adb with

$adb devices

and see if it shows up
3. Forward the remote SSHDroid port to your machine with

$adb forward tcp:2222 tcp:2222

(2222 is the default SSHDroid port for none rooted phones)
4. Mount sshfs on your machine with:

$sshfs -p 2222 root@localhost:/mnt/ >mount point, like ~/Desktop/sshfs<

The default password should be admin, if you haven’t changed it. YOU SHOULD HAVE!
5. Done! On my Arch, nautilus did not want to unmount it, so I ran

$fusermount -u <mount point, like ~/Desktop/sshfs>

As always, don’t trust what I tell you to do, just some guidelines to be able to find a similar, if not the same, solution. Have in mind that the steps here are not idiot-proof, I expect that people at least be able to use google and the basics of linux, like installing sshfs.

UPDATE (2013-04-12):
I decided to try again using the S3 with MTP and installed go-mtpfs on Arch. https://wiki.archlinux.org/index.php/MTP

After adding me as owner to udev rule, it seems to work but has some bugs:

$ touch test
touch: failed to close ‘test’: Invalid argument

but the file shows up:

$ ls
BKP clockworkmod data DCIM Downloads LOST.DIR MOV07784.MPG Roms test Tools

$ cat test
cat: test: Invalid argument

removing it works fine…

mtpfs still doesn’t work… either with

$ mtfps ~/s3/

or

# mtfps -o allow_other /home/oliver/s3/

Just does nothing.

w00t
simple-mtfps seems to work fine, will test it further! (available in AUR from Arch or https://github.com/phatina/simple-mtpfs/)

Showing the devices:

$ simple-mtpfs -l
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
Unable to open ~/.mtpz-data for reading, MTPZ disabled.1: SamsungGalaxy models (MTP)

Mounting:

$ simple-mtpfs –device 1 s3/
Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).

Unmounting (obvious):

$ fusermount -u /home/oliver/s3

It is recomended not running simple-mtfps as root, as always… but nice that it doesn’t need to run as root 😀

Touching, displaying and removing files from both Phone and Card directories worked flawlessly.
Though I did not do a stress test on this method. Will try to pass some gigs later 😀

UPDATE2:
Seems jmtpfs is working too! Some time that I haven’t tried it. Another solution, I prefer simple-mtpfs though for more options, listing and specifying the device to be mounted.

Advertisements
23
Feb
11

Upside-Down-Ternet

Well, for some time now I’ve wanted to recreate the ‘Upside-Down-Ternet‘ from pete@ex-parrot (reference) but the process used squid to handle the proxying and I didn’t want to install and configure (even if it’s only basic config) squid.

So I was looking for an alternative. I knew that I could create a relatively simple proxy with perl or python and had started the code with perl, where I was using HTTP::Proxy and adding filters. The problem was that the proxy reported the content as chunked. And I found no way to undo this. I tried to add the complete filter, to just pass complete contents to my custom filter but I wasn’t successful sending the modified image to the client. I even asked at perlmonks but no significative answer was left(only one actually answer at all, by the time of this writing).

I started reading the source of an existing webproxy project in perl, which was implemented at a lower level. So I tried that. I created a web server and a lwp agent in my script, and connected the requests to the agent. It worked!

After some tinkering and threading the script  I got something quite decent, but not very stable… Just good enough.

Features:

  • flips images(upside-down-ternet)
  • substitutes images for one image file
  • blurs images
  • runs a custom convert(imagemagick) command

The script is available here.

Note: I thought of setting as a sf project, but this script is so insignificant…and unstable… I have another proxy project going however, that may go into sf. Who knows…

Note2: If used as a prank, it is interesting to redirect automatically the traffic from another pc to yours and act as a proxy. The iptables part should be present in pete@ex-parrot. For the redirecting I’d use arpspoofing. Google it.

19
Feb
11

Sharing Photosmart 7200 from ubuntu to win7 via smb

So, I had to format my mothers computer because the 30GB partition reserved for Windows 7 64-bits had less than 3GB free space, and nothing really removable.

Instead of being lazy and using gparted to fix the problem(which included removing a 30GB Windows XP partition and moving the current partition out of a logical section of the harddrive, I just backed up the games(Steam rocks!) and formatted the damn thing.

Of course, backing up 100GB of Steam games and then getting them back would be no easy task(12hours by the steam backup manager, spliting the games into DVD sized chunks).

After having reinstalled everything, I went to configure the printer which is connected at another computer and shared through samba on an ubuntu maverick. (It was working fine before I formatted the harddrive.)

I added the printer through the interface in windows, but a prompt asked me to select the correct driver. OF COURSE, the exact driver of the printer was NOT present. Only photosmart 8xxx or photosmart 3xxx.

Searching the internet, I found out that the driver only is installed through windows update. Great. I had to select a driver, which only was installed if the printer was selected as the correct model. Just great….

I saw some references about modifying the smb.conf and cupsd.conf but none of the tries worked. I discovered the printer could be shared by selecting the cups http interface in windows but cups did not allow remote connections, and I was not able to configure it otherwise.

I ended up grabing the printer and connecting it to the Windows 7 and installing the driver, removing the printer device and taking it back to the ubuntu computer.

Then the driver was available in the prompt. YAY.

Note: I did not need to do this before, because the first time I configured the printer, the computer sharing it was Windows XP and probably reports the driver correctly to windows 7.

UPDATE
And I formatted my windows machine again. Had the same problem AGAIN. Obvious…

But this time I think I solved it… I’m trying to as I’m writing this.
This time I shared the printer via CUPS. The samba loading before cups problem in ubuntu is at fault.

It is quite easy configuring the CUPS interface via http://localhost:631 and sharing it on the network. Fuck samba.

I added the printer via http://ubuntumaching:631/printers/printer_name and set a similar driver(Photosmart C7200).
Now, in Windows, go to the Devices and Printers window, right-click the printer in question and click the Printer properties.
In the Advanced tab, click the New Driver button. Then follow the wizard, using the Windows Update to update your drivers list. It will take a while.

Select your driver and voilá! The correct driver is installed!

21
Apr
09

Migrating VirtualBox to Vmware ESXi

A while back I was expermenting with Vmware ESXi 3.5 and wanted to convert a Virtualbox VM to a Vmware ESXi VM.

I found a way to convert the image file from .vdi to .vmdk but not the configuration files. The solution to convert .vdi to .vmdk was to have ‘vditools’ and ‘qemu’ on ubuntu.

Converting .vdi to raw(DD)

$vditools COPYDD .vdi .raw

Converting raw to .vmdk

$qemu-img convert .raw -O vmdk .vmdk

But I still had a problem importing the vmdk image to ESXi(through datastore manager or scp upload).

I finally did it using vmware converter to convert and upload directly to a infrastructure server, my vmware esxi server in this case.

Worked on ubuntu server7.04 and windows server 2003.




The Author

Older Ramblings

Tweets

Linux User Sig