I need to shrink /home(755G) to 150GB and use free space to add to the existing /(50G). #df -kh Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_web-lv_root 50G 7.8G 40G 17% / tmpfs 7.8G 384K 7.8G 1% /dev/shm /dev/sda2 485M 79M 381M 18% /boot /dev/sda1 200M 256K 200M 1% /boot/efi /dev/mapper/vg_web-lv_home755G 6.2G 711G 1% /home Need to have the step, can this be done online or need to go offline (umount) the file systems. Thanks
On 03/18/12 10:34 AM, madunix at gmail.com wrote:> I need to shrink /home(755G) to 150GB and use free space to add to the > existing /(50G). > #df -kh > Filesystem Size Used Avail Use% Mounted on > /dev/mapper/vg_web-lv_root 50G 7.8G 40G 17% / > tmpfs 7.8G 384K 7.8G 1% /dev/shm > /dev/sda2 485M 79M 381M 18% /boot > /dev/sda1 200M 256K 200M 1% /boot/efi > /dev/mapper/vg_web-lv_home755G 6.2G 711G 1% /home > > Need to have the step, can this be done online or need to go offline > (umount) the file systems.IMHO, the only sane way to shrink a file system is to back it up to other media, delete it, then recreate it at the new smaller size and restore the backup. my /'s are rarely bigger than 18GB, but I usually mount other file systems for stuff like /var/www, /var/pgsql-x.y/data, etc. -- john r pierce N 37, W 122 santa cruz ca mid-left coast
On 18.3.2012 18:34, madunix at gmail.com wrote:> I need to shrink /home(755G) to 150GB and use free space to add to the > existing /(50G). > #df -kh > Filesystem Size Used Avail Use% Mounted on > /dev/mapper/vg_web-lv_root 50G 7.8G 40G 17% / > tmpfs 7.8G 384K 7.8G 1% /dev/shm > /dev/sda2 485M 79M 381M 18% /boot > /dev/sda1 200M 256K 200M 1% /boot/efi > /dev/mapper/vg_web-lv_home755G 6.2G 711G 1% /home > > Need to have the step, can this be done online or need to go offline > (umount) the file systems.What filesystem? Assuming ext3, this cannot shrunk without unmounting. I believe the following *should* work for ext3 $ umount /home $ e2fsck -f /dev/vg_web/lv_home $ resize2fs /dev/vg_web/lv_home 150g $ lvresize -L 150g /dev/vg_web/lv_home $ mount /home I am not sure how safe it is. Take care! -- Kind Regards, Markus Falb -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 307 bytes Desc: OpenPGP digital signature URL: <http://lists.centos.org/pipermail/centos/attachments/20120318/d5c59ffd/attachment-0004.sig>
On Sun, Mar 18, 2012 at 08:04:14PM +0100, Markus Falb wrote:> On 18.3.2012 18:34, madunix at gmail.com wrote: > > I need to shrink /home(755G) to 150GB and use free space to add to the > > existing /(50G). > > #df -kh > > Filesystem Size Used Avail Use% Mounted on > > /dev/mapper/vg_web-lv_root 50G 7.8G 40G 17% / > > tmpfs 7.8G 384K 7.8G 1% /dev/shm > > /dev/sda2 485M 79M 381M 18% /boot > > /dev/sda1 200M 256K 200M 1% /boot/efi > > /dev/mapper/vg_web-lv_home755G 6.2G 711G 1% /home > > > > Need to have the step, can this be done online or need to go offline > > (umount) the file systems. > > What filesystem? Assuming ext3, this cannot shrunk without unmounting. > I believe the following *should* work for ext3 > > $ umount /home > $ e2fsck -f /dev/vg_web/lv_home > $ resize2fs /dev/vg_web/lv_home 150g > $ lvresize -L 150g /dev/vg_web/lv_home > $ mount /home > > I am not sure how safe it is. Take care!I was under the impression that you needed to unmount the file system to shrink it with resize2fs (you can grow it online however). Ray
On 03/18/2012 10:34 AM, madunix at gmail.com wrote:> I need to shrink /home(755G) to 150GB and use free space to add to the > existing /(50G)....> Need to have the step, can this be done online or need to go offline > (umount) the file systems.To shink an ext3 filesystem, it'll have to be offline. Start by identifying and terminating any applications with files open on /home using "fuser -vm /home/". Once there are no open files, you can unmount the filesystem and use "fsadm resize /dev/mapper/vg_web-lv_home755G 150G" to shrink the filesystem.