Jump to content

[How-to] Enable Usb Mass Storage With Swap Partition


Recommended Posts

This tutorial applies to the WiFi Pineapple Mark IV.

1. Partition and format your USB Flash Disk. We'll be using the 4GB SanDisk Cruzer Fit (Available in the HakShop /shameless plug)

a. Using Ubuntu open Disk Utility from System > Admin.

b. Unmount any mounted existing volumes

c. Delete any existing partitions. You should now have a blank drive with no partitions as seen below.

6844777856_7f35cdfddd.jpg

d. Create your first partition using the Create Partition button and make the partition take 80% of the available space. The unused space will be used for your swap partition. Make sure to uncheck the box regarding taking ownership and select EXT4 as the filesystem.

6844777842_c609b2328b.jpg

e. Repeat the previous step using the last available space, unchecking the ownership box and selecting EXT4 as the FS. Name the partitions whatever you like.

6844777844_272ee49f82.jpg

f. Your drive show look like the below image. Remove the USB drive from your Linux box.

6844777858_4edef31299.jpg

2. Configure the Swap partition on your WiFi Pineapple

a. On the WiFi Pineapple's Web UI browse the the USB page and ensure that your config looks like the one below.

6844777852_1f76020b2d.jpg


config global automount
       option from_fstab 1
       option anon_mount 1

config global autoswap
       option from_fstab 1
       option anon_swap 1

config mount
       option target   /usb
       option device   /dev/sda1
       option fstype   ext4
       option options  rw,sync
       option enabled  1
       option enabled_fsck 0

config swap
       option device   /dev/sda2
       option enabled  1

b. Plug in the USB drive and wait a minute for everything to settle.

c. SSH into the WiFi Pineapple (typically "ssh root@172.16.42.1")

d. Issue "mkswap /dev/sda2"

root@Pineapple:~# mkswap /dev/sda2
Setting up swapspace version 1, size = 1003741 kB
no label, UUID=97996185-a731-4d1e-92d8-1017fdb3603e

e. Reboot the WiFi Pineapple by issuing "reboot"

3. Verify that swap space has been enabled

a. From the Advanced page issue the command "free"

6844777850_41bf8bc954.jpg

More reading on fstab in openwrt: http://wiki.openwrt.org/doc/uci/fstab

Installing packages to the USB partition:

Your /etc/opkg.conf file should look like the below. You can verify by issuing "cat /etc/opkg.conf" from a SSH session or from the Advanced pages execute commands box.

dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
dest usb /usb 

Update opkg by issuing "opkg update" (Internet connection required so enable 3G or Tether)

Install packages using the syntax "opkg install --dest usb packagename"

Thoughts?

Link to comment
Share on other sites

  • Replies 100
  • Created
  • Last Reply

Top Posters In This Topic

This is Great:-)

Is this so we can run something like sslstrip? and how long do you think the usb drive's life would be?

Does the swap wright to a new location every time?

I wouldn't worry too much about it. I've run full linux distros on flash media for years. They all have wear leveling built in now, so it shouldn't wear out too fast.

Link to comment
Share on other sites

Thanks for the tute Darren, worked well for me. I used gparted instead to setup the partitions. Just keep in mind though that removal and reinsertion of the usb drive doesn't remount it as /dev/sda, but sdb instead and so on for each unplug/replug.

Edited by Isc
Link to comment
Share on other sites

i have set this up and my experiences have been a little hit and miss.

when rebooting the pineapple, the USB doesnt always automatically find itself. the light on my usb wont always boot up and the usb led on the pineapple itself remains off. i try to unplug and replug and sometimes it will work but most times it wont.

