Linux:LVM创建和删除:修订间差异
建立內容為「==创建== <syntaxhighlight lang="bash"> pvcreate /dev/sda4 vgcreate vg-linux /dev/sda4 vgdisolay vg-linux lvcreate -L 10G vg-linux -n lv-home lvcreate -L 10G v…」的新頁面 |
|||
(未显示同一用户的1个中间版本) | |||
第28行: | 第28行: | ||
pvremove /dev/sda4 | pvremove /dev/sda4 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Extend space= | |||
use vgdisplay <thevgname> to display the volume name and details. There you can see VG size (total size), Allocated (used) and Free space. The free space hints on how much you could expand your partition. | |||
<syntaxhighlight lang="bash"> | |||
sudo vgdisplay | |||
--- Volume group --- | |||
VG Name ubuntu-vg | |||
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 <928.46 GiB | |||
PE Size 4.00 MiB | |||
Total PE 237685 | |||
Alloc PE / Size 25600 / 100.00 GiB | |||
Free PE / Size 212085 / <828.46 GiB | |||
VG UUID 64593D-HLgd-bEGf-Fodu-dXjQ-5G6W-0QbGK4 | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
sudo lvdisplay | |||
--- Logical volume --- | |||
LV Path /dev/ubuntu-vg/ubuntu-lv | |||
LV Name ubuntu-lv | |||
VG Name ubuntu-vg | |||
LV UUID AcvIuI-xQ60-nddK-1T9Q-4hQq-V4Cw-H1rFpK | |||
LV Write Access read/write | |||
LV Creation host, time ubuntu-server, 2024-05-08 07:21:53 +0000 | |||
LV Status available | |||
# open 1 | |||
LV Size 100.00 GiB | |||
Current LE 25600 | |||
Segments 1 | |||
Allocation inherit | |||
Read ahead sectors auto | |||
- currently set to 256 | |||
Block device 253:0 | |||
</syntaxhighlight> | |||
use lvextend -L +2G /thename/of/filesystem to extend the size the partition. In this example it was increased by 2Gb... edit this part according to your needs. | |||
<syntaxhighlight lang="bash"> | |||
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv | |||
</syntaxhighlight> | |||
use resize2fs /thename/of/filesystem to actually expand the used space. | |||
<syntaxhighlight lang="bash"> | |||
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv | |||
resize2fs 1.46.5 (30-Dec-2021) | |||
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required | |||
old_desc_blocks = 13, new_desc_blocks = 117 | |||
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 243389440 (4k) blocks long. | |||
</syntaxhighlight> | |||
[[Category:Linux/Unix]] | [[Category:Linux/Unix]] |
2024年6月18日 (二) 01:55的最新版本
创建
pvcreate /dev/sda4
vgcreate vg-linux /dev/sda4
vgdisolay vg-linux
lvcreate -L 10G vg-linux -n lv-home
lvcreate -L 10G vg-linux -n lv-root
lvcreate -l +100%FREE vg-linux -n lv-data
lvdisplay
lsblk
mkfs.ext4 /dev/vg-linux/lv-home
mkfs.ext4 /dev/vg-linux/lv-root
mkfs.ext4 /dev/vg-linux/lv-data
删除
lvchange -an /dev/vg-linux/lv-home
lvchange -an /dev/vg-linux/lv-root
lvchange -an /dev/vg-linux/lv-data
lvremove /dev/vg-linux/lv-home
lvremove /dev/vg-linux/lv-root
lvremove /dev/vg-linux/lv-data
vgremove /dev/vg-linux
pvremove /dev/sda4
Extend space
use vgdisplay <thevgname> to display the volume name and details. There you can see VG size (total size), Allocated (used) and Free space. The free space hints on how much you could expand your partition.
sudo vgdisplay
--- Volume group ---
VG Name ubuntu-vg
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 <928.46 GiB
PE Size 4.00 MiB
Total PE 237685
Alloc PE / Size 25600 / 100.00 GiB
Free PE / Size 212085 / <828.46 GiB
VG UUID 64593D-HLgd-bEGf-Fodu-dXjQ-5G6W-0QbGK4
sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID AcvIuI-xQ60-nddK-1T9Q-4hQq-V4Cw-H1rFpK
LV Write Access read/write
LV Creation host, time ubuntu-server, 2024-05-08 07:21:53 +0000
LV Status available
# open 1
LV Size 100.00 GiB
Current LE 25600
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
use lvextend -L +2G /thename/of/filesystem to extend the size the partition. In this example it was increased by 2Gb... edit this part according to your needs.
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
use resize2fs /thename/of/filesystem to actually expand the used space.
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 117
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 243389440 (4k) blocks long.