Resizing partitions

LionelR

New Member
May 23, 2014
20
0
1
Hi all,
Some time ago, I've used the defaults parameters for installing a 3.0 Proxmox server on a HP server with 4*600Go DD configured with RAID 1+0. This server is for now hosting only one VM (ubuntu 12.04 + postgresql 9.1) and I need to upgrade it to ubuntu 14.04 + PG 9.3, but the upgrade process requires more disk space than availabled as pg_upgradecluster will clone a big database.
For this purpose, I want to resize the swap and the root partitions as they are too large one the proxmox server :
Code:
root@dedale:~# lvs
  LV   VG   Attr     LSize   Pool Origin Data%  Move Log Copy%  Convert
  data pve  -wi-ao-- 865.64g                                           
  root pve  -wi-ao--  96.00g                                           
  swap pve  -wi-ao-- 139.62g

Code:
root@dedale:~# df -h
Sys. fich.           Taille Util. Dispo Uti% Monté sur
udev                    10M     0   10M   0% /dev
tmpfs                   19G  336K   19G   1% /run
/dev/mapper/pve-root    95G  971M   89G   2% /
tmpfs                  5.0M     0  5.0M   0% /run/lock
tmpfs                   38G   13M   38G   1% /run/shm
/dev/mapper/pve-data   853G  493G  361G  58% /var/lib/vz
/dev/sda1              495M   34M  436M   8% /boot
/dev/fuse               30M   12K   30M   1% /etc/pve

The same problem occurs in the Ubuntu VM as the defaults install parameters set a near 200Go swap partition:
Code:
minos@icare:/$ sudo lvs
[sudo] password for minos: 
  LV     VG    Attr      LSize   Pool Origin Data%  Move Log Copy%  Convert
  root   icare -wi-ao--- 513,76g                                           
  swap_1 icare -wi-ao--- 186,00g

So, is it possible (and how) to shrink pve-root and pve-swap, says to 5Go each (if it's ok for Proxmox), and to extend pve-data accordingly and set the available space in the VM?

Thanks
 
Hi all,
Some time ago, I've used the defaults parameters for installing a 3.0 Proxmox server on a HP server with 4*600Go DD configured with RAID 1+0. This server is for now hosting only one VM (ubuntu 12.04 + postgresql 9.1) and I need to upgrade it to ubuntu 14.04 + PG 9.3, but the upgrade process requires more disk space than availabled as pg_upgradecluster will clone a big database.
For this purpose, I want to resize the swap and the root partitions as they are too large one the proxmox server :
Code:
root@dedale:~# lvs
  LV   VG   Attr     LSize   Pool Origin Data%  Move Log Copy%  Convert
  data pve  -wi-ao-- 865.64g                                           
  root pve  -wi-ao--  96.00g                                           
  swap pve  -wi-ao-- 139.62g

Code:
root@dedale:~# df -h
Sys. fich.           Taille Util. Dispo Uti% Monté sur
udev                    10M     0   10M   0% /dev
tmpfs                   19G  336K   19G   1% /run
/dev/mapper/pve-root    95G  971M   89G   2% /
tmpfs                  5.0M     0  5.0M   0% /run/lock
tmpfs                   38G   13M   38G   1% /run/shm
/dev/mapper/pve-data   853G  493G  361G  58% /var/lib/vz
/dev/sda1              495M   34M  436M   8% /boot
/dev/fuse               30M   12K   30M   1% /etc/pve

The same problem occurs in the Ubuntu VM as the defaults install parameters set a near 200Go swap partition:
Code:
minos@icare:/$ sudo lvs
[sudo] password for minos: 
  LV     VG    Attr      LSize   Pool Origin Data%  Move Log Copy%  Convert
  root   icare -wi-ao--- 513,76g                                           
  swap_1 icare -wi-ao--- 186,00g

So, is it possible (and how) to shrink pve-root and pve-swap, says to 5Go each (if it's ok for Proxmox), and to extend pve-data accordingly and set the available space in the VM?

Thanks
Hi,
resize of swap is easy, if your system has enough ram and don't use swap (If you need swap, you can assign an swapfile before you recreate an smaller swap-space).
Look with "swapon -s".
remove with something like
Code:
swapoff /dev/pve/swap
lvchange -a n /dev/pve/swap
lvremove /dev/pve/swap
lvcreate -Cy -L6G -n swap pve
mkswap -f /dev/pve/swap
swapon -a
for shrinking the root filesystem you need to boot an live-cd like grml, use commands like resize2fs and be sure to have an valid backup and that you know what you are doing!

Udo
 
Hi,
thanks for your help.
Maybe I will not try to resize the pve-root because I don't have physical access to the server (so no live-cd). If I remove/shrink the pve-swap like you say, is it possible to give the available space to pve-data without stopping the server?
 
Hi,
thanks for your help.
Maybe I will not try to resize the pve-root because I don't have physical access to the server (so no live-cd). If I remove/shrink the pve-swap like you say, is it possible to give the available space to pve-data without stopping the server?
Hi,
yes, of course.

lvextend and resize2fs are your friend! If you want to use lvm-snapshots don't use the whole free space.
Code:
man lvextend
man resize2fs
Udo
 
Hmm, trying the same process on the production server, I get a "swapoff: /dev/pve/swap: swapoff failed: cannot allocate memory". Is it safe to apply these recommandations on dropping cache as says here : http://techdire.com/swapoff-cannot-allocate-memory/ when VMs are in use?
Hi,
create an swap-file, activate them and then try to disable pve-swap again. After readd pve-swap again, you can disable the swapfile.
See "man mkswap" the section below Notes.

Udo