not sure where im going wrong here. its a good USB, its been formatted as mentioned above and the USB code has been amended and mkswap issued. :(

I'm not really going to be using 3g and will always have this USB plugged in but it doesnt appear to want to play ball!

Link to comment
Share on other sites

Thank You!

I edited the steps in your tutorial to fit location/mnt points for a microSD in a ZTE MF591 'rocket'.

Still need to ln sbin or use absolute paths for warez, but it works like a charm. Ran tcpdump all night last nite on a 16GB sd-card.

Now it is possible to autossh -M 2000 -N -R 4255:localhost:22 root@myipaddy

then from diff laptop ssh into root@myipaddy

from there ssh localhost -p 4255

myipaddy acts as relay

can't seem to log out of pineapple ssh session and keep autossh session alive. I'm still learning (thank god)

and I also used gparted. I was concerned about Darrens instruction for 'take ownership' of filesystem, as gparted did not give an option to disable/uncheck. But it worked perfectly. Again. Thank you. Thank you for subjecting me to such a fun device.

Link to comment
Share on other sites

Thank You!

I edited the steps in your tutorial to fit location/mnt points for a microSD in a ZTE MF591 'rocket'.

Still need to ln sbin or use absolute paths for warez, but it works like a charm. Ran tcpdump all night last nite on a 16GB sd-card.

Now it is possible to autossh -M 2000 -N -R 4255:localhost:22 root@myipaddy

then from diff laptop ssh into root@myipaddy

from there ssh localhost -p 4255

myipaddy acts as relay

can't seem to log out of pineapple ssh session and keep autossh session alive. I'm still learning (thank god)

and I also used gparted. I was concerned about Darrens instruction for 'take ownership' of filesystem, as gparted did not give an option to disable/uncheck. But it worked perfectly. Again. Thank you. Thank you for subjecting me to such a fun device.

condor could you please share the steps you took to do this as im having no luck mounting my microsd in my huawei modem, i have the card formatted as per darrens instructions.

Thanks

Link to comment
Share on other sites

I typed out the steps I took, then followed them again to make sure they work before posting and found some inconsistencies. 1)pineapple mounts the device differently depending whether or not 3G is enabled? It mounted the microSD card @ /usb, but when I enabled 3G it moved on it's own to /mnt.

This was strange behavior to me, and I got lost. Began editing files and ended up crashing the thing. Reset and put it on a shelf. Will attempt again tonite when the old-lady goes to sleep :blink:

Link to comment
Share on other sites

ok I got it going now it was simple in the end, the micro sd shows as sda in /dev, so all I had to do was change the line,

option device /dev/sda1

to

option device /dev/sda

then I followed Darrens instructions and it worked perfectly

resourceseo.jpg

Link to comment
Share on other sites

Gawd I feel like such a !@#$%!@#$% n00b sometimes.

- 8GB Sandisk Fit

- Followed the instructions to the letter, using Ubuntu to create the partitions just as Darren shows, though mine has a 6GB "main" and a 2GB "swap" instead of 3GB/1GB.

I booted the MK4, let it come up fully.

Start GUI and follow instructions to make my USB page setting the same as shown (I had to change a few 0's to 1's).

Updated Fstab with the button, and it saved it (I know this because I refreshed the page, and it held through a subsequent reboot)

Fired up PuTTY and got into console, issued the following from the prompt: mkswap /dev/sda2

I get: /dev/sda2: No such file or directory

I confirm that in the GUI, it shows in USB:

Bus 001 Device 001: ID xxxx:xxxx Linux Foundation 2.0 root hub

Bus 001 Device 005: ID xxxx: xxxx SanDisk Corp. Cruzer

The USB LED is lit up on the MK4 (solid)

The orange light on the SanDisk has been flashing rapidly now for about 50 minutes, no sign of stopping

I have shut down the MK4, put the USB back in the ubuntu machine, deleted/recreated partitions, retried it in the MK4, same results. The USB drive is fine and Ubuntu sees it fine and mounts both partitions, EXT4 style.

Any assistance would be greatly appreciated. I can't get this thing to work in the MK4 to save my life.

Thanks gang.

Link to comment
Share on other sites

Gawd I feel like such a !@#$%!@#$% n00b sometimes.

- 8GB Sandisk Fit

- Followed the instructions to the letter, using Ubuntu to create the partitions just as Darren shows, though mine has a 6GB "main" and a 2GB "swap" instead of 3GB/1GB.

I booted the MK4, let it come up fully.

Start GUI and follow instructions to make my USB page setting the same as shown (I had to change a few 0's to 1's).

Updated Fstab with the button, and it saved it (I know this because I refreshed the page, and it held through a subsequent reboot)

Fired up PuTTY and got into console, issued the following from the prompt: mkswap /dev/sda2

I get: /dev/sda2: No such file or directory

I confirm that in the GUI, it shows in USB:

Bus 001 Device 001: ID xxxx:xxxx Linux Foundation 2.0 root hub

Bus 001 Device 005: ID xxxx: xxxx SanDisk Corp. Cruzer

The USB LED is lit up on the MK4 (solid)

The orange light on the SanDisk has been flashing rapidly now for about 50 minutes, no sign of stopping

