First of all i have to say i've been looking through lots of posts very similar to what i have but none could solve my problem…
In my xen server i use 5 lvm disks per virtual machine:
/boot
/
/home
/var
/swap
I just create the disks with lvcreate, add them to the vm config file and create the vm. Each disk partition is then made by the partition manager while installing the OS (Ubuntu server 12.04).
Tipically resizing an lvm disk should be as simple an lvextend
lvextend -L +100MB /dev/vm-disks/testes-home
Extending logical volume testes-home to 524.00 MiB
Logical volume testes-home successfully resized
Followed by a resize2fs, but it gives an error…
resize2fs /dev/vm-disks/testes-home
resize2fs 1.42 (29-Nov-2011)
resize2fs: Bad magic number in super-block while trying to open /dev/vm-disks/testes-home
Couldn't find valid filesystem superblock.
It is curious that mounting also doesn't work the normal way for an lvm volume:
mount /dev/vm-disks/testes-home /root/mount/
mount: you must specify the filesystem type
One could think that there were more than one partition but running kpartx yields only one…
kpartx -av /dev/vm-disks/testes-home
add map vm--disks-testes--home1 (252:36): 0 1044480 linear /dev/vm-disks/testes-home 2048
… and mounting that one works ok…
mount /dev/mapper/vm--disks-testes--home1 /root/mount/
e2fsck also complains…
e2fsck -f /dev/vm-disks/testes-home
e2fsck 1.42 (29-Nov-2011)
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/vm-disks/testes-home
The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>
Why all this? It's supposed to be super simple…
fdisk -l /dev/vm-disks/testes-home
Disk /dev/vm-disks/testes-home: 549 MB, 549453824 bytes
37 heads, 35 sectors/track, 828 cylinders, total 1073152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 524288 bytes / 1572864 bytes
Disk identifier: 0x000d462a
Device Boot Start End Blocks Id System
/dev/vm-disks/testes-home1 2048 1046527 522240 83 Linux
any ideas? 🙂
Best Answer
The problem is that you have are trying to run the
resize2fs
tool on the whole logical volume, which contains a partition table, and a partition inside the volume.First you must resize the partition table by running
fdisk
on the logical volume.Then you need to use
kpartx
to create the mapping from partition inside the volume to a device, like you already did before mounting, and then runresize2fs
on the actual partition.So, in summary, expand partition, run:
instead of: