この記事は109日前に作成され、109日前に最後に変更されたため、一部の情報が古くなっている可能性があります。
**環境はVMware仮想マシン上のCentos7システムです**
[ root@xls ~]# fdisk -l
Disk /dev/sda:21.5 GB,21474836480 bytes,41943040 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk label type: dos
Disk identifier:0x00000a46
Device Boot Start End Blocks Id System
/dev/sda1 *20482099199104857683 Linux
/dev/sda2 20992004194303919921920 8e Linux LVM
Disk /dev/mapper/cl-root:18.2 GB,18249416704 bytes,35643392 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk /dev/mapper/cl-swap:2147 MB,2147483648 bytes,4194304 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk /dev/sdb:10.7 GB,10737418240 bytes,20971520 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
[ root@xls ~]# fdisk /dev/sdb
Command(m for help): p #パーティションを印刷し、現在のパーティションステータスを表示します
Disk /dev/sdb:10.7 GB,10737418240 bytes,20971520 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk label type: dos
Disk identifier:0x62cab278
Device Boot Start End Blocks Id System
Command(m for help): n #パーティションを開始します
Partition type:
p primary(0 primary,0 extended,4 free)
e extended
Select(default p): p #プライマリパーティションを選択します
Partition number(1-4,default1):1 #パーティション番号1
First sector(2048-20971519,default2048): #Enterキーを押して、デフォルト値を選択します
Using default value 2048
Last sector,+sectors or +size{K,M,G}(2048-20971519,default20971519): #Enterキーを押して、デフォルトのパーティションサイズを選択します
Using default value 20971519
Partition 1of type Linux and of size 10 GiB is set
Command(m for help): p #パーティションを印刷し、現在のパーティションステータスを表示します
Disk /dev/sdb:10.7 GB,10737418240 bytes,20971520 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk label type: dos
Disk identifier:0x62cab278
Device Boot Start End Blocks Id System
/dev/sdb1 2048209715191048473683 Linux
Command(m for help):Command(m for help): t #パーティションタイプの変更
Selected partition 1
Hex code(type L to list all codes): 8e #lvmパーティションタイプ
Changed type of partition 'Linux' to 'Linux LVM'Command(m for help): p #パーティションを印刷すると、タイプが8e、linuxLVMに変更されていることがわかります。
Disk /dev/sdb:10.7 GB,10737418240 bytes,20971520 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk label type: dos
Disk identifier:0x62cab278
Device Boot Start End Blocks Id System
/dev/sdb1 20482097151910484736 8e Linux LVM
Command(m for help): w #パーティションを保存
[ root@xls ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[ root@xls ~]# pvdisplay
- - - Physical volume ---
PV Name /dev/sda2
VG Name cl
PV Size 19.00 GiB / not usable 3.00 MiB
Allocatable yes(but full)
PE Size 4.00 MiB
Total PE 4863
Free PE 0
Allocated PE 4863
PV UUID yunbOn-2uCl-9Xtr-wWV0-3jkn-fUoz-xpw6Ap
" /dev/sdb1" is a newphysical volume of"10.00 GiB"--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID k8y4on-IAJP-URy6-l3eu-xmUH-D3Ov-OI3yfb
[ root@xls ~]# vgcreate xls_vg /dev/sdb1
Volume group "xls_vg" successfully created
[ root@xls ~]# vgdisplay
- - - Volume group ---
VG Name xls_vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 10.00 GiB
PE Size 4.00 MiB
Total PE 2559
Alloc PE / Size 0/0
Free PE / Size 2559/10.00 GiB
VG UUID NczNSi-vCaA-pe9L-Q857-GDig-ME0f-zzxRiB
[ root@xls ~]# lvcreate -L 10000M -n xls_lv xls_vg
Logical volume "xls_lv" created.
[ root@xls ~]# lvdisplay
- - - Logical volume ---
LV Path /dev/xls_vg/xls_lv
LV Name xls_lv
VG Name xls_vg
LV UUID fXQxBc-UYQi-4T6y-gkmE-e9FC-ACy3-YfATDN
LV Write Access read/write
LV Creation host, time xls,2020-04-0122:55:12-0400
LV Status available
# open 0
LV Size 9.77 GiB
Current LE 2500
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
[ root@xls ~]# mkfs.ext4 /dev/xls_vg/xls_lv
[ root@xls ~]# mount /dev/xls_vg/xls_lv /data/[root@xls ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 17G 1020M 16G 6% /
devtmpfs 478M 0 478M 0%/dev
tmpfs 489M 0 489M 0%/dev/shm
tmpfs 489M 6.7M 482M 2%/run
tmpfs 489M 0 489M 0%/sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14%/boot
tmpfs 98M 0 98M 0%/run/user/0/dev/mapper/xls_vg-xls_lv 9.5G 37M 9.0G 1%/data
[ root@xls ~]# vi /etc/fstab
/dev/mapper/xls_vg-xls_lv /data ext4 defaults 00
[ root@xls ~]# echo "- - -">/sys/class/scsi_host/host2/scan
[ root@xls ~]# fdisk -l
Disk /dev/sdc:5368 MB,5368709120 bytes,10485760 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
[ root@xls ~]# fdisk /dev/sdc
Welcome to fdisk(util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a newDOS disklabel with disk identifier 0x8dd3be7d.Command(m for help): n
Partition type:
p primary(0 primary,0 extended,4 free)
e extended
Select(default p): p
Partition number(1-4,default1):
First sector(2048-10485759,default2048):
Using default value 2048
Last sector,+sectors or +size{K,M,G}(2048-10485759,default10485759):
Using default value 10485759
Partition 1of type Linux and of size 5 GiB is setCommand(m for help): p
Disk /dev/sdc:5368 MB,5368709120 bytes,10485760 sectors
Units = sectors of1*512=512 bytes
Sector size(logical/physical):512 bytes /512 bytes
I/O size(minimum/optimal):512 bytes /512 bytes
Disk label type: dos
Disk identifier:0x8dd3be7d
Device Boot Start End Blocks Id System
/dev/sdc1 204810485759524185683 Linux
Command(m for help): t
Selected partition 1
Hex code(type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'Command(m for help): w
[ root@xls ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
[ root@xls ~]# pvscan
PV /dev/sdb1 VG xls_vg lvm2 [10.00 GiB /236.00 MiB free]
PV /dev/sda2 VG cl lvm2 [19.00 GiB /0 free]
PV /dev/sdc1 lvm2 [5.00 GiB]
Total:3[33.99 GiB]/in use:2[28.99 GiB]/in no VG:1[5.00 GiB]
[ root@xls ~]# vgextend xls_vg /dev/sdc1
Volume group "xls_vg" successfully extended
[ root@xls ~]# vgdisplay #vgスペースが元の10gから15gに増加したことがわかります。
- - - Volume group ---
VG Name xls_vg
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 14.99 GiB
PE Size 4.00 MiB
Total PE 3838
Alloc PE / Size 2500/9.77 GiB
Free PE / Size 1338/5.23 GiB
VG UUID NczNSi-vCaA-pe9L-Q857-GDig-ME0f-zzxRiB
[ root@xls ~]# lvextend -l +100%FREE /dev/xls_vg/xls_lv
Size of logical volume xls_vg/xls_lv changed from9.77GiB(2500 extents) to 14.99GiB(3838
extents).
Logical volume xls_vg/xls_lv successfully resized.
[ root@xls ~]# lvdisplay
- - - Logical volume ---
LV Path /dev/xls_vg/xls_lv
LV Name xls_lv
VG Name xls_vg
LV UUID fXQxBc-UYQi-4T6y-gkmE-e9FC-ACy3-YfATDN
LV Write Access read/write
LV Creation host, time xls,2020-04-0122:55:12-0400
LV Status available
# open 1
LV Size 14.99 GiB
Current LE 3838
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
[ root@xls ~]# resize2fs /dev/xls_vg/xls_lv
resize2fs 1.42.9(28-Dec-2013)
Filesystem at /dev/xls_vg/xls_lv is mounted on /data; on-line resizing required
old_desc_blocks =2, new_desc_blocks =2
The filesystem on /dev/xls_vg/xls_lv is now 3930112 blocks long.
[ root@xls ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 17G 1021M 16G 6% /
devtmpfs 478M 0 478M 0%/dev
tmpfs 489M 0 489M 0%/dev/shm
tmpfs 489M 6.8M 482M 2%/run
tmpfs 489M 0 489M 0%/sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14%/boot
tmpfs 98M 0 98M 0%/run/user/0/dev/mapper/xls_vg-xls_lv 15G 41M 14G 1%/data
Recommended Posts