Swap File on NTFS USB External Hard Drive with udevil

This forum is for Marvell Kirkwood devices such as the GoFlex Home/Net, PogoPlug v1/v2, SheevaPlug, and ZyXEL devices.

Swap File on NTFS USB External Hard Drive with udevil

Postby bolingj » Sat May 11, 2013 4:30 am

Hello,

I am trying to create and use a swap file on my external USB hard drive that is NTFS formatted. I use udevil to automount the drive. I am able to create and use the swap file by these instructions. My drive is mounted at /media/Bear.

$this->bbcode_second_pass_code('', 'dd if=/dev/zero of=/media/Bear/swapfile.img bs=1M count=1024
mkswap /media/Bear swapfile.img')

I can turn it on with

$this->bbcode_second_pass_code('', 'swapon /media/Bear/swapfile.img')

I check it with the command

$this->bbcode_second_pass_code('', 'free')

and everything looks great.

However, I can't get it to automatically turn on after reboot. I added the following information to /etc/fstab

$this->bbcode_second_pass_code('', '/media/Bear/swapfile.img none swap sw 0 0')

Can anybody help me get this working automatically after reboot?

Thanks!
bolingj
 
Posts: 8
Joined: Wed Feb 13, 2013 10:59 am

Re: Swap File on NTFS USB External Hard Drive with udevil

Postby moonman » Sat May 11, 2013 6:32 am

fstab is used at an earlier stage than udevil. So the system is trying to find the file on a not yet mounted drive and fails. Add the drive to fstab as well.

Swap file on an ntfs drive = really bad idea. NTFS-3G is really slow uses a lot of CPU time.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3387
Joined: Sat Jan 15, 2011 3:36 am

Re: Swap File on NTFS USB External Hard Drive with udevil

Postby bolingj » Sat May 11, 2013 7:45 am

Thanks for your help.

2 more questions then.

1, if I continue to use the NTFS drive as is, how do I add it to fstab specifically. I am still a bit of a noob at this. I have tried a couple of times tonight, but keep messing it up. After I make changes to fstab, ALARM fails to boot and I can't SSH into it. I end up having to reformat the drive and start all over again.

2, what would be a better solution than what I have now. I want my external drive to be able to be used on my Windows systems as well, which is why I formatted it in NTFS. It is a 3 TB drive with over a 1 TB of data already on it. Again, a bit of a noob on this, but I don't know how to re-partition a drive with data already on it in ALARM.

Any more help would be greatly appreciated.

Thanks!
bolingj
 
Posts: 8
Joined: Wed Feb 13, 2013 10:59 am

Re: Swap File on NTFS USB External Hard Drive with udevil

Postby moonman » Sat May 11, 2013 8:08 am

you have to make sure the options in fstab are right. First mount it from the terminal to make sure all the options are right.

I think the best solution is to create a second swap partition about 1gb or less (it may be overkill but who cares on a 3tb drive) and use the partition for swap. You can use something like partition wizard home to shrink ntfs partition under windows, then use linux to create a swap partition in the freed up space
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3387
Joined: Sat Jan 15, 2011 3:36 am

Re: Swap File on NTFS USB External Hard Drive with udevil

Postby bolingj » Sat May 11, 2013 8:18 am

Ok, I can handle shrinking the partition in windows, however, are there any step by step guides available for exactly what information is needed for mounting and placing that information into fstab? Furthermore, for also creating that partition and making it active automatically? I have been using these guides found here so far.

http://obihoernchen.net/wordpress/770/p ... rch_linux/

http://blog.qnology.com/2013/03/tutoria ... linux.html

Thanks!
bolingj
 
Posts: 8
Joined: Wed Feb 13, 2013 10:59 am

Re: Swap File on NTFS USB External Hard Drive with udevil

Postby grayman4hire » Sat May 11, 2013 2:23 pm

You should seriously reconsider using NTFS. With a gigabit network and ext3/4, Samba speed goes up to 28MB, which is around the bottleneck of USB 2.0. Yeah, it would be nice to plug the USB drive into a windows computer occasionally, but I'm not sure it's worth the hassle (don't forgot you need to properly powerdown the pogoplug also). Not to mention now you need to repartition your drive to add swap.

Like moonman pointed out, you need to use fstab to mount your NTFS partition versus udevil if you also want to mount a swap file/partition. I ran into the exact same issue when I was experimenting with udevil, which is why I left it out of my tutorial.
grayman4hire
 
Posts: 350
Joined: Sat Sep 29, 2012 12:03 am
Location: SF, CA

Re: Swap File on NTFS USB External Hard Drive with udevil

Postby moonman » Sun May 12, 2013 2:29 am

The problem is that if you add the ntfs drive to fstab, the system will fail to boot without it. Same probably goes with the swap in fstab. I would recommend creating a swap partition (use any linux live cd to create it), then create a systemd service that runs a bash script with something like this in it:

$this->bbcode_second_pass_code('', '#!/bin/bash
swapon /dev/sdb3')

Use this to write a systemd service: https://wiki.archlinux.org/index.php/Sy ... vice_files, use simple or oneshot for type type.

Now if the service fails your system will still boot.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3387
Joined: Sat Jan 15, 2011 3:36 am



Return to Marvell Kirkwood

Who is online

Users browsing this forum: No registered users and 4 guests