I am not a system administrator but I had to extend a logical volume on our search cluster nodes due to increased data usage and a storage shortage. I have not done this before and after asking a linux admin and googling some pages I discovered that all the information needed for someone not having done this before is quite insufficient and I decided to write a sum up which finally worked fine:
Preconditions for this solution:
- System with one SCSI controller important for below scan because host0 is used, this can be different if you have more than one SCSI controller in place
- cfdisk or fdisk installed
- lvm ready
- existing Volume should be extended by a new physical volume
Hints:
- sdc was the device on my system can be another one on yours
- sdc1 will also then have another name on your system after fdisk
- VolGroup01 was made on my system yours can have another name
- /san mountpoint is the name on my system your mountpoint can have a different name
For Runaways the fast way:
rescan SCSI bus_______: echo "- - -" > /sys/class/scsi_host/host0/scan
create lvm partitioin_: fdisk /dev/sdc
create physical volume: pvcreate /dev/sdc1
unmount volume________: umount /san/
extend volume group___: vgextend VolGroup01 /dev/sdc1
save changes__________: vgchange -a y VolGroup01
extend logical volume_: lvextend /dev/VolGroup01/san /dev/sdc1
check filesystem______: e2fsck -f /dev/VolGroup01/san
extend filesystem_____: resize2fs /dev/VolGroup01/san
mount volume__________: mount -t ext3 /dev/VolGroup01/san /san/
check changes_________: df -h
reboot for cowards____: shutdown -r now
Detailed Doing:
- Example for ls -l /dev/sd* before rescan
brw-rw---- 1 root disk 8, 0 Nov 9 10:21 /dev/sda
brw-rw---- 1 root disk 8, 1 Nov 9 10:21 /dev/sda1
brw-rw---- 1 root disk 8, 2 Nov 9 10:21 /dev/sda2
brw-rw---- 1 root disk 8, 16 Nov 9 10:21 /dev/sdb
brw-rw---- 1 root disk 8, 17 Nov 9 10:21 /dev/sdb1
- Rescan of the SCSI bus
echo "- - -" > /sys/class/scsi_host/host0/scan
- Example for ls -l /dev/sd* after rescan, a new device sdc is now visible for the system
brw-rw---- 1 root disk 8, 0 Nov 9 10:21 /dev/sda
brw-rw---- 1 root disk 8, 1 Nov 9 10:21 /dev/sda1
brw-rw---- 1 root disk 8, 2 Nov 9 10:21 /dev/sda2
brw-rw---- 1 root disk 8, 16 Nov 9 10:21 /dev/sdb
brw-rw---- 1 root disk 8, 17 Nov 9 10:21 /dev/sdb1
brw-rw---- 1 root disk 8, 32 Jan 3 13:52 /dev/sdc
- Mark partition for LVM using cfdisk followed by device
Disk /dev/sdc: 21.4 GB, 21474836480 bytesfdisk /dev/sdc
[root@tfdsypwpadmin.tdmz.hbd ~]# fdisk /dev/sdc
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 2610.
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
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): p
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/sdc1 1 2610 20964793+ 8e Linux LVMCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
- Example for ls -l /dev/sd* after creating new partition using fdisk
brw-rw---- 1 root disk 8, 0 Nov 9 10:21 /dev/sda
brw-rw---- 1 root disk 8, 1 Nov 9 10:21 /dev/sda1
brw-rw---- 1 root disk 8, 2 Nov 9 10:21 /dev/sda2
brw-rw---- 1 root disk 8, 16 Nov 9 10:21 /dev/sdb
brw-rw---- 1 root disk 8, 17 Nov 9 10:21 /dev/sdb1
brw-rw---- 1 root disk 8, 32 Jan 3 13:52 /dev/sdc
brw-rw---- 1 root disk 8, 33 Jan 3 13:58 /dev/sdc1
- Create the physical volume
[root@tfdsypwpadmin.tdmz.hbd ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
- Unmount the volume
[root@tfdsypwpadmin.tdmz.hbd ~]# umount /san/
- Extend logical volume with created physical one. We have a volume group defined with the name VolGroup01, there we will add the additional physical volume. Listing of vgdisplay:
[root@tfdsypwpadmin.tdmz.hbd ~]# vgdisplay
--- Volume group ---
VG Name VolGroup01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 29.97 GB
PE Size 32.00 MB
Total PE 959
Alloc PE / Size 959 / 29.97 GB
Free PE / Size 0 / 0
VG UUID 1HFeZa-IJNC-v7Wh-KKN1-VtPx-J04n-MV7YZ6
[root@tfdsypwpadmin.tdmz.hbd ~]# vgextend VolGroup01 /dev/sdc1
Volume group "VolGroup01" successfully extended
- Changes are currently not visible for the node only for the volumegroup, see VolGroup01 is still of size 30GB but should be 50GB by now
[root@tfdsypwpadmin.tdmz.hbd san]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-root
16G 14G 940M 94% /
/dev/sda1 99M 15M 80M 16% /boot
none 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/VolGroup01-san
30G 76M 28G 1% /san
- Make changes persistent unmount Volume, call vgchange -a y volumegroupname and mount again
[root@tfdsypwpadmin.tdmz.hbd ~]# vgchange -a y VolGroup01
1 logical volume(s) in volume group "VolGroup01" now active
- Extend the logical volume with the size of the prior created physical volume
[root@tfdsypwpadmin.tdmz.hbd ~]# lvextend /dev/VolGroup01/san /dev/sdc1
Extending logical volume san to 49.94 GB
Logical volume san successfully resized
- Extend the filesystem
[root@tfdsypwpadmin.tdmz.hbd ~]# e2fsck -f /dev/VolGroup01/san
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup01/san: 12/3932160 files (8.3% non-contiguous), 142845/7856128 blocks
[root@tfdsypwpadmin.tdmz.hbd ~]# resize2fs /dev/VolGroup01/san
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/VolGroup01/san to 13090816 (4k) blocks.
The filesystem on /dev/VolGroup01/san is now 13090816 blocks long.[root@tfdsypwpadmin.tdmz.hbd ~]# mount -t ext3 /dev/VolGroup01/san /san/
[root@tfdsypwpadmin.tdmz.hbd ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-root
16G 14G 941M 94% /
/dev/sda1 99M 15M 80M 16% /boot
none 3.9G 0 3.9G 0% /dev/shm
/dev/mapper/VolGroup01-san
50G 84M 48G 1% /san
- FINISHED