0

TL;DR: How to combine RAID + LVM partitions online (not touching rootfs)?

I have a server which was used for something else before and had a certain partition structure create. df -h shows

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/raid1-rootfs
                       50G   28G   20G  59% /
tmpfs                  16G     0   16G   0% /lib/init/rw
udev                   16G  152K   16G   1% /dev
tmpfs                  16G  624K   16G   1% /dev/shm
/dev/md0              460M   29M  408M   7% /boot
/dev/mapper/raid1-data
                       99G   20G   74G  22% /data
/dev/mapper/raid1-mysql
                       99G  4.6G   89G   5% /data/mysql
/dev/mapper/raid1-backup
                       99G  664M   93G   1% /data/backup
/dev/mapper/raid1-activemq
                       99G  188M   94G   1% /data/activemq
/dev/mapper/raid1-backups
                      1.0T  651G  373G  64% /backup

Basically I do not need the different /data partitions anymore. I mainly need if to store backups in the last partition mounted at /backup.

In order to have more disk space there I would like to add the 4*99G of the partitions above it to /backup. It would also be fine to combine them in a separate partition, I could mount some sub-dir to it then.

The disk is mirrored and has LVM apparently.

I am a bit lost on how to do it, I would like to be able to do it online, I do not have physical access.

Can you explain or guide me how this can be achieved?

PS:

fdisk -l tells me:

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted

lvdisplay output:

  --- Logical volume ---
  LV Name                /dev/raid1/swap
  VG Name                raid1
  LV UUID                gOtYhu-oORL-JZRy-inlb-hlyn-0qGU-SBxYo3
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                4.00 GiB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/raid1/rootfs
  VG Name                raid1
  LV UUID                Y3np5X-IyEn-WMGW-2t51-LIiX-9I8z-rnBXZp
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/raid1/activemq
  VG Name                raid1
  LV UUID                0mGA9R-wi89-adqN-oI2x-W24j-2qzD-pXJdNA
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/raid1/mysql
  VG Name                raid1
  LV UUID                D5dD6A-1TDZ-fKsO-pc1u-Xttm-Wb2K-RjqAJw
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Logical volume ---
  LV Name                /dev/raid1/backup
  VG Name                raid1
  LV UUID                Brfzgy-nDWG-xyAD-b2a5-sTWf-T7hX-jZRiji
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

  --- Logical volume ---
  LV Name                /dev/raid1/data
  VG Name                raid1
  LV UUID                JmF16w-jLJz-V3Is-WeTb-K0Qn-uG21-WhLWJY
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:6

  --- Logical volume ---
  LV Name                /dev/raid1/storage
  VG Name                raid1
  LV UUID                0qRsZl-Kbix-6dhc-g7UD-xJuG-tK3t-zP04fd
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                25.00 GiB
  Current LE             6400
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:7

  --- Logical volume ---
  LV Name                /dev/raid1/backups
  VG Name                raid1
  LV UUID                g3VgO6-QkEv-KlD4-Wo7N-0cvn-Aolg-1hz1P1
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.00 TiB
  Current LE             262144
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:8

Note that there is one partition which is excluded from the output and is not relevant for this operation.

  • Add the output of lvdisplay to your question. – wurtel Nov 12 '15 at 12:57
  • Added the output – Luksurious Nov 12 '15 at 13:31
1

First ensure you don't need the data stored on the /data filesystems any more (make a backup or copy elsewhere if you do). make sure no processes are using files on those filesystems (lsof -n | grep /data).

unmount the filesystems:

# umount /dev/mapper/raid1-backups
# umount /dev/mapper/raid1-activemq
# umount /dev/mapper/raid1-backup
# umount /dev/mapper/raid1-mysql
# umount /dev/mapper/raid1-data

If any of these umounts fail, check again whether any processes are using the filesystems. Make sure you umount /dev/mapper/raid1-data last, as the others are mounted on top of that filesystem.

Don't forget to modify /etc/fstab to remove the lines for these filesystems.

Now these logical volumes aren't needed anymore, you can delete them:

# lvremove raid1/data
# lvremove raid1/mysql
# lvremove raid1/backup
# lvremove raid1/activemq

Take care with raid1/backup, you also have a raid1/backups that you want to keep!

Note you also have a raid1/storage listed in your lvdisplay output which apparently isn't mounted. Check whether that logical volume is needed and if not, you can remove that one as well.

Now the space that was allocated to those logical volumes has been returned as available to the volume group (you can check with vgdisplay raid1). You can now grow the "backups" logical volume:

# lvresize --resizefs --size +XXX raid1/backups

Replace the XXX with the free size you see in the vgdisplay output; e.g. use --size +500G if 500 GiB is shown.

The --resizefs tells lvresize to modify the filesystem together with the logical volume; it uses the fsadm command to do that. This should work on ext2, ext3, ext4, reiserfs and xfs filesystems. At least the ext3 and ext4 filesystems should be resizable while mounted (I'm not sure about the rest).

  • Thank you, I got to the point where the disk space is shown as free. However, when I try to run lvresize I get: xfs_check: /dev/dm-8 contains a mounted and writable filesystem fatal error -- couldn't initialize XFS library fsadm failed: 1 Do you know what to do about this? – Luksurious Nov 17 '15 at 13:24
  • Executing the resize command without the --resizefs option worked. After some searching I found the command xfs_growfs /dev/mapper/raid1-backups which looks like resized the filesystem correctly. – Luksurious Nov 17 '15 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.