Jump to content

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


Recommended Posts

Hi guys,

Wondering if anyone could help.

I followed instructions..I have a Verbatim 4gigs usb drive and formatted it as ext4.

Here is my fstab:

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

For some reason, I keep getting

No such file or directory

When doing mkswap /dev/sda2

Am I supposed to already have sda2 in /dev?

Also tried a different usb and getting the same error...what else can I try?

Thanks!

Did you try using gparted to partition the flash drive?

Link to comment
Share on other sites

  • Replies 100
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 months later...

I keep getting the following message trying to create the swap on while the usb stick is plugged in

mkswap /dev/sdb2

/dev/sdb2: Device or resource busy

(I can switch it to sda2 by editing the fstab to have sdb init and when i mount the usb it will take the sda place).

Anyone have any thoughts on how to get past the device or resource busy error?

http://cl.ly/0v010g0d2z0b1y0a2f0a (screen shot of my settings)

Edited by Jeff
Link to comment
Share on other sites

I keep getting the following message trying to create the swap on while the usb stick is plugged in

mkswap /dev/sdb2

/dev/sdb2: Device or resource busy

(I can switch it to sda2 by editing the fstab to have sdb init and when i mount the usb it will take the sda place).

Anyone have any thoughts on how to get past the device or resource busy error?

http://cl.ly/0v010g0d2z0b1y0a2f0a (screen shot of my settings)

if the mkswap command has already been run on that partition then that is normal.

I am curious why your using sdb2? and not sda2?

Link to comment
Share on other sites

if the mkswap command has already been run on that partition then that is normal.

I am curious why your using sdb2? and not sda2?

I have not run the mkswap command on the partition before and it still gives that error.

The sdb2 vs sda2 happens because of the following. If my fstab looks as follows

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

config swap
       option device   /dev/sdb2
       option enabled  1

when I plug in the usb drive it will mount it at /dev/sda1 and /dev/sda2

if I change the fstab to the following

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

when plugging in the usb drive it mounts it to /dev/sdb2 which is the state I had it in when i posted the request for help. Changing it back and forth has not helped either way so I just posted in the state I was in. The problem with the command not returning the correct response is that it doesn't appear to be reading the usb as part of the memory right now.

root@Pineapple:~# free
             total         used         free       shared      buffers
Mem:         29524        25180         4344            0         3636
-/+ buffers:              21544         7980
Swap:            0            0            0
root@Pineapple:~# 

Link to comment
Share on other sites

weird? I would re format the drive and re flash the pineapple to make sure it's not a glitch.

That did the trick. For anyone else that comes across this problem. It looks like updating the firmware with the usb drive in was the difference. If you update the firmware and reconfigure things you might wanna do it with the usb drive out. Second time around and I am back up and running.

Thanks for the help.

Link to comment
Share on other sites

THE WINDOWS WAY

Hi folks.

I've never bothered with Linux before because I've never needed to. Nor a Mac come to that. I'm a Windows kinda guy and consequently I'm rubbish with Linux. It's probably not THE thing to say on any forum, let alone a Hak5 one, but for anyone else out there like me, here's how to format their USB drive with Windows. After doing these very spoon-fed, hand-held steps, you can just pop the USB in to the Pineapple and give it a restart and all is good without having to download VMWare and Ubuntu:

1) Download MiniTools "Partition Wizard Home Edition" for free from http://www.partitionwizard.com/free-partition-manager.html

2) Follow the step by step install. I just used default options throughout.

3) Open up the tool with your USB drive already plugged in to your PC.

4) Identify your USB drive (either by drive letter, size, etc) and right click it. Select "Delete" to delete the partition.

5) Right click again and select "Wipe". The default "Fill sectors with Zero" is fine - you're only trying to clean it up a bit and you don't want to wait hours for this to do!

The tool hasn't done these actions yet - it's building a list of processes to carry out. Now is your last chance to remember if you have any important stuff on your USB drive that you actually need or to realise if you're about to perform these actions on your hard drive, because if you can't even get this right, it's likely to cost you a fair bit to recover the data. Once satisfied a personal armageddon is not going to ruin your life just yet...

6) ...Click "Apply" in the top left!

7) Warning message blurb; ignore and click Yes. You can carry on using your PC, just don't let it go in to sleep mode. If you can't disable that, then you really should consider whether you should be doing THIS process for THIS purpose!

Whir whir whir... This can take a few minutes, so go find a cheesy 80s song on YouTube and practice busting some grooves. Personally, I chose

8) Just before you start considering getting a perm like Phil, you'll get a success message. Click "OK".

9) Right-click the drive again and select "Create". Use these settings: Create As = Primary; File System = EXT4; Drag the right side of the slider down to about 80%.

10) Everything else is inconsequential, so be care-free and click "OK"

11) Right-click the "Unallocated" portion of your drive and select Create. Use these settings: Create As = Primary; File System = Linux Swap.

12) Don't move the slider this time, just click "OK".

13) Click "Apply" from the top left again, ignore the error message and stick Phil Oakly back on.

14) Click "OK" on the success message and close the program.

15) Browse to the Pineapple's USB page and update the script with this from Darren's post at the top:

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

16) Plug the USB drive into the Pineapple and restart it whichever way you prefer. I like to get physical with my Pineapple, so I pull the power.

That's it! Job done. Play Phil Oakly one more time to celebrate.

Link to comment
Share on other sites

  • 1 month later...

That did the trick. For anyone else that comes across this problem. It looks like updating the firmware with the usb drive in was the difference. If you update the firmware and reconfigure things you might wanna do it with the usb drive out. Second time around and I am back up and running.

Thanks for the help.

I'm wondering if this might have been a one-time issue, or if it's always recommended to remove the USB drive when updating? I wanted to mount my 32GB Sandisk Cruzer fit inside the MK4, and it'd be a real pain to unplug it.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

i cant seem to make the usb thingy work

i have sandisk cruzer 8gb

i have followed the guide from darren and just a second ago the one from windows

usb is recognized properly in windows/linux but when i plug it in pineapple, i dont know what is wrong

here is the lsusb and dmesg logs:

root@Pineapple:~# lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 002: ID 0781:5530 SanDisk Corp. Cruzer

root@Pineapple:~# dmesg |grep sda

[ 13.820000] sd 0:0:0:0: [sda] 131072 512-byte logical blocks: (67.1 MB/64.0 MiB)

[ 13.820000] sd 0:0:0:0: [sda] Write Protect is off

