Tag: lvextend

Scanning for new disk in a VMware host running Suse Linux 10 SP4

Scanning for new disk in a VMware host running Suse 10 SP4

root@linux:~ # cat /etc/*release
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4
LSB_VERSION=”core-2.0-noarch:core-3.0-noarch:core-2.0-x86_64:core-3.0-x86_64″

I use the following command to scan the SCSI bus

root@linux:~ # echo “- – -” > /sys/class/scsi_host/host0/scan

List the disks. It’s the last one

root@linux:~ # fdisk -l

Then I make a partition for the disk. The first time, when there is not a valid DOS partition I like to write and call fdisk again

root@linux:~ # fdisk /dev/sdf
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.

The number of cylinders for this disk is set to 9137.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Running again and this time creating the partition

root@linux:~ # fdisk /dev/sdf

The number of cylinders for this disk is set to 9137.
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-9137, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-9137, default 9137):
Using default value 9137

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Add the partition to LVM

root@linux:~ # pvcreate /dev/sdf1
Physical volume “/dev/sdf1” successfully created

Verify the file system size

root@linux:~ # df -h /usr/oradata/oradvt061t
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/softwarevg-dvt061lv
168G 133G 26G 84% /usr/oradata/oradvt061t

Add the disk to the volume group

root@linux:~ # vgextend softwarevg /dev/sdf1
Volume group “softwarevg” successfully extended

See the characteristics of the volume group

root@linux:~ # vgdisplay softwarevg
— Volume group —
VG Name softwarevg
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 4
Act PV 4
VG Size 385.98 GB
PE Size 4.00 MB
Total PE 98810
Alloc PE / Size 69376 / 271.00 GB
Free PE / Size 29434 / 114.98 GB
VG UUID 0BsKwN-18al-1TT8-gctq-fRK4-ccJl-fNXL6g

And the disk added

root@dsv080:~ # pvdisplay /dev/sdf1
— Physical volume —
PV Name /dev/sdf1
VG Name softwarevg
PV Size 69.99 GB / not usable 793.00 KB
Allocatable yes
PE Size (KByte) 4096
Total PE 17918
Free PE 17918
Allocated PE 0
PV UUID 21Q3wb-2tKn-xUdP-9ZBa-tqbp-vhvS-MhSbVt

Increase the logical volume using the new disk

root@linux:~ # lvextend -l +17918 /dev/softwarevg/dvt061lv
Extending logical volume dvt061lv to 239.99 GB
Logical volume dvt061lv successfully resized

Then resize the file system

root@linux:~ # ext2online /dev/softwarevg/dvt061lv
ext2online v1.1.18 – 2001/03/18 for EXT2FS 0.5b

Verify the file system size

root@linux:~ # df -h /usr/oradata/oradvt061t
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/softwarevg-dvt061lv
237G 133G 92G 60% /usr/oradata/oradvt061t

Resizing an ext3 filesystem mounted on a logical volume in a Linux

My home directory got full

root@linux:~ # df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-homevol
101M 96M 94K 100% /home

Checking if the logical volume permits online resizing and if it was created with an older e2fsprogs version. Volumes created prior to SUSE Linux 10 SP2 are using an older e2fsprogs version and needs to be recreated

root@linux:~ # dumpe2fs -h /dev/mapper/rootvg-homevol | grep features
dumpe2fs 1.35 (28-Feb-2004)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file

We checked that the volume has the resize_inode property so to extend the filesystem, first we extend the logical volume

root@linux:~ # lvextend -L 200M /dev/rootvg/homevol
Extending logical volume homevol to 200.00 MB
Logical volume homevol successfully resized

You can see that the filesystem is not yet showing the new size

root@linux:~ # df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-homevol
101M 96M 95K 100% /home

Now we increase the filesystem with resize2fs

root@linux:~ # resize2fs /dev/rootvg/homevol
resize2fs 1.41.9 (22-Aug-2009)
Filesystem at /dev/rootvg/homevol is mounted on /home; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/rootvg/homevol to 204800 (1k) blocks.
The filesystem on /dev/rootvg/homevol is now 204800 blocks long.

Checking the new size

root@linux:~ # df -h /home
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-homevol
194M 94M 90M 52% /home

If you receive a message saying that you can’t resize a mounted filesystem, use ext2online

root@suselinux10:~ # resize2fs /dev/localVG/sys.opt
resize2fs 1.38 (30-Jun-2005)
/dev/localVG/sys.opt is mounted; can’t resize a mounted filesystem!

root@suselinux10:~ # ext2online /dev/localVG/sys.opt
ext2online v1.1.18 – 2001/03/18 for EXT2FS 0.5b

You can also pass the flag -r to resize the filesystem without using resize2fs and use lvresize instead of lvextend

root@linux:~ # lvresize -L +2g -r /dev/vgHQ0ascs/lv_sapmnt_exe
Size of logical volume vgHQ0ascs/lv_sapmnt_exe changed from 5.00 GiB (1280 extents) to 7.00 GiB (1792 extents).
Logical volume lv_sapmnt_exe successfully resized
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vgHQ0ascs-lv_sapmnt_exe is mounted on /export/sapmnt/HQ0/exe; on-line resizing required
old desc_blocks = 20, new_desc_blocks = 28
Performing an on-line resize of /dev/mapper/vgHQ0ascs-lv_sapmnt_exe to 7340032 (1k) blocks.
The filesystem on /dev/mapper/vgHQ0ascs-lv_sapmnt_exe is now 7340032 blocks long.