Expanding A Root-FS - Page 2

Want to support HowtoForge? Become a subscriber!
 
Submitted by gbi (Contact Author) (Forums) on Fri, 2009-11-27 17:22. ::

* Now you have to find the devices which represent the root filesystem and the new partion/disk. You can inspect the startup messages of SysRescCD and try to find out the right devices by doing a

dmesg | less

Look for devices with hd or sd in it's name. You could also do a

fdisk -l /dev/device

to show the partition table of the device you have guessed. It's also a good point in time to look for all other infos you need later, namely Volume Groups in /dev, Logical Volumes in /dev/VolGroup*, and perhaps make a drawing with all involved components. Next following a short look into /dev/mapper and /dev/VolGroup00:

[root@localhost dev]# ll mapper/
total 0
crw------- 1 root root  10, 63 Nov  4 20:04 control
brw-rw---- 1 root disk 253,  0 Nov  4 20:05 VolGroup00-LogVol00
brw-rw---- 1 root disk 253,  1 Nov  4 20:04 VolGroup00-LogVol01
[root@localhost dev]# ll VolGroup00/
total 0
lrwxrwxrwx 1 root root 31 Nov  4 20:04 LogVol00 -> /dev/mapper/VolGroup00-LogVol00
lrwxrwxrwx 1 root root 31 Nov  4 20:04 LogVol01 -> /dev/mapper/VolGroup00-LogVol01
[root@localhost dev]# 

* Now partition the new disk, and create a new logical drive (or primary partition, as you like) and make the ID of the partition 0x8e (as we already have LVM on the root filesystem). This could be done with "fdisk", "cfdisk" or (when X11 is running) much more comfortable with "gparted". Assume the new partition is /dev/sda3.

* Next create a new physical volume on the partition by doing a

pvcreate --test -v /dev/sda3

Leave away the --test, when everything looks good.

* Do a

ll /dev/VolGroup*

and look which is the Volume Group representing your root filesystem by doing a

vgdisplay -v VolGroup00 | less

* Extend this Volume Group by doing a

vgextend --test -v VolGroup00 /dev/sda3

and check whether this is ok by doing a

vgdisplay -v VolGroup00 | less

* If everything is ok there should be an amount of free PhysikalExtents, that could all (or partially) be added to the Logical Volume. Do this by performing

lvextend --test -v -l +PhysikalExtents /dev/VolGroup00/LogVol00

again do a check by

vgdisplay -v VolGroup00 | less

* Next you can do a

lvscan -v

to do a further check, and do a

mkdir /mnt/newvol && mount -o ro /dev/VolGroup/LogVol00

* If you can see the content of the root filesystem, all is ok so far, and you can expand the filesystem itself. This is done by performing an

e2fsck -f /dev/VolGroup/LogVol00 && resize2fs -p /dev/VolGroup/LogVol00

This may take some time, depending on the size of your filesystem.

* Now do another

mount -o ro /dev/VolGroup/LogVol00

and you should see your expanded root filesystem.

* Now you can do a

reboot

followed by a

disk1

on the SystemRescueCD boot prompt (if you forgot to change the boot order in the VMware BIOS). Pray to the lord that all works well. Otherwise chances are high, that you have to do a complete reinstall.

 

Links

http://www.sysresccd.org

http://www.centos.org

http://sources.redhat.com/lvm2/

http://grml.org/

http://www.knoppix.net/

http://www.damnsmalllinux.org/

http://www.howtoforge.com/partitioning_with_gparted

http://www.howtoforge.com/linux_lvm

http://www.howtoforge.com/linux_resizing_ext3_partitions


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Mon, 2009-11-30 10:06.

It might be worth pointing out that all the tasks done above can be done online, without rebooting. Even resizing the filesystem, with resize2fs or ext2online. You'll only need to boot if you need to add a disk physically, or you're not using LVM in the first place.

 

Submitted by Anonymous (not registered) on Fri, 2009-12-11 23:34.

Unfortunately you cannot shrink a mounted / partition, that's what this article documents.

Submitted by Grant (not registered) on Mon, 2009-11-30 21:46.

In addition, if using ReiserFS, you don't even need to unmount the file system to do this, just extend the LV, then resize the FS hot.

 

<pre>

vmetch:/mnt# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              20G   12G  7.2G  62% /
tmpfs                 506M  8.0K  506M   1% /lib/init/rw
udev                   10M  240K  9.8M   3% /dev
tmpfs                 506M     0  506M   0% /dev/shm
/dev/mapper/TestLVM-test1
                      200M   33M  168M  17% /mnt/lvm
vmetch:/mnt# lvresize -L +10M /dev/TestLVM/test1
  Rounding up size to full physical extent 12.00 MiB
  Extending logical volume test1 to 212.00 MiB
  Logical volume test1 successfully resized
vmetch:/mnt# resize_reiserfs /dev/TestLVM/test1
resize_reiserfs 3.6.21 (2009 www.namesys.com)



resize_reiserfs: On-line resizing finished successfully.

vmetch:/mnt# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              20G   12G  7.2G  62% /
tmpfs                 506M  8.0K  506M   1% /lib/init/rw
udev                   10M  228K  9.8M   3% /dev
tmpfs                 506M     0  506M   0% /dev/shm
/dev/mapper/TestLVM-test1
                      212M   33M  180M  16% /mnt/lvm
vmetch:/mnt#
</pre>