Resize2fs Ubuntu Filesystem using CentOS binary ?
Hi,
I have a Ubuntu VM which is running under my CentOS node. The VM uses a LVM as its disk. I needed to resize this VM, so I wanted to know is it ok to use CentOS' resize2fs to resize the ubuntu VMs disk ? Is there a difference in CentOS' resize2fs and ubuntu's resize2fs ? |
Quote:
On ubuntu is on the e2fsprogs package. root@ubuntu:~# dpkg -S resize2fs e2fsprogs: /usr/share/man/man8/resize2fs.8.gz e2fsprogs: /sbin/resize2fs and is maintained by ubutu too root@ubuntu:~# aptitude show e2fsprogs Package: e2fsprogs Essential: yes State: installed Automatically installed: no Version: 1.42-1ubuntu2 Priority: required Section: admin Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> ------------------------------------------------------------------------ Out of boredom I have created an lv to remember how this tool was used. I have ACTIVE '/dev/tmpvg/tmplv' [2.00 GiB] inherit mounted at root@ubuntu:~# df -h|grep tmplv /dev/mapper/tmpvg-tmplv 2.0G 68M 1.9G 4% /mnt/tmplv and I will grow it to 4 Gbytes. The easiest way to do so is to use lvresize -r modifier. root@ubuntu:~# lvresize -v -r -L4G /dev/tmpvg/tmplv Finding volume group tmpvg Executing: fsadm --verbose check /dev/tmpvg/tmplv fsadm: "ext3" filesystem found on "/dev/dm-2" fsadm: Executing fsck /dev/dm-2 fsck from util-linux 2.20.1 e2fsck 1.42 (29-Nov-2011) /dev/mapper/tmpvg-tmplv is mounted. WARNING!!! The filesystem is mounted. If you continue you ***WILL*** cause ***SEVERE*** filesystem damage. Do you really want to continue<n>? no check aborted. Archiving volume group "tmpvg" metadata (seqno 2). Extending logical volume tmplv to 4.00 GiB Found volume group "tmpvg" Found volume group "tmpvg" Loading tmpvg-tmplv table (252:2) Suspending tmpvg-tmplv (252:2) with device flush Found volume group "tmpvg" Resuming tmpvg-tmplv (252:2) Creating volume group backup "/etc/lvm/backup/tmpvg" (seqno 3). Logical volume tmplv successfully resized Executing: fsadm --verbose resize /dev/tmpvg/tmplv 4194304K fsadm: "ext3" filesystem found on "/dev/dm-2" fsadm: Device "/dev/dm-2" size is 4294967296 bytes fsadm: Parsing tune2fs -l "/dev/dm-2" fsadm: Resizing filesystem on device "/dev/dm-2" to 4294967296 bytes (524288 -> 1048576 blocks of 4096 bytes) fsadm: Executing resize2fs /dev/dm-2 1048576 resize2fs 1.42 (29-Nov-2011) Filesystem at /dev/dm-2 is mounted on /mnt/tmplv; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/dm-2 to 1048576 (4k) blocks. The filesystem on /dev/dm-2 is now 1048576 blocks long. **My remarks: if you are to extend a mounted filesystem, notice lvresize -r likes to run safe and invoke fsck before hand. If the volume is marked dirty, it will refuse to run. If not you can avoid it, and it will resize. This same thing can be accomplished using resize2fs in the following way: 1) First extend the volume, then 2) extend the filesystem on it. Ex: 1) Will add 2Gbytes to the volume (hence the +2G) root@ubuntu:~# lvresize -v -L+2G /dev/tmpvg/tmplv Finding volume group tmpvg Archiving volume group "tmpvg" metadata (seqno 3). Extending logical volume tmplv to 6.00 GiB Found volume group "tmpvg" Found volume group "tmpvg" Loading tmpvg-tmplv table (252:2) Suspending tmpvg-tmplv (252:2) with device flush Found volume group "tmpvg" Resuming tmpvg-tmplv (252:2) Creating volume group backup "/etc/lvm/backup/tmpvg" (seqno 4). Logical volume tmplv successfully resized So the volume went from --- Logical volume --- LV Name /dev/tmpvg/tmplv VG Name tmpvg LV UUID 12oq5t-dpN4-AGRV-4Uac-rMkO-VAlj-AS1YMh LV Write Access read/write LV Status available # open 1 LV Size 4.00 GiB Current LE 1024 <<<<<<<<<<<NOTICE Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2 TO --- Logical volume --- LV Name /dev/tmpvg/tmplv VG Name tmpvg LV UUID 12oq5t-dpN4-AGRV-4Uac-rMkO-VAlj-AS1YMh LV Write Access read/write LV Status available # open 1 LV Size 6.00 GiB Current LE 1536 <<<<<<<<<<<NOTICE Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2 However filesystem is still 4 Gbytes. root@ubuntu:~# df -h|grep tmplv /dev/mapper/tmpvg-tmplv 4.0G 69M 3.7G 2% /mnt/tmplv At this point the volume is 6 Gbytes but the logical structure on top of it is just 4 Gbytes. We move to grow the filesytem. 2) resize the filesystem to the volume size (hence the missing last parameter [size]. root@ubuntu:~# resize2fs /dev/tmpvg/tmplv resize2fs 1.42 (29-Nov-2011) Filesystem at /dev/tmpvg/tmplv is mounted on /mnt/tmplv; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/tmpvg/tmplv to 1572864 (4k) blocks. The filesystem on /dev/tmpvg/tmplv is now 1572864 blocks long. Voila: root@ubuntu:~# df -h|grep tmplv /dev/mapper/tmpvg-tmplv 6.0G 69M 5.6G 2% /mnt/tmplv Same principles apply to any modern linux. If you are messing with the root or OS partitions, same principles apply, but you might have a hard time to have the partitions sizes and all that s**t. Btw, even when I am doing an online risize here, on some situations you need to do it umounted. Moreover, you need to boot from some other medium/OS to rezise the OS root/partitions. Regards Sebastian |
Hi,
Sir, I know I can resize when the VM is using the LVM tool. My question is whether can I use the CentOS resize2fs utility to resize the partition of the Ubuntu machine when the VM is powered down ? The reason to do this is becuase I dont have access to the VM via SSH or terminal. Hence I was looking for an external solution. |
Quote:
So, you are planning to bring the ubuntu vm down plug the disk to other vm running CentOS resize on CentOS move the disk back to Ubuntu. If the ubuntu disk you'd like to resize is ext3, it should work ok. I would venture ext4 should work too, but it is still in dev and ubuntu is usually more advanced in features and package versions than CentOS. In any case, if you want to resize an LV, there is no need to go with resize2fs. Just pvscan, vgscan, lvscan, check if LVs are ok. If the vg was not imported, start it with vgchange -ay vg, and use lvresize -r on the lv. Regards, Sebastian |
>> bring the ubuntu vm down plug the disk to other vm running CentOS
I dont want to plug the disk on another VM. The Host Node is CentOS and would like to resize from the Host NODE. >> Just pvscan, vgscan, lvscan, check if LVs are ok. That doesnt resize the File System sir. Only the disk capacity. |
I fail to understand your setup and what you are trying to do. Specially since I don't like guessing games and my crystal ball is broken.
Because of your nick (vzXEN), I think you have a centos host running a xen dom0 and some domU, with ubuntu on it. You are trying to grow the filesystem residing on a virtual disk, that the Dom0 sees as an LV. From the CentOS perspective, what you are asking is how can you work with the LV inside a VG that is inside a LV physical LV. If so,the short answer is no. The long answer is maybe. Send an output of pvscan, vgscan, lvscan from both the host and VM, and please confirm this possible imaginary setup I think you have, and what you want to accomplish. Thanks. |
Quote:
Now I need to grow the LV and the Filesystem in it. ATM, the LV and Filesystem size within the LV is 10GB. I would like to grow it to 20 GB. Extending the LV is no big deal. Resizing it is the issue. I would like to resize this LV File System (when the VM is powered off). A way to do it is : kpartx -av /dev/VG/LV (Since its an HVM, we will need to map its partitions) This is will return some path like /dev/device-mapper/LV1, /dev/device-mapper/LV2, etc Now I can resize /dev/device-mapper/LV1 to its maximum limit. The main concern here is whether ITS Safe to use the resize2fs binary of CentOS to resize the File System of another OS i.e. Ubuntu ? |
All times are GMT -5. The time now is 03:45 AM. |