[ 13.830000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00

[ 13.830000] sd 0:0:0:0: [sda] No Caching mode page present

[ 13.830000] sd 0:0:0:0: [sda] Assuming drive cache: write through

[ 13.950000] sd 0:0:0:0: [sda] No Caching mode page present

[ 13.950000] sd 0:0:0:0: [sda] Assuming drive cache: write through

[ 13.960000] sda: unknown partition table

[ 13.970000] sd 0:0:0:0: [sda] No Caching mode page present

[ 13.970000] sd 0:0:0:0: [sda] Assuming drive cache: write through

[ 13.980000] sd 0:0:0:0: [sda] Attached SCSI removable disk

root@Pineapple:~#

nothing is showing up in the resources page.

anyone have something to add i should try?

i am kind of lost on what might be the problem, as everything should work. i am maybe overlooking something simple all the time

EDIT: pineapple is powered from the AC

Edited by tertko
Link to comment
Share on other sites

i cant seem to make the usb thingy work

i have sandisk cruzer 8gb

i have followed the guide from darren and just a second ago the one from windows

usb is recognized properly in windows/linux but when i plug it in pineapple, i dont know what is wrong

here is the lsusb and dmesg logs:

root@Pineapple:~# lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 001 Device 002: ID 0781:5530 SanDisk Corp. Cruzer

root@Pineapple:~# dmesg |grep sda

[ 13.820000] sd 0:0:0:0: [sda] 131072 512-byte logical blocks: (67.1 MB/64.0 MiB)

[ 13.820000] sd 0:0:0:0: [sda] Write Protect is off

[ 13.830000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00

[ 13.830000] sd 0:0:0:0: [sda] No Caching mode page present

[ 13.830000] sd 0:0:0:0: [sda] Assuming drive cache: write through

[ 13.950000] sd 0:0:0:0: [sda] No Caching mode page present

[ 13.950000] sd 0:0:0:0: [sda] Assuming drive cache: write through

[ 13.960000] sda: unknown partition table

[ 13.970000] sd 0:0:0:0: [sda] No Caching mode page present

[ 13.970000] sd 0:0:0:0: [sda] Assuming drive cache: write through

[ 13.980000] sd 0:0:0:0: [sda] Attached SCSI removable disk

root@Pineapple:~#

nothing is showing up in the resources page.

anyone have something to add i should try?

i am kind of lost on what might be the problem, as everything should work. i am maybe overlooking something simple all the time

EDIT: pineapple is powered from the AC

Okay.... to get it to work, you need to use vmware and run ubuntu.

In ubuntu partition your sandisk 80% part 1 and 20% part 2

Note: make sure you uncheck "take ownership of filesystems".(see picture)

post-40252-0-82162100-1346532223_thumb.j

Now that you partitioned your san disk with 2 partitions (80% and 20%) safely remove from computer.

Now on your pineapple, go to the UI page and go to USB. Change "option enabled 0" to "option enabled 1"

Now go to advanced and type in "mkswap /dev/sda2" into the execute commands zone. once you execute... wait a little bit and then reboot.

Should work after reboot.

Link to comment
Share on other sites

i have done this multiple times, sadly without success

going to do one more time. will edit this post once im done

EDIT2:

removed all the output and code from the post

found an old usb drive, all works properly

so i guess i should blame sandisk

it was brand new bought yesterday in bestbuy

bah, so pissed off now

old usb stick is big and awful, i liked the sandisk :(

EDIT3:

hopped over bestbuy, bought 16 GB sandisk fit and pineapple wont even recognize it

no blue led light when plugged in, just errors :

[ 136.160000] usb 1-1: new high-speed USB device number 2 using ath79-ehci

[ 151.280000] usb 1-1: device descriptor read/64, error -145

[ 155.850000] hub 1-0:1.0: unable to enumerate USB device on port 1

[ 408.910000] usb 1-1: new high-speed USB device number 3 using ath79-ehci

so yea, i guess the sandisk sux

anyone have any other suggestions which usb stick should i try to buy, but its small as the sandisk one?

thank you

Edited by tertko
Link to comment
Share on other sites

Is the USB swap supposed to take place automatically?

In other words, I was able to successfully extend memory allocation as described in the original post, however, after rebooting the device, I noticed that after issuing the "free" command, the Swap line did not show any memory. I had to issue "swapon /dev/sda2" to allocate the memory again.

Here is some background on what I did:

1. Formatted and partitioned USB Cruzer Fit 8GB drive (USB Partition 1, 6GB, and USB Partition 2, 2GB); both as described in the original post.

2. ssh into pineapple.

3. Issued mkswap /dev/sda2

4. Received "device is busy" error

5. Issued umount /dev/sda2

6. Issued mkswap /dev/sda2

7. Received a successful message like the one in the original post

8. Issued swapon /dev/sda2

9. Memory is allocated successfully in the pineapple

I had no other choice but to umount the sda2 in order to bypass the "device is busy" error

Is it possible to script-in the command swapon /dev/sda2? If so, where would you recommend inserting it? I don't plan on removing the USB from the device.

EDIT: I apologize Hak5 Admin/Mods --- I read a post above and saw the following to always allow the memory allocation:

USB --> fstab Configuration ---> config swap ---> Option Enabled 1 (default is 0)

Pineapple working like a charm!!!

Edited by 5lyfoxx
Link to comment
Share on other sites

  • 2 months later...

In testing 7 different USB thumb drives including a Sandisk cruzer fit 4gb and 8gb I found that if the pineapple's powered by a USB port on my laptop getting a USB drive to detect is very unpredictable and usually fails.

When I powered the pineapple from an AC adapter 100% of the time it recognized the USB thumb drive. I couldn't find any specs on the voltage requirements of any of the thumb drives I tested.

I'm using an HP 6550B business class laptop, also tested with a Dell and had the same results although I only tested the Sandisk cruzer thumbdrives.

Moral of the story --?> If using USB as swap/storage use a solid power source, USB power is inadequte (at least for my hardware).

Link to comment
Share on other sites

  • 1 month later...

I'm noticing that when I upgrade to 2.7.0 and run

cat /etc/opkg.conf

I do not see:

dest root /

dest ram /tmp

lists_dir ext /var/opkg-lists

option overlay_root /overlay

dest usb /usb

but rather see:

dest root /

dest ram /tmp

lists_dir ext /var/opkg-lists

option overlay_root /overlay

dest usb /home <-----------------------this is new

dest usb /usb

which should it be?

Thanks.

Link to comment
Share on other sites

In testing 7 different USB thumb drives including a Sandisk cruzer fit 4gb and 8gb I found that if the pineapple's powered by a USB port on my laptop getting a USB drive to detect is very unpredictable and usually fails.

When I powered the pineapple from an AC adapter 100% of the time it recognized the USB thumb drive. I couldn't find any specs on the voltage requirements of any of the thumb drives I tested.

I'm using an HP 6550B business class laptop, also tested with a Dell and had the same results although I only tested the Sandisk cruzer thumbdrives.

Moral of the story --?> If using USB as swap/storage use a solid power source, USB power is inadequte (at least for my hardware).

I believe that a standard USB port puts out 500millawatts of power. Wall power or USB battery is required for anything other than just the Pineapple.

Link to comment
Share on other sites

  • 2 weeks later...
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. sad.gif

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!

I got a 4GB transcend to work with little or no issue. Now most of my modules and logs are on the usb. Given its kinda protruding but it works for me. Sorry about not having the pineapple sticker, didnt get one with the holiday bundle.

Link to comment
Share on other sites

Did you partition the drive? Is the swap partition the correct partition number?

yes i did, I used another usb drive and followed the same procedure and that worked not working with sand disk cruzer.

When I ls with cruzer in /dev/ it creates sdb and sg0.

also with the other usb drive when i used the same again its not mounted, it shows sdb1 and sdb2 instead of sda1 and sda2.

Edited by jOlly
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...