LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   [HELP] RHEL6.2 Resize LVM Partition (https://www.linuxquestions.org/questions/linux-newbie-8/%5Bhelp%5D-rhel6-2-resize-lvm-partition-4175439882/)

SevenDP 12-03-2012 09:22 PM

[HELP] RHEL6.2 Resize LVM Partition
 
i have running server using RHEL 6.2 64bit
but i have wrong partition

[root@mail ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_mail-lv_root
53G 12G 39G 23% /
tmpfs 4.2G 91k 4.2G 1% /dev/shm
/dev/sda1 508M 38M 444M 8% /boot
/dev/mapper/vg_mail-lv_home
675G 207M 641G 1% /home


[root@mail ~]# cat /etc/fstab
/dev/mapper/vg_mail-lv_root / ext4 defaults 1 1
UUID=7d13f9fe-4227-4c84-b57d-35b605a03df8 /boot ext4 defaults 1 2
/dev/mapper/vg_mail-lv_home /home ext4 defaults 1 2
/dev/mapper/vg_mail-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0

i wish i can make / bigger and /home smaller, or merge /home to /
so / have 53GB + 675GB

/ --- have data i do not want to lose
/home --- is empty just lost&found directory

thanks
denny

MensaWater 12-04-2012 02:52 PM

You can reduce the size of /home since it is unused and increase / on line:

***WARNING: SINCE THIS IS ROOT YOUR MUCKING WITH BE SURE YOU HAVE A GOOD BACKUP FIRST***

My notes show reduction of /home must be done offline (with filesystem unmounted)
Requires a filesystem check with e2fsck be done
Filesystem can then be reduced using resize2fs.
The LV can then be reduced using lvreduce.

df -h /home (to see current size)
umount /home
esfsck -f /dev/mapper/vg_mail-lv_home
resize2fs /dev/mapper/vg_mail-lv_home <newsize you desire>
lvreduce -L <new size you desire> /dev/mapper/vg_mail-lv_home
mount /dev/mapper/vg_mail-lv_home /home
df -h /home (should now show new size)

You can then easily extend root by running:
lvextend -L <new size you desire greater than current size> /dev/mapper/vg_mail-lv_root
resize2fs -p /dev/mapper/vg_mail-lv_root
df -h / (to verify new size)

You can get more details on size specifications and/or other options for each of the commands by typing "man <command>"

SevenDP 12-05-2012 03:31 AM

Quote:

Originally Posted by MensaWater (Post 4842759)
You can reduce the size of /home since it is unused and increase / on line:

***WARNING: SINCE THIS IS ROOT YOUR MUCKING WITH BE SURE YOU HAVE A GOOD BACKUP FIRST***

My notes show reduction of /home must be done offline (with filesystem unmounted)
Requires a filesystem check with e2fsck be done
Filesystem can then be reduced using resize2fs.
The LV can then be reduced using lvreduce.

df -h /home (to see current size)
umount /home
esfsck -f /dev/mapper/vg_mail-lv_home
resize2fs /dev/mapper/vg_mail-lv_home <newsize you desire>
lvreduce -L <new size you desire> /dev/mapper/vg_mail-lv_home
mount /dev/mapper/vg_mail-lv_home /home
df -h /home (should now show new size)

You can then easily extend root by running:
lvextend -L <new size you desire greater than current size> /dev/mapper/vg_mail-lv_root
resize2fs -p /dev/mapper/vg_mail-lv_root
df -h / (to verify new size)

You can get more details on size specifications and/or other options for each of the commands by typing "man <command>"

thanks MensaWater
i will try that after i prepare backup server this week.
this is online mail server so i have to shutdown it on holiday
and i will update this thread after that

thanks
regards
denny

MensaWater 12-05-2012 07:34 AM

The main point in my email was that you shouldn't need to shutdown to do this.

If /home is empty it likely isn't in use so can be unmounted. You can run "lsof /home" to see if anything is using it.

Since you're expanding rather than reducing root it can be done with root online.

It wasn't clear if you meant you're doing the shutdown to setup backups or not. I wouldn't think that would be necessary but I use NetBackup so maybe its different for whatever you're using.


All times are GMT -5. The time now is 06:36 AM.