Debian DRBD: How to resize drbd volume on top of LVM

root's picture

The examples below are done on an environment where drbd volume resides on lvm logical volume and the filesystem is reiserfs.

a. If you want to shrink it, you will have to reduce first the filesystem on the primary node then the logical volume on both nodes. Afterwards you execute the resize command for drbd on primary node.
Be careful, in order to shrink the filesystem, you will have to umount it and obviously to stop the services before that (nfs, apache, etc.).

Primary node:

umount /nfs
resize_reiserfs -s5G /dev/drbd0

Both nodes:

lvresize -L5G /dev/nfsvg/nfs

Primary node:

drbdadm resize nfs

b. On grow operation, you have to increase first the logical volume on both nodes, then increase the drbd volume and filesystem on primary node.
This operation can be done while filesystem is up and running, at least with reiserfs. Regarding other filesystem types, check the documentation first.

Both nodes:

lvresize -L20G /dev/nfsvg/nfs

Primary node:

drbdadm resize nfs

Primary node:

resize_reiserfs -s20G /dev/drbd0

Below you have the output of the operations, as example, if needed.

Grow work log:

root@eave:~# lvresize -L20G /dev/nfsvg/nfs
  Extending logical volume nfs to 20.00 GiB
  Logical volume nfs successfully resized
  
root@candy:~# lvresize -L20G /dev/nfsvg/nfs
  Extending logical volume nfs to 20.00 GiB
  Logical volume nfs successfully resized

root@eave:~# fdisk -l /dev/drbd0

Disk /dev/drbd0: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 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

root@eave:~# drbdadm resize nfs
root@eave:~# cat /proc/drbd
version: 8.3.11 (api:88/proto:86-96)
srcversion: F937DCB2E5D83C6CCE4A6C9 
 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----
    ns:432764 nr:132 dw:268 dr:433428 al:7 bm:31 lo:0 pe:9 ua:1 ap:0 ep:1 wo:f oos:15297152
	[>....................] sync'ed:  2.8% (14936/15360)Mfinish: 0:10:02 speed: 25,380 (25,380) K/sec

root@eave:~# fdisk -l /dev/drbd0

Disk /dev/drbd0: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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

root@eave:~# df -h /nfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/drbd0      5.0G  1.1G  4.0G  21% /nfs
root@eave:~# resize_reiserfs /dev/drbd0
resize_reiserfs 3.6.21 (2009 www.namesys.com)



resize_reiserfs: On-line resizing finished successfully.

root@eave:~# df -h /nfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/drbd0       20G  1.1G   19G   6% /nfs

Shrink work log:

root@eave:~# umount /nfs
root@eave:~# resize_reiserfs -s5G /dev/drbd0
resize_reiserfs 3.6.21 (2009 www.namesys.com)

You are running BETA version of reiserfs shrinker.
This version is only for testing or VERY CAREFUL use.
Backup of you data is recommended.

Do you want to continue? [y/N]:y
Processing the tree: 0%....20%....40%....60%....80%....100%       left 0, 854 /sec

nodes processed (moved):
int        3 (2),
leaves     257 (239),
unfm       256000 (240640),
total      256260 (240881).

check for used blocks in truncated region

ReiserFS report:
blocksize             4096
block count           1310720 (6553600)
free blocks           1046210 (6288930)
bitmap block count    40 (200)

Syncing..done


resize_reiserfs: Resizing finished successfully.

root@eave:~# lvresize -L5G /dev/nfsvg/nfs
  WARNING: Reducing active and open logical volume to 5.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce nfs? [y/n]: y
  Reducing logical volume nfs to 5.00 GiB
  Logical volume nfs successfully resized
  
root@candy:~# lvresize -L5G /dev/nfsvg/nfs
  WARNING: Reducing active and open logical volume to 5.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce nfs? [y/n]: y
  Reducing logical volume nfs to 5.00 GiB
  Logical volume nfs successfully resized
  
root@eave:~# mount /dev/drbd0 /nfs
root@eave:~# df -h /nfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/drbd0      5.0G  1.1G  4.0G  21% /nfs

Inspiration:

http://www.drbd.org/users-guide/s-resizing.html

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root