邏輯卷管理實驗---縮減/home目錄使用空間並建立新的LVM
參考:http://blog.51cto.com/dreamfire/1084729
實驗環境:redhat6.5
實驗過程
顯示物理卷:
[root@jing1 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 142
Allocated PE 76532
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
檢視磁碟掛載:
[root@jing1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/vg_jing1-lv_home 49G 226M 46G 1% /home
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
umount home目錄:
[root@jing1 /]# umount /home
檢查lvm:
[root@jing1 /]# e2fsck -f /dev/vg_jing1/lv_home
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/vg_jing1/lv_home: 504/3203072 files (0.0% non-contiguous), 258764/12800000 blocks
resize lvm(注意不要在生產環境使用):
[root@jing1 /]# resize2fs /dev/vg_jing1/lv_home 2G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg_jing1/lv_home to 524288 (4k) blocks.
The filesystem on /dev/vg_jing1/lv_home is now 524288 blocks long.
減少lvm空間:
[root@jing1 /]# lvreduce -L 2G /dev/vg_jing1/lv_home
WARNING: Reducing active logical volume to 2.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Reducing logical volume lv_home to 2.00 GiB
Logical volume lv_home successfully resized
重新掛載/home目錄
[root@jing1 /]# mount /dev/vg_jing1/lv_home /home
[root@jing1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/mapper/vg_jing1-lv_home 2.0G 198M 1.7G 11% /home
[root@jing1 /]# fdisk -l
Disk /dev/sda: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 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: 0x000ba939
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 39163 314059776 8e Linux LVM
Disk /dev/mapper/vg_jing1-lv_root: 251.7 GB, 251658240000 bytes
255 heads, 63 sectors/track, 30595 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/mapper/vg_jing1-lv_swap: 16.9 GB, 16911433728 bytes
255 heads, 63 sectors/track, 2056 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/mapper/vg_jing1-lv_home: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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
空間釋放到物理卷中:
[root@jing1 /]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 12130
Allocated PE 64544
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
檢視卷組發現減少的空間已經自動釋放到卷組中:
[root@jing1 /]# vgdisplay
--- Volume group ---
VG Name vg_jing1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 64544 / 252.12 GiB
Free PE / Size 12130 / 47.38 GiB
VG UUID 1IW8eG-arlp-kvje-wFLT-pC5d-AcY0-RulpNe
建立名為lv_test的lvm:
[root@jing1 /]# lvcreate -L 15G -n lv_test vg_jing1
Logical volume "lv_test" created
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_test
LV Name lv_test
VG Name vg_jing1
LV UUID l1IhX5-LOKf-lOaH-K5nZ-3wod-2X7m-07cogG
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 13:19:39 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_test
LV Name lv_test
VG Name vg_jing1
LV UUID l1IhX5-LOKf-lOaH-K5nZ-3wod-2X7m-07cogG
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 13:19:39 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@jing1 /]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Feb 10 10:35:59 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_jing1-lv_root / ext4 defaults 1 1
UUID=3b96274e-550d-43fa-96c3-2a4b0b6684dc /boot ext4 defaults 1 2
/dev/mapper/vg_jing1-lv_home /home ext4 defaults 1 2
/dev/mapper/vg_jing1-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
格式化lvm:
[root@jing1 /]# mkfs.ext4 /dev/vg_jing1/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
983040 inodes, 3932160 blocks
196608 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4026531840
120 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
掛載lv_test到/test目錄
[root@jing1 /]# mkdir /test
[root@jing1 /]# mount /dev/vg_jing1/lv_test /test
[root@jing1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/mapper/vg_jing1-lv_home 2.0G 198M 1.7G 11% /home
/dev/mapper/vg_jing1-lv_test 15G 166M 14G 2% /test
接下刪除lv_test邏輯卷,並建立名為lv_asm的邏輯卷用作資料庫使用:
[root@jing1 /]# umount /test
[root@jing1 /]#
[root@jing1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/mapper/vg_jing1-lv_home 2.0G 198M 1.7G 11% /home
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_test
LV Name lv_test
VG Name vg_jing1
LV UUID l1IhX5-LOKf-lOaH-K5nZ-3wod-2X7m-07cogG
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 13:19:39 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@jing1 /]# vgdisplay
--- Volume group ---
VG Name vg_jing1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 68384 / 267.12 GiB
Free PE / Size 8290 / 32.38 GiB
VG UUID 1IW8eG-arlp-kvje-wFLT-pC5d-AcY0-RulpNe
[root@jing1 /]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 8290
Allocated PE 68384
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
[root@jing1 /]# lvremove /dev/vg_jing1/lv_test
Do you really want to remove active logical volume lv_test? [y/n]: y
Logical volume "lv_test" successfully removed
[root@jing1 /]#
[root@jing1 /]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 12130
Allocated PE 64544
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
[root@jing1 /]# vgdisplay
--- Volume group ---
VG Name vg_jing1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 64544 / 252.12 GiB
Free PE / Size 12130 / 47.38 GiB
VG UUID 1IW8eG-arlp-kvje-wFLT-pC5d-AcY0-RulpNe
[root@jing1 /]#
[root@jing1 /]# lvcreate -L 45G -n lv_asm vg_jing1
Logical volume "lv_asm" created
[root@jing1 /]# mkfs.ext4 /dev/vg_jing1/lv_asm
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
2949120 inodes, 11796480 blocks
589824 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
360 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
Writing inode tables: done
Creating journal (32768 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@jing1 /]#
[root@jing1 /]#
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_asm
LV Name lv_asm
VG Name vg_jing1
LV UUID Fa3ufV-6Pjn-Sncv-KyKd-x6BD-GWoi-yFXjMv
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 14:00:39 +0800
LV Status available
# open 0
LV Size 45.00 GiB
Current LE 11520
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
實驗環境:redhat6.5
實驗過程
顯示物理卷:
[root@jing1 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 142
Allocated PE 76532
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
檢視磁碟掛載:
[root@jing1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/vg_jing1-lv_home 49G 226M 46G 1% /home
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
umount home目錄:
[root@jing1 /]# umount /home
檢查lvm:
[root@jing1 /]# e2fsck -f /dev/vg_jing1/lv_home
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/vg_jing1/lv_home: 504/3203072 files (0.0% non-contiguous), 258764/12800000 blocks
resize lvm(注意不要在生產環境使用):
[root@jing1 /]# resize2fs /dev/vg_jing1/lv_home 2G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg_jing1/lv_home to 524288 (4k) blocks.
The filesystem on /dev/vg_jing1/lv_home is now 524288 blocks long.
減少lvm空間:
[root@jing1 /]# lvreduce -L 2G /dev/vg_jing1/lv_home
WARNING: Reducing active logical volume to 2.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Reducing logical volume lv_home to 2.00 GiB
Logical volume lv_home successfully resized
重新掛載/home目錄
[root@jing1 /]# mount /dev/vg_jing1/lv_home /home
[root@jing1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/mapper/vg_jing1-lv_home 2.0G 198M 1.7G 11% /home
[root@jing1 /]# fdisk -l
Disk /dev/sda: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 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: 0x000ba939
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 39163 314059776 8e Linux LVM
Disk /dev/mapper/vg_jing1-lv_root: 251.7 GB, 251658240000 bytes
255 heads, 63 sectors/track, 30595 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/mapper/vg_jing1-lv_swap: 16.9 GB, 16911433728 bytes
255 heads, 63 sectors/track, 2056 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/mapper/vg_jing1-lv_home: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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
空間釋放到物理卷中:
[root@jing1 /]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 12130
Allocated PE 64544
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
檢視卷組發現減少的空間已經自動釋放到卷組中:
[root@jing1 /]# vgdisplay
--- Volume group ---
VG Name vg_jing1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 64544 / 252.12 GiB
Free PE / Size 12130 / 47.38 GiB
VG UUID 1IW8eG-arlp-kvje-wFLT-pC5d-AcY0-RulpNe
建立名為lv_test的lvm:
[root@jing1 /]# lvcreate -L 15G -n lv_test vg_jing1
Logical volume "lv_test" created
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_test
LV Name lv_test
VG Name vg_jing1
LV UUID l1IhX5-LOKf-lOaH-K5nZ-3wod-2X7m-07cogG
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 13:19:39 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_test
LV Name lv_test
VG Name vg_jing1
LV UUID l1IhX5-LOKf-lOaH-K5nZ-3wod-2X7m-07cogG
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 13:19:39 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@jing1 /]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Feb 10 10:35:59 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_jing1-lv_root / ext4 defaults 1 1
UUID=3b96274e-550d-43fa-96c3-2a4b0b6684dc /boot ext4 defaults 1 2
/dev/mapper/vg_jing1-lv_home /home ext4 defaults 1 2
/dev/mapper/vg_jing1-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
格式化lvm:
[root@jing1 /]# mkfs.ext4 /dev/vg_jing1/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
983040 inodes, 3932160 blocks
196608 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4026531840
120 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
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
掛載lv_test到/test目錄
[root@jing1 /]# mkdir /test
[root@jing1 /]# mount /dev/vg_jing1/lv_test /test
[root@jing1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/mapper/vg_jing1-lv_home 2.0G 198M 1.7G 11% /home
/dev/mapper/vg_jing1-lv_test 15G 166M 14G 2% /test
接下刪除lv_test邏輯卷,並建立名為lv_asm的邏輯卷用作資料庫使用:
[root@jing1 /]# umount /test
[root@jing1 /]#
[root@jing1 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_jing1-lv_root 231G 27G 193G 13% /
tmpfs 16G 228K 16G 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
/dev/mapper/vg_jing1-lv_home 2.0G 198M 1.7G 11% /home
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_test
LV Name lv_test
VG Name vg_jing1
LV UUID l1IhX5-LOKf-lOaH-K5nZ-3wod-2X7m-07cogG
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 13:19:39 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
[root@jing1 /]# vgdisplay
--- Volume group ---
VG Name vg_jing1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 68384 / 267.12 GiB
Free PE / Size 8290 / 32.38 GiB
VG UUID 1IW8eG-arlp-kvje-wFLT-pC5d-AcY0-RulpNe
[root@jing1 /]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 8290
Allocated PE 68384
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
[root@jing1 /]# lvremove /dev/vg_jing1/lv_test
Do you really want to remove active logical volume lv_test? [y/n]: y
Logical volume "lv_test" successfully removed
[root@jing1 /]#
[root@jing1 /]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_jing1
PV Size 299.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 76674
Free PE 12130
Allocated PE 64544
PV UUID fusHvY-5mpq-X2bO-pbdC-2AWl-m4wO-cUf07p
[root@jing1 /]# vgdisplay
--- Volume group ---
VG Name vg_jing1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 299.51 GiB
PE Size 4.00 MiB
Total PE 76674
Alloc PE / Size 64544 / 252.12 GiB
Free PE / Size 12130 / 47.38 GiB
VG UUID 1IW8eG-arlp-kvje-wFLT-pC5d-AcY0-RulpNe
[root@jing1 /]#
[root@jing1 /]# lvcreate -L 45G -n lv_asm vg_jing1
Logical volume "lv_asm" created
[root@jing1 /]# mkfs.ext4 /dev/vg_jing1/lv_asm
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
2949120 inodes, 11796480 blocks
589824 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
360 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
Writing inode tables: done
Creating journal (32768 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@jing1 /]#
[root@jing1 /]#
[root@jing1 /]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_jing1/lv_root
LV Name lv_root
VG Name vg_jing1
LV UUID shkBg6-9RqZ-AhDG-qfVf-d51Z-nsoS-qvF7Da
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:09 +0800
LV Status available
# open 1
LV Size 234.38 GiB
Current LE 60000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_jing1/lv_swap
LV Name lv_swap
VG Name vg_jing1
LV UUID FQE8o0-yOKG-S4ip-Cvry-qSdk-v3f9-uPSa1e
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:50 +0800
LV Status available
# open 1
LV Size 15.75 GiB
Current LE 4032
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/vg_jing1/lv_home
LV Name lv_home
VG Name vg_jing1
LV UUID FTLjIk-zr5B-M5ak-WdXB-c2Zs-c0eC-xZ6YBp
LV Write Access read/write
LV Creation host, time jing1, 2017-02-10 10:33:51 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_jing1/lv_asm
LV Name lv_asm
VG Name vg_jing1
LV UUID Fa3ufV-6Pjn-Sncv-KyKd-x6BD-GWoi-yFXjMv
LV Write Access read/write
LV Creation host, time jing1, 2017-11-28 14:00:39 +0800
LV Status available
# open 0
LV Size 45.00 GiB
Current LE 11520
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2147859/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- lvm收縮邏輯卷空間LVM
- Lvm邏輯卷管理、建立、使用、擴充套件、縮減、遷移、快照、恢復LVM套件
- LVM 邏輯卷管理LVM
- LVM_邏輯卷管理LVM
- lvm 擴充邏輯卷空間(linux的磁碟擴容)LVMLinux
- Linux下LVM邏輯卷管理LinuxLVM
- 在Linux中,如何使用LVM管理邏輯卷?LinuxLVM
- LVM邏輯卷線上動態擴容磁碟空間LVM
- 如何在 Ubuntu 中管理和使用邏輯卷管理 LVMUbuntuLVM
- Linux LVM Logical Volume Management 邏輯卷的管理LinuxLVM
- Linux—磁碟配額,管理LVM邏輯卷LinuxLVM
- linux之LVM邏輯卷LinuxLVM
- 一文全解:LVM(邏輯卷管理器)LVM
- ENGINEER01 - 分割槽規劃和使用,LVM邏輯卷LVM
- 實操CentOS8系統中建立LVM邏輯卷CentOSLVM
- 手把手教學----LVM邏輯卷管理與磁碟配額實操全流程LVM
- 在LVM中恢復已刪除的邏輯卷LVM
- Linux作業系統邏輯盤卷管理LVM建立步驟(轉)Linux作業系統LVM
- 什麼是LVM邏輯卷管理?0基礎學Linux運維LVMLinux運維
- Centos8中建立LVM精簡邏輯卷CentOSLVM
- 『學了就忘』Linux檔案系統管理 — 65、LVM邏輯卷管理介紹LinuxLVM
- 邏輯課程目錄
- ubuntu重新分配根目錄儲存空間-將根目錄空間縮小騰出給別的位置Ubuntu
- 關於 Jenkins master 共享 JENKINS_HOME 目錄的實驗JenkinsAST
- 使用 LVM 將多個硬碟合併,解決 /home 目錄容量不足問題LVM硬碟
- linux 磁碟分割槽掛載-LVM-物理卷PV,卷組VG,邏輯卷LVLinuxLVM
- Linux-使用者管理與建立邏輯卷Linux
- Centos7使用SSM管理LVM卷CentOSSSMLVM
- linux 壓縮目錄並排除某個目錄Linux
- LVM : 縮減檔案系統的容量LVM
- 管理(006):啟用只讀Oracle Home目錄Oracle
- linux 磁碟自動化分割槽掛載-LVM-物理卷PV,卷組VG,邏輯卷LV-shellLinuxLVM
- 如何新建邏輯卷及磁碟掛載,邏輯卷擴容
- linux系統lvm中lv使用空間的調整LinuxLVM
- linux系統掛載邏輯卷和擴充套件邏輯卷組Linux套件
- Linux擴充套件LVM空間Linux套件LVM
- Ubuntu 22.04擴容LVM空間UbuntuLVM
- 實驗11-使用keras完成邏輯迴歸Keras邏輯迴歸
- linux雲主機如何檢視目錄空間的使用率Linux