Server: Centos Logical Volume
diskserver.rmohan.com (Centos 6.5) = 192.168.1.6
Disk to use:
Disk /dev/sdb: 50GB DISK A
Disk /dev/sdc: 50GB DISK B
Disk /dev/sdd: 50GB DISK C
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdd: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
fdisk -cu /dev/sdb
[root@diskserver ~]# fdisk -cu /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x50497d5f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
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.
fdisk -cu /dev/sdc
fdisk -cu /dev/sdd
root@diskserver ~]# fdisk -cu /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1f69e4f5.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
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.
[root@diskserver ~]# pvcreate /dev/sdb1
Physical volume “/dev/sdb1” successfully created
[root@diskserver ~]# pvcreate /dev/sdc1
dev_is_mpath: failed to get device for 8:33
Physical volume “/dev/sdc1” successfully created
[root@diskserver ~]# pvcreate /dev/sdd1
dev_is_mpath: failed to get device for 8:49
Physical volume “/dev/sdd1” successfully created
[root@diskserver ~]# vgcreate vg01 /dev/sdb1 /dev/sdc1
Volume group “vg01” successfully created
[root@diskserver ~]# lvcreate –extents 100%FREE –name lv_test vg01
Logical volume “lv_test” created
[root@diskserver ~]# mkfs.ext4 /dev/mapper/vg01-lv_test
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26212352 blocks
1310617 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@diskserver ~]# mkdir /media/my_disk
[root@diskserver ~]# mount /dev/mapper/vg01-lv_test /media/my_disk/
[root@diskserver ~]# df -H
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
52G 1.1G 48G 3% /
tmpfs 4.1G 0 4.1G 0% /dev/shm
/dev/sda1 508M 58M 425M 12% /boot
/dev/mapper/vg_diskserver-lv_home
5.1G 145M 4.7G 4% /home
/dev/mapper/vg01-lv_test
106G 197M 101G 1% /media/my_disk
[root@diskserver ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
48G 1.1G 45G 3% /
tmpfs 3.8G 0 3.8G 0% /dev/shm
/dev/sda1 485M 55M 405M 12% /boot
/dev/mapper/vg_diskserver-lv_home
4.7G 138M 4.4G 4% /home
/dev/mapper/vg01-lv_test
99G 188M 94G 1% /media/my_disk
[root@diskserver ~]# dd if=/dev/zero of=/media/my_disk/noodles.log bs=1572864000 count=1
1+0 records in
1+0 records out
1572864000 bytes (1.6 GB) copied, 7.80047 s, 202 MB/s
[root@diskserver ~]# pvcreate /dev/sdd1
Physical volume “/dev/sdd1” successfully created
[root@diskserver ~]# vgextend vg01 /dev/sdd1
Volume group “vg01” successfully extended
[root@diskserver ~]#
[root@diskserver ~]# vgdisplay -v vg01
Using volume group(s) on command line
Finding volume group “vg01”
— Volume group —
VG Name vg01
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 149.99 GiB
PE Size 4.00 MiB
Total PE 38397
Alloc PE / Size 25598 / 99.99 GiB
Free PE / Size 12799 / 50.00 GiB
VG UUID mOZfFu-K2kJ-iD4i-GkD0-4yLa-zPOE-WGfCnd
— Logical volume —
LV Path /dev/vg01/lv_test
LV Name lv_test
VG Name vg01
LV UUID hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status available
# open 1
LV Size 99.99 GiB
Current LE 25598
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:3
— Physical volumes —
PV Name /dev/sdb1
PV UUID NaqfCR-EM8Q-LTHp-vQZf-5mSi-tTF2-kClwyJ
PV Status allocatable
Total PE / Free PE 12799 / 0
PV Name /dev/sdc1
PV UUID Gm32iH-i5FJ-BfSp-3SBw-XjJ3-jAcA-grQUdr
PV Status allocatable
Total PE / Free PE 12799 / 0
PV Name /dev/sdd1
PV UUID jYNKlQ-T5oK-Hw4M-6uyj-ZoJq-4NSJ-AGzYOw
PV Status allocatable
Total PE / Free PE 12799 / 12799
[root@diskserver ~]# vgextend vg01 /dev/sdd1
Physical volume ‘/dev/sdd1’ is already in volume group ‘vg01’
Unable to add physical volume ‘/dev/sdd1’ to volume group ‘vg01’.
[root@diskserver ~]#
[root@diskserver ~]# vgdisplay -v vg01
Using volume group(s) on command line
Finding volume group “vg01”
— Volume group —
VG Name vg01
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 149.99 GiB
PE Size 4.00 MiB
Total PE 38397
Alloc PE / Size 25598 / 99.99 GiB
Free PE / Size 12799 / 50.00 GiB
VG UUID mOZfFu-K2kJ-iD4i-GkD0-4yLa-zPOE-WGfCnd
— Logical volume —
LV Path /dev/vg01/lv_test
LV Name lv_test
VG Name vg01
LV UUID hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status available
# open 1
LV Size 99.99 GiB
Current LE 25598
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:3
— Physical volumes —
PV Name /dev/sdb1
PV UUID NaqfCR-EM8Q-LTHp-vQZf-5mSi-tTF2-kClwyJ
PV Status allocatable
Total PE / Free PE 12799 / 0
PV Name /dev/sdc1
PV UUID Gm32iH-i5FJ-BfSp-3SBw-XjJ3-jAcA-grQUdr
PV Status allocatable
Total PE / Free PE 12799 / 0
PV Name /dev/sdd1
PV UUID jYNKlQ-T5oK-Hw4M-6uyj-ZoJq-4NSJ-AGzYOw
PV Status allocatable
Total PE / Free PE 12799 / 12799
[root@diskserver ~]# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/sda2 vg_diskserver lvm2 a– 59.51g 0 59.51g
/dev/sdb1 vg01 lvm2 a– 50.00g 0 50.00g
/dev/sdc1 vg01 lvm2 a– 50.00g 0 50.00g
/dev/sdd1 vg01 lvm2 a– 50.00g 50.00g 0
[root@diskserver ~]# pvmove /dev/sdc1
/dev/sdc1: Moved: 0.0%
/dev/sdc1: Moved: 17.1%
/dev/sdc1: Moved: 34.1%
/dev/sdc1: Moved: 51.1%
/dev/sdc1: Moved: 68.1%
/dev/sdc1: Moved: 84.6%
/dev/sdc1: Moved: 100.0%
[root@diskserver ~]#
root@diskserver ~]# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/sda2 vg_diskserver lvm2 a– 59.51g 0 59.51g
/dev/sdb1 vg01 lvm2 a– 50.00g 0 50.00g
/dev/sdc1 vg01 lvm2 a– 50.00g 50.00g 0
/dev/sdd1 vg01 lvm2 a– 50.00g 0 50.00g
[root@diskserver ~]#
[root@diskserver ~]# vgreduce vg01 /dev/sdc1
Removed “/dev/sdc1” from volume group “vg01”
[root@diskserver ~]#
[root@diskserver ~]# cat /media/my_disk/myfile.txt
my file
[root@diskserver ~]# cat /media/my_disk/
lost+found/ myfile.txt noodles.log
[root@diskserver ~]# cat /media/my_disk/noodles.log
^C
[root@diskserver ~]# du -hs /media/my_disk/noodles.log
1.5G /media/my_disk/noodles.log
[root@diskserver ~]#
root@diskserver ~]# vgdisplay -vv vg01
Setting activation/monitoring to 1
Setting global/locking_type to 1
Setting global/wait_for_locks to 1
File-based locking selected.
Setting global/locking_dir to /var/lock/lvm
Setting global/prioritise_write_locks to 1
Using volume group(s) on command line
Finding volume group “vg01”
Locking /var/lock/lvm/V_vg01 RB
/dev/ram0: No label detected
/dev/root: size is 102236160 sectors
/dev/root: size is 102236160 sectors
/dev/root: No label detected
/dev/ram1: No label detected
/dev/sda1: No label detected
/dev/vg_diskserver/lv_swap: size is 12582912 sectors
/dev/vg_diskserver/lv_swap: size is 12582912 sectors
/dev/vg_diskserver/lv_swap: No label detected
/dev/ram2: No label detected
/dev/sda2: lvm2 label detected at sector 1
/dev/vg_diskserver/lv_home: size is 9977856 sectors
/dev/vg_diskserver/lv_home: size is 9977856 sectors
/dev/vg_diskserver/lv_home: No label detected
/dev/ram3: No label detected
/dev/vg01/lv_test: size is 209698816 sectors
/dev/vg01/lv_test: size is 209698816 sectors
/dev/vg01/lv_test: No label detected
/dev/ram4: No label detected
/dev/ram5: No label detected
/dev/ram6: No label detected
/dev/ram7: No label detected
/dev/ram8: No label detected
/dev/ram9: No label detected
/dev/ram10: No label detected
/dev/ram11: No label detected
/dev/ram12: No label detected
/dev/ram13: No label detected
/dev/ram14: No label detected
/dev/ram15: No label detected
/dev/sdb1: lvm2 label detected at sector 1
/dev/sdc1: lvm2 label detected at sector 1
/dev/sdd1: lvm2 label detected at sector 1
— Volume group —
VG Name vg01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 2
Act PV 2
VG Size 99.99 GiB
PE Size 4.00 MiB
Total PE 25598
Alloc PE / Size 25598 / 99.99 GiB
Free PE / Size 0 / 0
VG UUID mOZfFu-K2kJ-iD4i-GkD0-4yLa-zPOE-WGfCnd
— Logical volume —
global/lvdisplay_shows_full_device_path not found in config: defaulting to 0
LV Path /dev/vg01/lv_test
LV Name lv_test
VG Name vg01
LV UUID hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status available
# open 1
LV Size 99.99 GiB
Current LE 25598
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:3
— Physical volumes —
PV Name /dev/sdb1
PV UUID NaqfCR-EM8Q-LTHp-vQZf-5mSi-tTF2-kClwyJ
PV Status allocatable
Total PE / Free PE 12799 / 0
PV Name /dev/sdd1
PV UUID jYNKlQ-T5oK-Hw4M-6uyj-ZoJq-4NSJ-AGzYOw
PV Status allocatable
Total PE / Free PE 12799 / 0
Unlocking /var/lock/lvm/V_vg01
[root@diskserver ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_diskserver lvm2 a– 59.51g 0
/dev/sdb1 vg01 lvm2 a– 50.00g 0
/dev/sdc1 lvm2 a– 50.00g 50.00g
/dev/sdd1 vg01 lvm2 a– 50.00g 0
[root@diskserver ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg01 2 1 0 wz–n- 99.99g 0
vg_diskserver 1 3 0 wz–n- 59.51g 0
[root@diskserver ~]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
lv_test vg01 -wi-ao—- 99.99g
lv_home vg_diskserver -wi-ao—- 4.76g
lv_root vg_diskserver -wi-ao—- 48.75g
lv_swap vg_diskserver -wi-ao—- 6.00g
[root@diskserver ~]#
[root@diskserver ~]# lvdisplay
— Logical volume —
LV Path /dev/vg01/lv_test
LV Name lv_test
VG Name vg01
LV UUID hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status available
# open 1
LV Size 99.99 GiB
Current LE 25598
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:3
— Logical volume —
LV Path /dev/vg_diskserver/lv_root
LV Name lv_root
VG Name vg_diskserver
LV UUID ORCwGE-5W6s-kvcs-5oy9-HcMZ-1zLK-5YtebD
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 06:23:36 +0800
LV Status available
# open 1
LV Size 48.75 GiB
Current LE 12480
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0
— Logical volume —
LV Path /dev/vg_diskserver/lv_home
LV Name lv_home
VG Name vg_diskserver
LV UUID CCuLFi-SQfO-wCrH-Paic-QRRE-2B05-oRvruC
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 06:23:41 +0800
LV Status available
# open 1
LV Size 4.76 GiB
Current LE 1218
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2
— Logical volume —
LV Path /dev/vg_diskserver/lv_swap
LV Name lv_swap
VG Name vg_diskserver
LV UUID 041w0e-XJsi-BLuJ-5G1U-c2Im-6dza-f1t5cD
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 06:23:42 +0800
LV Status available
# open 1
LV Size 6.00 GiB
Current LE 1536
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1
[root@diskserver ~]#lvdisplay
root@diskserver ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
ext4 52G 1.1G 48G 3% /
tmpfs tmpfs 4.1G 0 4.1G 0% /dev/shm
/dev/sda1 ext4 508M 58M 425M 12% /boot
/dev/mapper/vg_diskserver-lv_home
ext4 5.1G 145M 4.7G 4% /home
/dev/mapper/vg01-lv_test
ext4 106G 1.8G 99G 2% /media/my_disk
[root@diskserver ~]# e2fsck -ff /dev/vg01/lv_test
e2fsck 1.41.12 (17-May-2010)
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/vg01/lv_test: 13/6553600 files (0.0% non-contiguous), 843351/26212352 blocks
[root@diskserver ~]# resize2fs /dev/vg01/lv_test 50G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg01/lv_test to 13107200 (4k) blocks.
The filesystem on /dev/vg01/lv_test is now 13107200 blocks long.
root@diskserver ~]# lvreduce -L -50G /dev/vg01/lv_test
WARNING: Reducing active logical volume to 49.99 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_test? [y/n]: y
Reducing logical volume lv_test to 49.99 GiB
Logical volume lv_test successfully resized
[root@diskserver ~]#
[root@diskserver ~]# lvdisplay vg01
— Logical volume —
LV Path /dev/vg01/lv_test
LV Name lv_test
VG Name vg01
LV UUID hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status available
# open 0
LV Size 49.99 GiB
Current LE 12798
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:3
[root@diskserver ~]# resize2fs /dev/mapper/vg01-lv_test
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg01-lv_test to 13105152 (4k) blocks.
The filesystem on /dev/mapper/vg01-lv_test is now 13105152 blocks long.
[root@diskserver my_disk]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
ext4 52G 1.1G 48G 3% /
tmpfs tmpfs 4.1G 0 4.1G 0% /dev/shm
/dev/sda1 ext4 508M 58M 425M 12% /boot
/dev/mapper/vg_diskserver-lv_home
ext4 5.1G 145M 4.7G 4% /home
/dev/mapper/vg01-lv_test
ext4 53G 1.8G 49G 4% /media/my_disk
[root@diskserver my_disk]#
[root@diskserver ~]# lvextend -l +4607 /dev/mapper/vg01-lv_test
Extending logical volume lv_test to 67.99 GiB
Logical volume lv_test successfully resized
[root@diskserver ~]# lvextend -l +4607 /dev/mapper/vg01-lv_test
Extending logical volume lv_test to 85.98 GiB
Logical volume lv_test successfully resized
[root@diskserver ~]# resize2fs /dev/vg
vg01/ vga_arbiter vg_diskserver/
[root@diskserver ~]# resize2fs /dev/vg01/lv_test
resize2fs 1.41.12 (17-May-2010)
Please run ‘e2fsck -f /dev/vg01/lv_test’ first.
[root@diskserver ~]# e2fsck -f /dev/vg01/lv_test
e2fsck 1.41.12 (17-May-2010)
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/vg01/lv_test: 13/3276800 files (0.0% non-contiguous), 635701/13105152 blocks
[root@diskserver ~]# resize2fs /dev/vg01/lv_test
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg01/lv_test to 22540288 (4k) blocks.
The filesystem on /dev/vg01/lv_test is now 22540288 blocks long.
Recent Comments