LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Partition Expansion DEBATE (https://www.linuxquestions.org/questions/linux-general-1/partition-expansion-debate-4175456948/)

tripialos 04-05-2013 06:09 AM

Partition Expansion DEBATE
 
Greetings

I am having a debate with my colleague regarding the below case and i would really like to hear your opinions:

Scenario:

You have an alix PC engines board which carries an 80GB HDD with CentOS 5.5 installed. You image the hard drive because you know that you will make ten (10) more of such systems with the exact same hardware.

Partitions:
hda1 - / (mount point) - 30GB
hda2 - ext3 (or LVM) - 50GB

Now, you are trying to clone the system which means you get the new hardware , which as stated is is exactly the same, and you copy the image to the new HDD.

BUT

The new hard drive is not 80GB it is 120GB, and i am asking:

1) When you dd the image (of 80GB) to the 120GB disk and connected to the system, what will CentOS recognize?
I mean will the OS have the partitions as before and recognize the rest space as free?

2) Million dollar question:

In case the OS will recognize the rest space as free, and we are able to use it, if we want to expand the hda1 partition will the procedure be the same with LVM or ext3?

I mean if we want to expand the rest space to the hda2 (second partition) would it be easier if the particular partition is an LVM or just an ordinary ext3.


Thanks

kilgoretrout 04-05-2013 04:08 PM

Quote:

When you dd the image (of 80GB) to the 120GB disk and connected to the system, what will CentOS recognize?
I mean will the OS have the partitions as before and recognize the rest space as free?
Not from within CentOS. You will have to use a bootable partitioning cd like PartedMagic or Gparted which will see the free, unallocated space on the drive and allow you to expand the adjacent partition to include the unallocated space. Once gparted writes the expanded partition to the partition table, on reboot CentOS will see the everything and recognize the partition has been enlarged.

syg00 04-05-2013 05:51 PM

Nope. Once you "dd" the image over the target drive, the drive geometry (basically cylinder count) will be replaced. Your 120 Gig will magically become an 80 Gig drive.

Yet another reason to stay away from "dd". Use a kickstart or something like clonezilla - it is data aware. They also have a multicast option which I've not looked at.

tripialos 04-06-2013 03:01 AM

So there is no way, somehow, to achieve this WITHIN the OS even if the partitions were LVM. For isntance, what if you have an LVM volume consisted of 2 partitions and then you make the unallocated space a new LVM partition and add it to your existed with result expanding its storage? Is that possible?

rknichols 04-06-2013 10:20 AM

For an ext3 or ext4 (not ext2) filesystem that was built with the "resize-inode" feature, kernel versions 2.6 and up support online resizing. See the manpage for resize2fs for details. You have several options for doing this, both with and without LVM, but working from within the OS, the size of that 30GB non-LVM root filesystem would be very hard to change. Expanding that second partition and filesystem(s) within it, however, is fairly straightforward.

Without LVM:
  1. Use fdisk to delete the second partition and the re-create it with the same starting point and extending to the end of the disk. You will be prompted to reboot.
  2. After rebooting, use resize2fs to extend the filesystem to fill that second partition.

With LVM - Method A: Expand existing partition:
  1. As above, use fdisk to delete the second partition and the re-create it with the same starting point and extending to the end of the disk. You will be prompted to reboot.
  2. After rebooting, use pvextend to extend the existing LVM physical volume to include the new space.
  3. Use lvextend to add space to the existing logical volume(s).
  4. Use resize2fs to extend the filesystem(s) to fill their enlarged logical volume(s).

With LVM - Method B: Add a new partition (safest):
  1. Use fdisk to add a third partition using the free space on the disk. You will be prompted to reboot.
  2. After rebooting, use pvcreate to set up that third partition as an LVM physical volume.
  3. Use vgextend to add the new physical volume to the existing volume group.
  4. Use lvextend to add space to the existing logical volume(s).
  5. Use resize2fs to extend the filesystem(s) to fill their enlarged logical volume(s).

Note that this fairly simple case is easier without LVM, but using LVM would allow you to have more than one filesystem in that second partition and make it easier to redistribute the space (perhaps adding an additional drive) in the future.


All times are GMT -5. The time now is 11:47 PM.