Nick's picture

Hi, running Postgres appliance, and i cant seem to figure out what the swap partition is, and thus how to increase its size.  I created this from the vmdk file (the ovf did not work, import error).

Forum: 
Jeremy Davis's picture

Try checking what disks are attached

fdisk -l

I haven't got a TKL machine handy just at the moment, but that will give you a starting point. TKL v11.x uses LVM by default so the easiest way to extend the FS is to add an extra vmdk and extend the volume. But I'm not sure how that applies to swap space though? For details on working with LVM in TKL there is a great blog post here.

Nick's picture

root@postgresql ~# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
4 heads, 32 sectors/track, 327680 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003402b

Device Boot Start End Blocks Id System
/dev/sda1 * 1 7813 500000 83 Linux
/dev/sda2 7825 305168 19030016 8e Linux LVM

 

root@postgresql ~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/turnkey-root
                       17G  7.1G  8.8G  45% /
none                  246M  172K  246M   1% /dev
none                  249M     0  249M   0% /dev/shm
none                  249M   64K  249M   1% /var/run
none                  249M     0  249M   0% /var/lock
none                  249M     0  249M   0% /lib/init/rw
/dev/sda1             473M   24M  425M   6% /boot
 
Jeremy Davis's picture

So the swap partition is a logical volume (LV). You can check the LVs with the lvscan command. Here's what mine looks like:

lvscan
  ACTIVE            '/dev/turnkey/root' [27.36 GiB] inherit
  ACTIVE            '/dev/turnkey/swap_1' [1.22 GiB] inherit

I'm using a 32GB virtual HDD - by default TKL uses 90% of the physical volume (PV - ie the hard drive) for the volume group (VG - where the LVs reside). You can check how much empty space there is in the volume group (VG) using the vgdisplay command. Here's mine:

vgdisplay
  --- Volume group ---
  VG Name               turnkey
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               31.76 GiB
  PE Size               4.00 MiB
  Total PE              8130
  Alloc PE / Size       7316 / 28.58 GiB
  Free  PE / Size       814 / 3.18 GiB
  VG UUID               BczuJ9-41RQ-xnI1-vztx-k9xM-boII-6UYiZx

So I have 3.18GB free. Yours will differ obviously. You could just use the available free space, but personally I'd be inclined to add a new virtual HDD (vmdk) - or extend the current one. Obviously you'll have to if it doesn't have as much extra room as you'd want to add.

I have only ever made a new virtual HDD (vmdk) and added it so thats what my instructions will be, if you want to extend your original vmdk you'll need to do a bit of research.

Make a new vmdk as big as you'd like (using your VM app). If you think you'll want more space for your appliance itself you can include that in the total (one single vmdk is fine - you don't need a separate one for swap). Once you have it attached (using your VM app interface - may require a reboot) then you can add it as a physical volume (PV) and extend your volume group (VG). Check that it is recognised by the system and the name of it with fdisk -l . Assuming it is /dev/sdb then add it as a PV and extend the VG like this:

pvcreate /dev/sdb
vgextend turnkey /dev/sdb

To check on your PVs you can use the pvscan command. More detailed info is available with the pvdisplay command. You can also check that your VG has been extended now using the vgdisplay command again.

Now you need to extend the LV. Assuming your swap is called 'swap_1' (as displayed by lvscan) and you want to add 2GB to it use something like this:

lvextend -L+2G /dev/turnkey/swap_1

And then extend the filesystem (I haven't done this with a swap partition so hope this works!):

resize2fs /dev/turnkey/swap_1

Hopefully all that worked and you now have a bigger swap. Check with lvscan. Let me know how you go.

Nick's picture

Jeremy-

Thanks for the clearly written suggestion.  I plan to attempt an lvreduce /dev/turnkey/root so i can lvextend /dev/turnkey/swap_1

Now that I know the commands to check this (thanks!) i will also try increasing the ram on the VM.

For those who may be interested or already know the answered: I am trying to get pgRouting installed and to work with osm data.  I am following the workshop from the pgrouting.org site, and there was a mention somewhere that the osm2pgrouting application doesn't handle large datasets and gets messed up if the ram and swap are not large enough.  I have no idea if this going to work, but at least i have learned some new linux commands!

I'll post back my results, good or bad.

Jeremy Davis's picture

I haven't personally used lvreduce but I would assume that it should work in a similar manner to lvextend. Also if you're new to Linux remember that detailed info about commands can (usually) be accessed via the man command. eg man lvreduce

It'll be great to hear how you go and even if you are unsuccessful we'll all learn something (at least you and I will!)

As for installing pgRouting, just in case you don't know, TKL is based on Ubuntu 10.04/Lucid which may make it easier to find clear and specific instructions. Although there are some TKL specifics such as sudo is not installed by default (as you may have already dicovered) and as default login is root, it is not required (and can just be removed from any instructions that use it).

Also, as a suggestion; for clarity and relevance for other users perhaps start a new thread for pgRounting specific stuff (I'll see it regardless). If you're successful, just post in 'General' or if having issues 'Support' is fine, otherwise post back here regarding LVM/swap stuff.

Good luck!

Nick's picture

Tried lvextend -L+512 /dev/turnkey/swap_1:

Extending logical volume swap_1 to 1.00 GiB
  Logical volume swap_1 successfully resized

Tried resize2fs... results:

resize2fs 1.41.11 (14-Mar-2010)
resize2fs: Bad magic number in super-block while trying to open /dev/turnkey/swap_1
Couldn't find valid filesystem superblock.

Not sure if i needed to run it, lvscan shows swap_1 as increased to 1.00 GiB

I have rebuilt the VM with 4 CPUs and 2 GiB RAM instead of the defaults of 1 CPU and 256 MB RAM.  Hopefully the 1.00 GiB swap will be enough.

Side note:  I tried to change my original VM from 1 CPU to 4 and increased the RAM, but after one successful startup, then next reboot got me the inframfs or whatever that prompt is, thus the "do over"

Jeremy Davis's picture

I'm not sure with swap (I've never extended a swap partition). I know with other FS types you need to run that command to get the underlaying filesystem to fill the LV (otherwise it still reports it as the original size). Perhaps swap is different somehow (well I guess obviously it is as resize2fs doesn't even see an FS). I guess if it doesn't work as expected, perhaps google has some suggestions?

Add new comment