I have shut down the MK4, put the USB back in the ubuntu machine, deleted/recreated partitions, retried it in the MK4, same results. The USB drive is fine and Ubuntu sees it fine and mounts both partitions, EXT4 style.

Any assistance would be greatly appreciated. I can't get this thing to work in the MK4 to save my life.

Thanks gang.

Do a dmesg, your drive might be sdb or something goofy. Should see something like this;

[   11.770000] Initializing USB Mass Storage driver...
[   11.770000] usbcore: registered new interface driver usb-storage
[   11.780000] USB Mass Storage support registered.
[   11.810000] scsi0 : usb-storage 1-1:1.0
[   12.810000] scsi 0:0:0:0: Direct-Access     Staples                   1.22 PQ: 0 ANSI: 5
[   12.820000] sd 0:0:0:0: [sda] 7821312 512-byte logical blocks: (4.00 GB/3.72 GiB)
[   12.820000] sd 0:0:0:0: [sda] Write Protect is off
[   12.830000] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[   12.830000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   12.840000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   12.850000]  sda: sda1 sda2
[   12.850000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   12.860000] sd 0:0:0:0: [sda] Attached SCSI removable disk

Are you using a hub? If so, try directly connecting the drive.

Edited by barry99705
Link to comment
Share on other sites

Do a dmesg, your drive might be sdb or something goofy. Should see something like this;

[   11.770000] Initializing USB Mass Storage driver...
[   11.770000] usbcore: registered new interface driver usb-storage
[   11.780000] USB Mass Storage support registered.
[   11.810000] scsi0 : usb-storage 1-1:1.0
[   12.810000] scsi 0:0:0:0: Direct-Access     Staples                   1.22 PQ: 0 ANSI: 5
[   12.820000] sd 0:0:0:0: [sda] 7821312 512-byte logical blocks: (4.00 GB/3.72 GiB)
[   12.820000] sd 0:0:0:0: [sda] Write Protect is off
[   12.830000] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[   12.830000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   12.840000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   12.850000]  sda: sda1 sda2
[   12.850000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[   12.860000] sd 0:0:0:0: [sda] Attached SCSI removable disk

Are you using a hub? If so, try directly connecting the drive.

Thanks for the quick response Barry, I learn something new and useful every time I post, thanks! :) :)

No hub, just the SanDisk Fit straight into the USB port.

Alright, well clearly there's a problem and that would explain why my troubles are, but exactly what it is I don't know. Here's the relevant part of my dmesg results:

[  192.730000] usb 1-1: new high speed USB device number 2 using ar71xx-ehci
[  193.430000] usb 1-1: device descriptor read/64, error -71
[  194.580000] usb 1-1: device descriptor read/64, error -71
[  194.810000] usb 1-1: new high speed USB device number 3 using ar71xx-ehci
[  195.400000] usb 1-1: device descriptor read/64, error -71
[  196.830000] usb 1-1: device descriptor read/64, error -71
[  197.060000] usb 1-1: new high speed USB device number 4 using ar71xx-ehci
[  198.250000] usb 1-1: device descriptor read/8, error -71
[  199.580000] usb 1-1: device descriptor read/8, error -71
[  199.810000] usb 1-1: new high speed USB device number 5 using ar71xx-ehci
[  200.810000] usb 1-1: device descriptor read/8, error -71
[  201.260000] usb 1-1: device descriptor read/8, error -71
[  201.370000] hub 1-0:1.0: unable to enumerate USB device on port 1
[  203.170000] usb 1-1: new high speed USB device number 6 using ar71xx-ehci
[  204.310000] usb 1-1: device descriptor read/64, error -71
[  204.960000] hub 1-0:1.0: unable to enumerate USB device on port 1
[  206.200000] usb 1-1: new high speed USB device number 7 using ar71xx-ehci
[  207.280000] usb 1-1: device descriptor read/64, error -71
[  208.400000] usb 1-1: device descriptor read/64, error -71
[  208.630000] usb 1-1: new high speed USB device number 8 using ar71xx-ehci
[  209.940000] usb 1-1: device descriptor read/64, error -71
[  211.150000] usb 1-1: device descriptor read/64, error -71
[  211.380000] usb 1-1: new high speed USB device number 9 using ar71xx-ehci
[  212.890000] usb 1-1: device descriptor read/8, error -71
[  214.430000] usb 1-1: device descriptor read/8, error -71
[  214.660000] usb 1-1: new high speed USB device number 10 using ar71xx-ehci
[  215.260000] usb 1-1: device descriptor read/8, error -71
[  216.480000] usb 1-1: device descriptor read/8, error -71
[  216.590000] hub 1-0:1.0: unable to enumerate USB device on port 1
[  246.320000] usb 1-1: new high speed USB device number 11 using ar71xx-ehci
[  246.480000] scsi0 : usb-storage 1-1:1.0
[  247.480000] scsi 0:0:0:0: Direct-Access     SanDisk  Firebird         1.06 PQ: 0 ANSI: 2
[  247.480000] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  247.500000] sd 0:0:0:0: [sda] 131072 512-byte logical blocks: (67.1 MB/64.0 MiB)
[  247.500000] sd 0:0:0:0: [sda] Write Protect is off
[  247.510000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[  247.510000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  247.520000] sd 0:0:0:0: ioctl_internal_command return code = 8070000
[  247.520000]    : Sense Key : 0x4 [current]
[  247.530000]    : ASC=0x0 ASCQ=0x0
[  247.530000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  247.540000]  sda: unknown partition table
[  247.550000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  247.550000] sd 0:0:0:0: [sda] Attached SCSI removable disk

It shows up and mounts fine in Ubuntu, both partitions mount, etc.

Any ideas? While I'm awaiting a reply I'm going to try to delete/recreate the partitions again (3rd time)...I know, that's the definition of insanity, but I don't know what else to try! :)

