linux - Debian 6.0.6 Squeeze: Expand LVM to fill expanded virtual hard disk
2013-07
I am running VMWare ESXi with multiple virtual machines. One of which is running Debian 6.0.6 Squeeze (x86_64) and had a thin provisioned hard disk of 16GB. This has now become full, so I expanded the provisioned space to 20GB.
I went into the root console to expand the LVM to fill out the new space, but Debian hasn't noticed there is more space available -- even after a virtual machine reboot. fdisk has noticed a bigger hard disk to use, though lvresize will not.
The obligatory information:
df -H
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/hlds--ls-root 16G 16G 6.8M 100% /
tmpfs 1.1G 0 1.1G 0% /lib/init/rw
udev 1.1G 103k 1.1G 1% /dev
tmpfs 1.1G 0 1.1G 0% /dev/shm
/dev/sda1 239M 17M 210M 8% /boot
fdisk -u -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c1f94
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 501758 33552383 16525313 5 Extended
/dev/sda5 501760 33552383 16525312 8e Linux LVM
Disk /dev/dm-0: 16.2 GB, 16177430528 bytes
255 heads, 63 sectors/track, 1966 cylinders, total 31596544 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 742 MB, 742391808 bytes
255 heads, 63 sectors/track, 90 cylinders, total 1449984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/dm-1 doesn't contain a valid partition table
Not entirely sure why dm-0/dm-1 are there. This is a single disk system, though does still have the Debian 6.0.6 DVD mounted (4GB).
I see that I would need to expand /dev/sda2 first, then /dev/sda5. I am assuming though if lvresize can't spot free space safely, then using fdisk to delete/re-create the partitions would not be a good idea either.
pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name hlds-ls
PV Size 15.76 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4034
Free PE 0
Allocated PE 4034
PV UUID yUJaSH-2igx-6Yzt-0vba-Rg5b-3BSq-XfouDV
lvdisplay /dev/hlds-ls/root
--- Logical volume ---
LV Name /dev/hlds-ls/root
VG Name hlds-ls
LV UUID svgWMF-kuUz-9Ip1-WGWc-cbkU-dy2m-QKfddW
LV Write Access read/write
LV Status available
# open 1
LV Size 15.07 GiB
Current LE 3857
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
vgdisplay hlds-ls
--- Volume group ---
VG Name hlds-ls
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 15.76 GiB
PE Size 4.00 MiB
Total PE 4034
Alloc PE / Size 4034 / 15.76 GiB
Free PE / Size 0 / 0
VG UUID 1KS0Br-quDG-5vxV-LYz3-ZTsS-2dmo-0micLM
You need to expand physical volume with pvresize and after that expand the logical volume using lvresize (or create new logical volume in that space).
A few months ago I have setup a server with three hard disks. The partition mapping the disks as follows:
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x7ca36fee
Device Boot Start End Blocks Id System
/dev/sda1 * 1 12158 97659103+ 83 Linux
/dev/sda2 12159 13131 7815622+ 82 Linux swap / Solaris
/dev/sda3 13132 121601 871285275 5 Extended
/dev/sda5 13132 121601 871285243+ 8e Linux LVM
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000160d1
Device Boot Start End Blocks Id System
/dev/sdc1 1 121601 976760001 5 Extended
/dev/sdc5 1 121601 976759969+ 8e Linux LVM
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0008d423
Device Boot Start End Blocks Id System
/dev/sdb1 1 121601 976760001 5 Extended
/dev/sdb5 1 121601 976759969+ 8e Linux LVM
As you can see I have created a Linux LVM file system. This are the information of the LVM Logical volume:
--- Logical volume ---
LV Name /dev/gegevens/Data
VG Name gegevens
LV UUID XsddGq-i3wO-HjTg-Lafe-TSF3-28kr-FGYhRd
LV Write Access read/write
LV Status available
# open 1
LV Size 2.63 TB
Current LE 689648
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
Now I have the following problem the LVM file system don't mount properly.
If I open the mount point I see only a few files of the LVM disk. If I want to unmount the disk I get the following error:
umount /data/
umount: /data/: not mounted
If I want to mount the volume I get the following error:
mount -a
mount: /dev/mapper/gegevens-Data already mounted or /data busy
Wat is the problem here?
Thank you,
Ivo Trompert
Please paste the output of the following commands:
mount
as root:
lsof | grep gegevens-Data
as root again:
lsof | grep /data
Given the messages /dev/mapper/gegevens-Data already mounted or /data busy
and umount: /data/: not mounted
, it looks like your gegevens-Data
volume is already mounted on some other directory. You can confirm that with df /dev/mapper/gegevens-Data
or grep /dev/mapper/gegevens-Data /proc/mounts
.
If your next question is why it is mounted: either you did it manually and forgot, or there is an entry for /dev/mapper/gegevens-Data
or UUID=XsddGq-i3wO-HjTg-Lafe-TSF3-28kr-FGYhRd
in /etc/fstab
.
You may be interested in the command mount --move /some/where /data
to change the point where a filesystem is mounted without having to unmount it.
If I open the mount point I see only a few files of the LVM disk.
Actually these files are probably files that you tried to write to the LVM disk when it wasn't mounted on /data
, so move them to the LVM disk before mounting it where you want it.
An application has files open under /data
, which is blocking the mount operation. Use lsof
or fuser
to verify.
Successfully mounted my LVM partitions using steps mentioned in link below
Mounting LVM Disk using Ubuntu livecd
See if it can help you?