[root@station1 Desktop]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
First cylinder (10609-19457, default 10609):
Using default value 10609
Last cylinder, +cylinders or +size{K,M,G} (10609-19457, default 19457): +512M
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@station1 Desktop]# reboot
[root@station1 Desktop]# pvcreate /dev/sda6
Physical volume "/dev/sda6" successfully created
[root@station1 Desktop]# vgcreate shazam /dev/sda6
Volume group "shazam" successfully created
[root@station1 Desktop]# lvcreate -n storage -L 256M shazam
Logical volume "storage" created
[root@station1 Desktop]# mkfs -t ext4 /dev/shazam/storage
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
32 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@station1 Desktop]# mkdir /storage
[root@station1 Desktop]# vim /etc/fstab
/dev/shazam/storage /storage ext4 defaults 1 2
[root@station1 Desktop]# mount -a
[root@station1 Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 8.6G 19G 32% /
tmpfs 495M 100K 495M 1% /dev/shm
/dev/sda1 985M 39M 897M 5% /boot
/dev/sda5 46G 2.2G 42G 5% /sambashare
/dev/mapper/shazam-storage
248M 11M 226M 5% /storage
[root@station1 Desktop]#
------------------------extending a logical volume---------------------------
NOTE: NO NEED TO UNMOUNT THE VOLUME WHILE EXTENDING
[root@station1 Desktop]# vgdisplay shazam
--- Volume group ---
VG Name shazam
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 516.00 MiB
PE Size 4.00 MiB
Total PE 129
Alloc PE / Size 64 / 256.00 MiB
Free PE / Size 65 / 260.00 MiB --------->FREE SPACE IS 65 EXTENTS SO I USED +32 i.e HALF OF THE FREE SPACE
VG UUID NJ5N0M-09GF-KfKa-TT6Z-uMGL-mdRE-Dq1YPo
[root@station1 Desktop]# lvextend -l +32 /dev/shazam/storage
Extending logical volume storage to 384.00 MiB
Logical volume storage successfully resized
[root@station1 Desktop]# resize2fs /dev/shazam/storage
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/shazam/storage is mounted on /storage; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/shazam/storage to 393216 (1k) blocks.
The filesystem on /dev/shazam/storage is now 393216 blocks long.
[root@station1 Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 8.6G 19G 32% /
tmpfs 495M 100K 495M 1% /dev/shm
/dev/sda1 985M 39M 897M 5% /boot
/dev/sda5 46G 2.2G 42G 5% /sambashare
/dev/mapper/shazam-storage
372M 11M 343M 3% /storage
--------------------------------Extending Volume Group---------------------------
[root@station1 Desktop]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
First cylinder (10609-19457, default 10609):
Using default value 10609
Last cylinder, +cylinders or +size{K,M,G} (10609-19457, default 19457): +512M
Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@station1 Desktop]# reboot
[root@station1 Desktop]# pvcreate /dev/sda
sda sda1 sda2 sda3 sda4 sda5 sda6 sda7
[root@station1 Desktop]# pvcreate /dev/sda7
Physical volume "/dev/sda7" successfully created
[root@station1 Desktop]# vgextend shazam /dev/sda7
Volume group "shazam" successfully extended
[root@station1 Desktop]# pvdisplay
--- Physical volume ---
PV Name /dev/sda6
VG Name shazam
PV Size 517.69 MiB / not usable 1.69 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 129
Free PE 33
Allocated PE 96
PV UUID SY87lw-LqeE-2Vxv-4Hh6-fLSV-mTy2-Jt8VNm
--- Physical volume ---
PV Name /dev/sda7
VG Name shazam
PV Size 517.69 MiB / not usable 1.69 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 129
Free PE 129
Allocated PE 0
PV UUID sLoDna-esoW-pqms-Vc3k-Pc4c-RC4g-p8T130
-----------------------------------------to reduce vg-----------------------------
[root@station1 Desktop]# vgreduce shazam /dev/sda7
Removed "/dev/sda7" from volume group "shazam"
[root@station1 Desktop]# pvdisplay
--- Physical volume ---
PV Name /dev/sda6
VG Name shazam
PV Size 517.69 MiB / not usable 1.69 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 129
Free PE 65
Allocated PE 64
PV UUID SY87lw-LqeE-2Vxv-4Hh6-fLSV-mTy2-Jt8VNm
"/dev/sda7" is a new physical volume of "517.69 MiB"
--- NEW Physical volume ---
PV Name /dev/sda7
VG Name
PV Size 517.69 MiB
Allocatable NO
PE Size 0 ----------> look everything is 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID sLoDna-esoW-pqms-Vc3k-Pc4c-RC4g-p8T130
[root@station1 Desktop]# vgdisplay
--- Volume group ---
VG Name shazam
System ID
Format lvm2
Metadata Areas 1 ---------> look 1 is here
Metadata Sequence No 8
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 516.00 MiB ------------> look only 516 is here
PE Size 4.00 MiB
Total PE 129
Alloc PE / Size 64 / 256.00 MiB
Free PE / Size 65 / 260.00 MiB
VG UUID NJ5N0M-09GF-KfKa-TT6Z-uMGL-mdRE-Dq1YPo
NOTE: sda7 is just remove from the shazam it can be added at any time by command 'vgextend shazam /dev/sda7'
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
First cylinder (10609-19457, default 10609):
Using default value 10609
Last cylinder, +cylinders or +size{K,M,G} (10609-19457, default 19457): +512M
Command (m for help): t
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@station1 Desktop]# reboot
[root@station1 Desktop]# pvcreate /dev/sda6
Physical volume "/dev/sda6" successfully created
[root@station1 Desktop]# vgcreate shazam /dev/sda6
Volume group "shazam" successfully created
[root@station1 Desktop]# lvcreate -n storage -L 256M shazam
Logical volume "storage" created
[root@station1 Desktop]# mkfs -t ext4 /dev/shazam/storage
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
32 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@station1 Desktop]# mkdir /storage
[root@station1 Desktop]# vim /etc/fstab
/dev/shazam/storage /storage ext4 defaults 1 2
[root@station1 Desktop]# mount -a
[root@station1 Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 8.6G 19G 32% /
tmpfs 495M 100K 495M 1% /dev/shm
/dev/sda1 985M 39M 897M 5% /boot
/dev/sda5 46G 2.2G 42G 5% /sambashare
/dev/mapper/shazam-storage
248M 11M 226M 5% /storage
[root@station1 Desktop]#
------------------------extending a logical volume---------------------------
NOTE: NO NEED TO UNMOUNT THE VOLUME WHILE EXTENDING
[root@station1 Desktop]# vgdisplay shazam
--- Volume group ---
VG Name shazam
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 516.00 MiB
PE Size 4.00 MiB
Total PE 129
Alloc PE / Size 64 / 256.00 MiB
Free PE / Size 65 / 260.00 MiB --------->FREE SPACE IS 65 EXTENTS SO I USED +32 i.e HALF OF THE FREE SPACE
VG UUID NJ5N0M-09GF-KfKa-TT6Z-uMGL-mdRE-Dq1YPo
[root@station1 Desktop]# lvextend -l +32 /dev/shazam/storage
Extending logical volume storage to 384.00 MiB
Logical volume storage successfully resized
[root@station1 Desktop]# resize2fs /dev/shazam/storage
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/shazam/storage is mounted on /storage; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/shazam/storage to 393216 (1k) blocks.
The filesystem on /dev/shazam/storage is now 393216 blocks long.
[root@station1 Desktop]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 29G 8.6G 19G 32% /
tmpfs 495M 100K 495M 1% /dev/shm
/dev/sda1 985M 39M 897M 5% /boot
/dev/sda5 46G 2.2G 42G 5% /sambashare
/dev/mapper/shazam-storage
372M 11M 343M 3% /storage
--------------------------------Extending Volume Group---------------------------
[root@station1 Desktop]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
First cylinder (10609-19457, default 10609):
Using default value 10609
Last cylinder, +cylinders or +size{K,M,G} (10609-19457, default 19457): +512M
Command (m for help): t
Partition number (1-7): 7
Hex code (type L to list codes): 8e
Changed system type of partition 7 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@station1 Desktop]# reboot
[root@station1 Desktop]# pvcreate /dev/sda
sda sda1 sda2 sda3 sda4 sda5 sda6 sda7
[root@station1 Desktop]# pvcreate /dev/sda7
Physical volume "/dev/sda7" successfully created
[root@station1 Desktop]# vgextend shazam /dev/sda7
Volume group "shazam" successfully extended
[root@station1 Desktop]# pvdisplay
--- Physical volume ---
PV Name /dev/sda6
VG Name shazam
PV Size 517.69 MiB / not usable 1.69 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 129
Free PE 33
Allocated PE 96
PV UUID SY87lw-LqeE-2Vxv-4Hh6-fLSV-mTy2-Jt8VNm
--- Physical volume ---
PV Name /dev/sda7
VG Name shazam
PV Size 517.69 MiB / not usable 1.69 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 129
Free PE 129
Allocated PE 0
PV UUID sLoDna-esoW-pqms-Vc3k-Pc4c-RC4g-p8T130
-----------------------------------------to reduce vg-----------------------------
[root@station1 Desktop]# vgreduce shazam /dev/sda7
Removed "/dev/sda7" from volume group "shazam"
[root@station1 Desktop]# pvdisplay
--- Physical volume ---
PV Name /dev/sda6
VG Name shazam
PV Size 517.69 MiB / not usable 1.69 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 129
Free PE 65
Allocated PE 64
PV UUID SY87lw-LqeE-2Vxv-4Hh6-fLSV-mTy2-Jt8VNm
"/dev/sda7" is a new physical volume of "517.69 MiB"
--- NEW Physical volume ---
PV Name /dev/sda7
VG Name
PV Size 517.69 MiB
Allocatable NO
PE Size 0 ----------> look everything is 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID sLoDna-esoW-pqms-Vc3k-Pc4c-RC4g-p8T130
[root@station1 Desktop]# vgdisplay
--- Volume group ---
VG Name shazam
System ID
Format lvm2
Metadata Areas 1 ---------> look 1 is here
Metadata Sequence No 8
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 516.00 MiB ------------> look only 516 is here
PE Size 4.00 MiB
Total PE 129
Alloc PE / Size 64 / 256.00 MiB
Free PE / Size 65 / 260.00 MiB
VG UUID NJ5N0M-09GF-KfKa-TT6Z-uMGL-mdRE-Dq1YPo
NOTE: sda7 is just remove from the shazam it can be added at any time by command 'vgextend shazam /dev/sda7'