Possible to create swap partition on cache disk? [Solved]


Recommended Posts

Hi Folks,

 

As the title says, I was wondering if it's possible to create a swap partition on the same disk as the cache?  I know it's possible to create a swap file on the cache, but I'd prefer a dedicated swap partiton to alleviate the issues of stopping swap ahead of stopping the array.

 

I could install a drive outside of the array, but to me that's overkill as I don't currently have much use for data space outside of the array and cache disk already in use, so any disk would be for swap only.  That being said, if there's no other way to have cache and swap co-exist, then I'd rather know this so I can get an SSD for outside of the array and move all of my application 'service' stuff from cache to it.

 

But before I go down that road I thought I'd try to use the cache.  I've manually created swap & reiserfs partitions (with cfdisk), but when I then assign the disk as cache in the unRAID page and start the array, it shows as unformatted, whereby formatting blats the whole thing.  Is there some way to prevent this?  I'm also quietly wondering if there's any logic to having a swap partition on the cache as perhaps that's just as bad as having a swapfile on it instead.

 

Bit of a dillemma as to whether I even need swap.  I've got 4GB in my machine and by the looks of it the system is boarderline where low memory is concerned.  As a test, I setup swap on a drive outside the array and 12hrs on it's used approximately 5mb of swap...

root@Eddie:~# free -l
             total       used       free     shared    buffers     cached
Mem:       3888660    3220280     668380          0     441076    2152448
Low:        870348     787768      82580
High:      3018312    2432512     585800
-/+ buffers/cache:     626756    3261904
Swap:      7903944       5420    7898524

 

 

 

 

Regards,

overbyrn

Link to comment

As far as I know, it should be possible, but some versions of unRAID did not permit it.  (they considered the non-standard partitioning as not unRAID)

 

The "cache" partition MUST be partition 1.  And... I think it must already have a reiserfs file system on it.  Otherwise, the disk will be re-partitioned.  You can use

mkreiserfs /dev/sdX1

to create the file system.  (make sure you have the correct disk device and make sure you create the file system on the first partition.... the one with the device name with a trailing "1")

 

The swap partition (and any others) can be partition 2,3 4

 

A swap partition (of its own) will not prevent the server from un-mounting its disks, unlike a swap-file on the cache drive.

 

What version of unRAID are you running?

 

Joe L.

Link to comment

Thanks Joe. 

 

Fixed it by revisiting my original steps.  Documented below in case it helps anyone else.

 

I was sure I'd tried putting the swap at the beginning and at the end of the disk prior to re-adding as cache disk in UnRAID, but I must have been mistaken. 

 

Steps taken were;

 

[*]Stopped array

[*]Made note of device id which was my cache disk.  In UnRAID array listing, for me this showed as "sdd".  eg. /dev/sdd.  It should go without saying this is specific to my setup and very likely will not be the same for others.

[*]Removed cache from array

[*]From command line: "cfdisk /dev/sdd"

[*]Deleted existing ReiserFS partition (which was the cache partition)

[*]Created new (primary) partition for use as cache, less the amount I wanted to give over to swap.  Selected to locate it at end of disk.  Left as filesystem type Linux.  This created /dev/sdd1

[*]Created new primary partition for use as swap.  Selected remainder of available space and to locate at end of disk.  This created /dev/sdd2

[*]From menu, selected "Type" and chose 82 (swap) for filesystem type

[*]From menu, selected Write, "yes" to confirm and exited cfdisk

[*]From command line created ReiserFS filesystem: "mkreiserfs /dev/sdd1"

[*]From command line created swap filesystem: "mkswap /dev/sdd2"

[*]From unRAID webgui, re-added disk into cache line

[*]Started Array.  Array started and disk was mounted.  No requirement to format was needed and I could see the disk space reported was showing the available free space less that I had assigned to swap partition

[*]From command line, enabled swap: "swapon /dev/sdd2

[*]From command line, checked swap was mounted: "free -k"

 

I'll probably add the swapon into my go file at some point, but for the moment I'll continue to run it by hand should a reboot be necessary.

 

As you say, the important point to remember is that the cache partition must be the FIRST partition on the disk.  eg. /dev/sd{x}1

 

 

Link to comment
  • 2 weeks later...

My cache drive has a lot of apps on it already.

 

Would it be possible to boot GParted Live and use that to shrink the cache partion and create the Linux swap partition after the cache partition? Or would that break something in unRAID?

 

If this would work then I could just powerdown, boot GParted Live and after the repartitioning was finished, just reboot unRAID and be back where I was with all my cache data intact.

 

Anybody know of some reason this wouldn't work?

 

 

Link to comment

My cache drive has a lot of apps on it already.

 

Would it be possible to boot GParted Live and use that to shrink the cache partion and create the Linux swap partition after the cache partition? Or would that break something in unRAID?

 

If this would work then I could just powerdown, boot GParted Live and after the repartitioning was finished, just reboot unRAID and be back where I was with all my cache data intact.

 

Anybody know of some reason this wouldn't work?

 

 

It'd likely be easier and quicker to just move it to an array disk and then move it back.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.