Our standard build = 30GB. How do you expand the file system without losing data and/or the VM.
Our test
30GB standard VM
Need to increase /motr to 100GB
Before you start, verify that the new space can be seen. Here is the un-modified fdisk.
Either reboot, or just enter this in. This will rescan the disk to find the new space.
echo 1 > /sys/block/sda/device/rescan
|
bwmx01d:~ # <strong>fdisk -l</strong> Disk /dev/sda: 139.6 GB, 139586437120 bytes 255 heads, 63 sectors/track, 16970 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x18d9c094 Device Boot Start End Blocks Id System /dev/sda1 * 1 8 64228+ 83 Linux /dev/sda2 9 3916 31391010 8e Linux LVM |
|
bwmx01d:~ # <strong>df -h</strong> Filesystem Size Used Avail Use% Mounted on /dev/mapper/system-LVRoot 4.8G 2.2G 2.5G 48% / devtmpfs 2.0G 116K 2.0G 1% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm /dev/mapper/system-LVhome 2.0G 46M 1.8G 3% /home /dev/mapper/system-LVmotr 114G 836M 108G 1% /motr /dev/mapper/system-LVtmp 985M 66M 869M 8% /tmp /dev/mapper/system-LVvar 3.9G 142M 3.6G 4% /var /dev/sda1 63M 15M 45M 25% /lvmboot bwmx01d:~ # |
#1 Start by creating a new primary with your new disk space, this also can be an extended
p = print
n = create new partition
w = write
t = type (8e = LVM)
Here’s the original without the new partition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
bwmx01d:~ # <strong>fdisk /dev/sda</strong> The number of cylinders for this disk is set to 16970. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): <strong>p</strong> Disk /dev/sda: 139.6 GB, 139586437120 bytes 255 heads, 63 sectors/track, 16970 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x18d9c094 Device Boot Start End Blocks Id System /dev/sda1 * 1 8 64228+ 83 Linux /dev/sda2 9 3916 31391010 8e Linux LVM Command (m for help): |
Add a new partition with the new space, we will create this on /dev/sda3. n = create new partition, p = print, t = disk type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Command (m for help): <strong>p</strong> Disk /dev/sda: 139.6 GB, 139586437120 bytes 255 heads, 63 sectors/track, 16970 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x18d9c094 Device Boot Start End Blocks Id System /dev/sda1 * 1 8 64228+ 83 Linux /dev/sda2 9 3916 31391010 8e Linux LVM Command (m for help): <strong>n</strong> Command action e extended p primary partition (1-4) <strong>p</strong> Partition number (1-4): <strong>3</strong> First cylinder (3917-16970, default 3917): <strong><hit enter></strong> Using default value 3917 Last cylinder, +cylinders or +size{K,M,G} (3917-16970, default 16970): <strong><hit enter></strong> Using default value 16970 Command (m for help): <strong>p</strong> Disk /dev/sda: 139.6 GB, 139586437120 bytes 255 heads, 63 sectors/track, 16970 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x18d9c094 Device Boot Start End Blocks Id System /dev/sda1 * 1 8 64228+ 83 Linux /dev/sda2 9 3916 31391010 8e Linux LVM /dev/sda3 3917 16970 104856255 83 Linux |
Now that it’s created we need to specify the partition type and switch that to Linux LVM. Type = 8e for Linux LVM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Command (m for help): <strong>p</strong> Disk /dev/sda: 139.6 GB, 139586437120 bytes 255 heads, 63 sectors/track, 16970 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x18d9c094 Device Boot Start End Blocks Id System /dev/sda1 * 1 8 64228+ 83 Linux /dev/sda2 9 3916 31391010 8e Linux LVM /dev/sda3 3917 16970 104856255 83 Linux Command (m for help): <strong>t </strong> Partition number (1-4): <strong>3</strong> Hex code (type L to list codes): <strong>8e</strong> Changed system type of partition 3 to 8e (Linux LVM) Command (m for help): <strong>p</strong> Disk /dev/sda: 139.6 GB, 139586437120 bytes 255 heads, 63 sectors/track, 16970 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x18d9c094 Device Boot Start End Blocks Id System /dev/sda1 * 1 8 64228+ 83 Linux /dev/sda2 9 3916 31391010 8e Linux LVM /dev/sda3 3917 16970 104856255 8e Linux LVM |
Looks good. Now we need to write this partition to disk using the w
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Command (m for help): <strong>p</strong> Disk /dev/sda: 139.6 GB, 139586437120 bytes 255 heads, 63 sectors/track, 16970 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x18d9c094 Device Boot Start End Blocks Id System /dev/sda1 * 1 8 64228+ 83 Linux /dev/sda2 9 3916 31391010 8e Linux LVM /dev/sda3 3917 16970 104856255 8e Linux LVM Command (m for help): <strong>w</strong> The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. |
run partprobe -s
which will re-scan the new partition table. A reboot will do the samething, but why reboot?
Increase the physical layer
|
bwmx01d:~ # <strong>pvcreate /dev/sda3</strong> No physical volume label read from /dev/sda3 Physical volume "/dev/sda3" successfully created |
Increase the “system” volume. System = the volume name
|
bwmx01d:~ # <strong>vgextend system /dev/sda3</strong> Volume group "system" successfully extended |
Increase the Logical Volume
|
bwmx01d:~ # <strong>lvextend /dev/system/LVmotr /dev/sda3</strong> Extending logical volume LVmotr to 115.62 GB Logical volume LVmotr successfully resized |
Finally increase the file system.
|
bwmx01d:~ # <strong>resize2fs /dev/mapper/system-LVmotr</strong> resize2fs 1.41.9 (22-Aug-2009) Filesystem at /dev/mapper/system-LVmotr is mounted on /motr; on-line resizing required old desc_blocks = 1, new_desc_blocks = 8 Performing an on-line resize of /dev/mapper/system-LVmotr to 30309376 (4k) blocks. The filesystem on /dev/mapper/system-LVmotr is now 30309376 blocks long. |
Note: I had issues trying to use resize2fs on a physical host, as I was attempting to expand file system by adding a new disk to the system. So try this as last step if that fails..
|
bwmx01d:~ # resize_reiserfs /dev/system/motr resize_reiserfs 3.6.21 (2009 www.namesys.com) |
resize_reiserfs: On-line resizing finished successfully.
That’s it.
|
bwmx01d:~ # <strong>df -h</strong> Filesystem Size Used Avail Use% Mounted on /dev/mapper/system-LVRoot 4.8G 2.2G 2.5G 48% / devtmpfs 2.0G 116K 2.0G 1% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm /dev/mapper/system-LVhome 2.0G 46M 1.8G 3% /home /dev/mapper/system-LVmotr 114G 836M 108G 1% /motr /dev/mapper/system-LVtmp 985M 66M 869M 8% /tmp /dev/mapper/system-LVvar 3.9G 142M 3.6G 4% /var /dev/sda1 63M 15M 45M 25% /lvmboot |