-1

I have to increase an lvm partition, then the fact is this I have an lvm centos with 3 file systems (you see them in the image) then the first one is /dev/mapper/centos-root which is what I should increase while /dev/mapper/centos-home which is what I should reduce to assign the spation to /dev/mapper/ centos-root! The problem is that when I resize / dev/mapper/centos-home with lvmresize and reboot the machine the filesystem gets damaged and it will not let me start the machine anymore! How can I solve this? in the picture!

Image of filesystem

HBruijn
  • 77,029
  • 24
  • 135
  • 201
riki
  • 103
  • 4
  • Welcome and thank you for posting. Getting good answers requires a clear and useful question which is [well written](http://meta.serverfault.com/a/3609/37681) , [on-topic](http://serverfault.com/help/on-topic) and contains sufficient details (i.e. your exact commands, the exact error messages) to provide you with a good solution. - Please improve your question to address those points or run the risk of leaving your problem unresolved and your question closed. – HBruijn Apr 18 '18 at 11:14
  • In general you need to first shrink a file-system before you can reduce the underlying LVM volume and not every file-system supports (online) shrinking (very well) – HBruijn Apr 18 '18 at 11:17
  • @HBruijn How can I do this? – riki Apr 18 '18 at 11:26

1 Answers1

3

If your file-system is supported you can use the -r, --resizefs flag for the lvresize command to (online) reduce or grow the file-system when you change the LVM size.

In general start by making a backup of your data. Since your /home is tiny that is not an issue:

tar -Pcvf /boot/home.tar /home

I only ever grow file-systems so I don't know if the following step is needed, so as a precaution:

umount /home

and if the file-system is supported you may be able to reduce the size of /home by 50 GB without losing any data:

lvreduce --resizefs -L -50G /dev/mapper/centos-home 

If that is successfull you can remount /home, remove the backup and then assign the newly available 50GB of free space to your root file system

lvresize -L +50G --resizefs /dev/mapper/centos-root

Since your /home is nearly empty if you can't shrink the file-system safely you can still just be destructive and then create a new file system and restore your data.

umount /home
lvreduce -L -50G /dev/mapper/centos-home
# Depending on the file-system of your choice and your /etc/fstab entry
mkfs.ext4 /dev/mapper/centos-home
mount /home 
tar -Pxvf /boot/home.tar
HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • lvreduce --resizefs -L -50G /dev/mapper/centos-home not works – riki Apr 18 '18 at 12:34
  • *"it doesn't work"* by itself is not a very useful statement. If you want to learn and resolve issues, you might want to think about (and post) the error message you got. – HBruijn Apr 18 '18 at 12:40
  • you are right, this is message: fsadm: Xfs filesystem shrinking is unsupported. /usr/sbin/fsadm failed: 1 Filesystem resize failed. – riki Apr 18 '18 at 12:42
  • 1
    **XFS is a file system that you can not shrink, it only supports growing the file-system to a larger size.** - I already included a suggestion in my answer on how to deal with that scenario, (i.e. omit the `--resizefs` option which **destroys the file-system** meaning you need to re-create it and **restore your data from backup**) and then rather than mkfs.ext4 you use to mkfs.xfs to – HBruijn Apr 18 '18 at 13:20