Skip to content

Instantly share code, notes, and snippets.

@daffodilistic
Last active September 22, 2021 03:52
Show Gist options
  • Save daffodilistic/335c53a16baf7d099cd5c5810f6e72f4 to your computer and use it in GitHub Desktop.
Save daffodilistic/335c53a16baf7d099cd5c5810f6e72f4 to your computer and use it in GitHub Desktop.
Shrink an LVM Volume Online on Synology NAS Devices

Scenario

Synology DS418 on v6.2.4-25556 does not allow shrinking of volumes via the GUI. Thus, this must be done via an SSH terminal. This gist is written as generically as possible so that it works for the general use-case of shrinking volumes formatted with the BTRFS filesystem, and then expanding another one. For this scenario, it's a volume that's being used for Time Machine.

Instructions

  1. SSH into the Synology NAS and switch to root account with sudo su.
  2. Run btrfs filesystem show to list the volumes:
root@SynologyNAS:~# btrfs filesystem show
Label: '2020.06.09-05:33:16 v25426'  uuid: c69b942c-758a-4d20-95cb-04d8bf6719fa
	Total devices 1 FS bytes used 648.00KiB
	devid    1 size 10.00GiB used 1.56GiB path /dev/mapper/vg1-volume_9

Label: '2020.06.08-05:31:35 v25426'  uuid: dbdd644f-e3cf-4139-9d2b-179a93f5db52
	Total devices 1 FS bytes used 1.45GiB
	devid    1 size 1000.00GiB used 8.06GiB path /dev/mapper/vg1-volume_3

Label: '2020.06.08-05:36:55 v25426'  uuid: 0a1098b5-e470-467d-995c-953fd51939da
	Total devices 1 FS bytes used 405.01MiB
	devid    1 size 100.00GiB used 4.06GiB path /dev/mapper/vg1-volume_7

Label: '2020.06.08-05:33:46 v25426'  uuid: 72feff40-2ad7-4904-b651-e8db140e4f94
	Total devices 1 FS bytes used 1.71GiB
	devid    1 size 1000.00GiB used 5.06GiB path /dev/mapper/vg1-volume_6

Label: '2020.06.08-05:31:01 v25426'  uuid: db613d96-cd89-4112-ba8a-7844bfbb5b57
	Total devices 1 FS bytes used 36.82GiB
	devid    1 size 2.93TiB used 63.02GiB path /dev/mapper/vg1-volume_2

Label: '2020.06.08-05:32:53 v25426'  uuid: fe6c1721-a942-4a6a-bd15-fa33ddced816
	Total devices 1 FS bytes used 408.32MiB
	devid    1 size 500.00GiB used 7.06GiB path /dev/mapper/vg1-volume_5

Label: '2020.10.23-02:38:55 v25426'  uuid: 8319d6ac-e3f8-4ef7-b4c2-289a7c1037ce
	Total devices 1 FS bytes used 510.88MiB
	devid    1 size 500.00GiB used 4.02GiB path /dev/mapper/vg1-volume_12

Label: '2020.06.08-05:32:32 v25426'  uuid: 6bafc65c-dc81-42fa-95be-9d07b7d220ad
	Total devices 1 FS bytes used 11.05GiB
	devid    1 size 500.00GiB used 43.06GiB path /dev/mapper/vg1-volume_4

Label: '2020.08.12-03:55:15 v25426'  uuid: 7b52e05b-f1ae-48d8-8495-4bd899af933c
	Total devices 1 FS bytes used 26.87GiB
	devid    1 size 1000.00GiB used 35.02GiB path /dev/mapper/vg1-volume_10

Label: '2020.06.08-08:26:02 v25426'  uuid: fd745ce3-ac3a-40b9-aa99-33e22b844c4e
	Total devices 1 FS bytes used 100.18GiB
	devid    1 size 500.00GiB used 186.06GiB path /dev/mapper/vg1-volume_8

Label: '2020.06.09-05:46:50 v25426'  uuid: b14f81fb-611d-4396-82bf-e4be374d1d44
	Total devices 1 FS bytes used 5.60TiB
	devid    1 size 5.86TiB used 5.86TiB path /dev/mapper/vg1-volume_1

Label: '2021.02.23-06:35:24 v25426'  uuid: 1fcacf6b-8404-46be-a410-9f20bbcc638c
	Total devices 1 FS bytes used 93.09MiB
	devid    1 size 100.00GiB used 3.02GiB path /dev/mapper/vg1-volume_11
  1. Start resizing the filesystem first with btrfs filesystem resize 15G /volume12 Do not panic if it takes a while, as the files are being moved around on the disk
  2. Now resize the volume with lvm lvreduce -L 15G /dev/vg1/volume_12
root@SynologyNAS:~# lvm lvreduce -L 15G /dev/vg1/volume_12
  WARNING: Reducing active and open logical volume to 15.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce volume_12? [y/n]: y
  1. Open the Storage Manager app in the Synology NAS web interface to verify that the volumes are resized. Resize the Time Machine volume via Action -> Configure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment