fdisk -l
Disk /dev/sda: 120 GiB, 128849018880 bytes, 251658240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6e1af0b8


Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048  39063551  39061504 18.6G 83 Linux
/dev/sda2        39065598 136720383  97654786 46.6G  5 Extended
/dev/sda3       136720384 251658239 114937856 54.8G 83 Linux
/dev/sda4       136720384 251658239 114937856 54.8G 8e Linux LVM
/dev/sda5        39065600 136720383  97654784 46.6G 83 Linux


sudo pvcreate /dev/sda4
  Physical volume "/dev/sda4" successfully created




创建VG
 sudo vgcreate ubuntu /dev/sda4
  Volume group "ubuntu" successfully created


sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu
  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               54.80 GiB
  PE Size               4.00 MiB
  Total PE              14030
  Alloc PE / Size       0 / 0   
  Free  PE / Size       14030 / 54.80 GiB
  VG UUID               ZVT3y2-Mw04-T2BS-5pms-YPCN-xe1y-Kh3CdB


pvscan 查看当前PV使用情况
sudo pvscan
  PV /dev/sda4   VG ubuntu          lvm2 [54.80 GiB / 54.80 GiB free]
  Total: 1 [54.80 GiB] / in use: 1 [54.80 GiB] / in no VG: 0 [0   ]


创建一个lv,占用PV中40G空间
 lvcreate -L 40G -n lv ubuntu 
提示
 Logical volume "lv" created.


 ls -l /dev/ubuntu/lv
lrwxrwxrwx 1 root root 7 Mar 29 14:51 /dev/ubuntu/lv -> ../dm-0
格式化分区
mkfs -t ext4 /dev/ubuntu/lv


mkdir /data2


开机自动挂载
vi /etc/fstab


在最下增加一行
/dev/ubuntu/lv   /data2       ext4    defaults        0       0
11-15 12:46
查看更多