Thanks again!

eta: image of the drive in Ubuntu Disk Utility:

sandiskfit1.jpg

Edited by hfam
Link to comment
Share on other sites

Thanks again for your help Barry!

Alright, for kicks I took an older 8GB full-length USB stick and followed the directions.

Works fine.

So it's got to be something with this SanDisk Fit 8GB device.

It works fine in every other device though. Ubuntu sees it, mounts the parts, uses the file system, etc.

Same on Windows when I format it NTFS or FAT32.

For obvious reasons I don't want to use this giant damn USB stick, so I guess I'll have to order another Fit, but I'm very skeptical about this, and left wondering if I"m going to get the same problem with the SanDisk Fit across the board.

Anyone have any ideas why this USB drive would work everywhere else BUT the MK4?

Link to comment
Share on other sites

Thanks again for your help Barry!

Alright, for kicks I took an older 8GB full-length USB stick and followed the directions.

Works fine.

So it's got to be something with this SanDisk Fit 8GB device.

It works fine in every other device though. Ubuntu sees it, mounts the parts, uses the file system, etc.

Same on Windows when I format it NTFS or FAT32.

For obvious reasons I don't want to use this giant damn USB stick, so I guess I'll have to order another Fit, but I'm very skeptical about this, and left wondering if I"m going to get the same problem with the SanDisk Fit across the board.

Anyone have any ideas why this USB drive would work everywhere else BUT the MK4?

Are you powering the pineapple from the brick, or over usb? Try the power brick it came with.

Link to comment
Share on other sites

Are you powering the pineapple from the brick, or over usb? Try the power brick it came with.

Good call, I'll try that when I get home from work tonight. Was indeed powering it from USB.

Weird though...following the same instructions, the old 8GB Patriot USB stick worked fine.

I'll try about anything at this point, since the Cruzer Fit works in every other situation but the MK4. Your power suggestion is the only possible suggestion that makes sense.

I've got 2 more of the SanDisk Cruzer Fit 8GB's on the way too, so I'll also give the new one a try and weigh in with the results on that as well.

Thanks again for the suggestion!

<placeholder for results> ;)

Edited by hfam
Link to comment
Share on other sites

USB power can be an issue with some devices. I haven't put a meter on it but the pineapple doesn't have a lot of left over juice for some devices. For instance my T-Mobile modem works beautifully though the CDMA modems from Ting and Virgin will cycle every so often due to power -- which is a real pain.

We've tested the 4GB Cruzer Fit, which is why we carry it in the HakShop. I guess it's possible that the 8GB requires a little more... Odd though.

We'll have a nice solution for all of this very shortly on the HakShop. Imagine some pineapple juice with *over 9000* mAh and dual usb output hooked up to the pineapple and a mini usb powered hub.

Link to comment
Share on other sites

Barry nailed it, and of course wins all of the day's innernetz, nicely done. :)

It's a power issue.

