0

We have a sysadmin configure a couple of servers at digitalocean. To me, it looks like swap wasn't enabled on this but it's been a VERY long time since I've had to do things like this. It's a rails app and the only reason this came up is because we were getting out of memory errors. Is a swap partition still considered a best practice for a modern (3.2.13 rails app)? I'd imagine so. Is there a simple fix to creating a swap partition from the command line (host has 2GB of RAM)? Not asking to do it but some guidance would be appreciated.

I'm fine with just upgrading to a 1GB of memory server which is only $5 / month more.

deploy@x1:~$ sudo fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track,
5221 cylinders, total 83886080 sectors Units = sectors of 1 * 512 =
512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O
size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000

Disk /dev/sda doesn't contain a valid partition table  
deploy@x1:~$ 

Alos should I be concerned about the last line regarding not containing a valid partition table?

  • 3
    If your app is running out of memory, whether you have swap or not is irrelevant, because there's a memory leak somewhere that you have to fix. – Thomas Ward Apr 10 '13 at 18:50
  • Thx, it's possible but it's at the asset pipeline phase of deployment which is a bit of a special case. Not traffic driving up regular memory usage. – timpone Apr 10 '13 at 18:52
  • Disk /dev/sda doesn't contain a valid partition table I saw this mentioned y-day too and the answer was no. – Rinzwind Apr 10 '13 at 18:52
  • Please post the "out of memory errors" as well as the output of free -m and ps aux sort of depends on what is using your memory as suggested by TLOT "doesn't contain a valid partition table" does not seem to be a problem, my guess is you are using LVM or encryption, post the output of mount. – Panther Apr 10 '13 at 18:55
  • @timpone, whether you're at the final stage of a deployment or not, a memory leak can have catastrophic consequences if it eats up all the memory. Which suggests the application is at fault. (and you should probably step back a bit and run an analysis of memory usage, because any sane application won't eat up all the memory, regardless of whether it's Ruby on Rails or not.) – Thomas Ward Apr 10 '13 at 18:57
1

You can always check if swap is enabled by running:

swapon -s

(See man swapon for details.)

This lists all swaps that are currently enabled. If you run that and get no output, swap is not enabled. Most of the time an Ubuntu system will have a single swap partition and no swap files enabled; that will look something like this:

ek@Kip:~$ swapon -s
Filename                Type        Size            Used         Priority
/dev/sda7               partition   4194300         1499712     -1

As for sudo fdisk -l telling you that Disk /dev/sda doesn't contain a valid partition table: no, that is usually not cause for concern. (In particular, it doesn't mean no swap is enabled.)

fdisk doesn't support some constructs--it will not recognize a disk that use LVM or software RAID (md) as having a valid partition table. LVM is very common on servers. When you see this warning from fdisk -l, run parted -l instead:

sudo parted -l

parted is more likely to be able to identify and report on such constructs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.