Resize (extend) disk on Linux (Rackspace)

with No Comments

Problem

At some point I have to clone Volume on Rackspace with bigger size. Need to resize disk now carefully to not lost old data and encrease partition.

Solution

Disk is used by MongoDB, so appropriate commands also exist

service mongod stop

df -h

umount /dev/xvdc1

(detaching disc from Rackspace UI)

(attaching new disc from Rackspace UI)

fdisk -l

fdisk /dev/xvdb

(first delete existing partition: d, p, w)

(then add new partition: n, 1, p, w - http://geekpeek.net/resize-filesystem-fdisk-resize2fs/)

e2fsck -f /dev/xvdb1

resize2fs /dev/xvdb1

mount /dev/xvdb1 /mongodb

df -h


service mongod start

Congrats!

Leave a Reply