Using a single USB port (USB to Type M barrel) for powering the MK4, and with nothing but the 8GB Cruzer Fit (no USB hub) plugged into the MK4's USB port, the MK4 will NOT recognize the 8GB SanDisk Cruzer Fit correctly. Guaranteed. I've received my second order of them (2 this time), and it is the same issue every time...fails to read/properly recognize...throws the same batch of errors as my dmesg out above shows.

I then powered up the MK4 with the 12v wall wart and it worked fine. I was then able to issue the mkswap command, and it also worked fine. Rebooted the device (keeping the 12v power), and it picked everything up as it should have, the Resources page in the GUI now shows the 1.6GB of swap space properly initialized and mounted, the 5.5GB of extra space mounted as well.

I then tried this all again on the USB power, and it failed in exactly the same fashion. Tried again back on 12v, works perfectly.

However, as indicated above, the older 8GB Patriot stick worked fine, so it's NOT an issue of size, but one of power consumption, and that is going to vary from model to model.

As Darren indicated, the 4GB has been tested, and that must be the one to use with regard to the SanDisk Cruzer Fit if you intend to power the MK4 from the USB port, the larger Cruzer Fit (8GB and 16GB) apparently require more power.

That said, I am going to try to turn one of these "USB to Type M" cables into a "2 USB to Type M" cable, similar to what Telot did with the generic USB cable, and then I'll re-try this again to see if it supplies enough power to do the 8GB Fit.

We'll have a nice solution for all of this very shortly on the HakShop. Imagine some pineapple juice with *over 9000* mAh and dual usb output hooked up to the pineapple and a mini usb powered hub.

Oh, I can imagine, but I have to put a magazine over my lap...know what I mean?!? ;)

I am all OVER that option, thanks Darren!! As with every other device in the HakShop (with the exception of I will now refer to as the "8GB Fit Debacle"...lesson learned...;) ), I'll be patronizing the HakShop for a few of those kits on release day! :)

Thanks again guys for all the help, hopefully documenting my pain here will help someone else avoid it. Buy the 4GB Fit from the HakShop!! :)

eta: clarity

Edited by hfam
Link to comment
Share on other sites

If you're still set on using a big(ger) sized usb and you're looking for small, the super talent pico line works great

http://www.supertalent.com/products/stt_usb_detail.php?type=Pico

I've got a 16GB and it works awesome :) Not quite as small as the cruzer, but still very very very small (size of my fingernail basically) and it has the bonus of being extremely durable. I highly recommend them for keychains or pineapples :) Hope this helps hfam, sorry you had bad luck with the 8GB cruzers

telot

Link to comment
Share on other sites

We'll have a nice solution for all of this very shortly on the HakShop. Imagine some pineapple juice with *over 9000* mAh and dual usb output hooked up to the pineapple and a mini usb powered hub.

Sounds great Darren! I will be first in line to purchase one, I cant wait till I get the pineapple mobile for some inconspicuous Fun lol.

Link to comment
Share on other sites

I tried to follow this guide and the other one with gparted. both worked fine, I formatted the flash to ext4 and everything, but when I plug the flash drive in the WiFi Pineapple it does not work. The led does not light up, and when I SSH into the WiFi Pineapple, and issue mkswap /dev/sda2 , it just tells me "No such file or directory"

Is there something I'm doing wrong? Or is the USB port in my WiFi Pineapple broke?

Pic related: My WiFi Pineapple with the 4GB SanDisk Cruze Fit pluged in the USB port. http://imageshack.us/photo/my-images/23/img20120325143321.jpg

http://imgur.com/6xU3p

Edited by abo al-7roof
Link to comment
Share on other sites

I had the same issue with my 16gb sandisk fit - havent tried mains power yet because i need to find a US to UK converter. But its strange that your having the same issues with the 4gb.

Have you tried taking it out, powering up then putting in?

mine sometimes works when i do that, but it isnt persistent.

Link to comment
Share on other sites

i plugged mine into my battery pack and its picking up the usb flawlessly.

one question guys, the opkg.conf file - i have removed all the lines and left what Darren has written in the original post. when running opkg update it finishes super quick. i dont think its updating. can you guys confirm what should be in this file?

thanks

EDIT

ok so I put the following line back in to my opkg.conf file

src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages

when running update i get the following error

Failed to download http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz, wget returned 1.

opkg.conf is as follows:

src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay
dest usb /usb

Edited by singh763173
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...