阅读文档可以先了解下物理卷、卷组与逻辑卷三者关系
fr_admin@GDNG3BOSS-HDPDN108:~> lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 446.6G 0 disk ├─sda1 8:1 0 156M 0 part /boot/efi └─sda2 8:2 0 446.5G 0 part ├─rootvg-lvroot 254:0 0 2T 0 lvm / ├─rootvg-boot 254:1 0 1G 0 lvm /boot ├─rootvg-lvhome 254:2 0 1T 0 lvm /home ├─rootvg-lvlog 254:3 0 135.5G 0 lvm /var/log ├─rootvg-lvopt 254:4 0 150G 0 lvm /opt ├─rootvg-lvsrv 254:5 0 60G 0 lvm /srv/BigData ├─rootvg-lvtmp 254:6 0 20G 0 lvm /tmp └─rootvg-lvvar 254:7 0 30G 0 lvm /var sdb 8:16 0 5.5T 0 disk └─sdb1 8:17 0 5.5T 0 part sdc 8:32 0 5.5T 0 disk └─sdc1 8:33 0 5.5T 0 part sdd 8:48 0 5.5T 0 disk └─sdd1 8:49 0 5.5T 0 part sde 8:64 0 5.5T 0 disk └─sde1 8:65 0 5.5T 0 part sdf 8:80 0 5.5T 0 disk └─sdf1 8:81 0 5.5T 0 part sdg 8:96 0 5.5T 0 disk └─sdg1 8:97 0 5.5T 0 part sdh 8:112 0 5.5T 0 disk └─sdh1 8:113 0 5.5T 0 part sdi 8:128 0 5.5T 0 disk └─sdi1 8:129 0 5.5T 0 part sdj 8:144 0 5.5T 0 disk └─sdj1 8:145 0 5.5T 0 part sdk 8:160 0 5.5T 0 disk └─sdk1 8:161 0 5.5T 0 part ├─rootvg-lvroot 254:0 0 2T 0 lvm / └─rootvg-lvhome 254:2 0 1T 0 lvm /home sdl 8:176 0 5.5T 0 disk └─sdl1 8:177 0 5.5T 0 part sdm 8:192 0 5.5T 0 disk └─sdm1 8:193 0 5.5T 0 part nvme0n1 259:0 0 1.5T 0 disk
按照下面Linux操作进行分区。
fr_admin@GDNG3BOSS-HDPDN108:~> fdisk /dev/sdk 命令(输入 m 获取帮助): m 命令操作 a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) 命令(输入 m 获取帮助): n #new 新分区 Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): p #选择主分区 分区号 (1-4,默认为 3): 3 #分区序号 起始 sector (499712-314572799,默认为 499712): #分区开始回车默认 将使用默认值 499712 Last sector, +扇区 or +size{K,M,G} (499712-501757,默认为 501757): 将使用默认值 501757 命令(输入 m 获取帮助): n #new 新分区 Partition type: p primary (2 primary, 1 extended, 1 free) l logical (numbered from 5) Select (default p): p #选择主分区 Selected partition 4 #分区序号 起始 sector (62912512-314572799,默认为 62912512): #分区开始回车默认 将使用默认值 62912512 Last sector, +扇区 or +size{K,M,G} (62912512-314572799,默认为 314572799): 将使用默认值 314572799 命令(输入 m 获取帮助): t #修改分区格式 分区号 (1-5): 4 #修改分区号 Hex code (type L to list codes): 8e #格式选择8e linux LVM Changed system type of partition 4 to 8e (Linux LVM) 命令(输入 m 获取帮助): p #显示分区信息 Disk /dev/vda: 161.1 GB, 161061273600 bytes 16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectors Units = 扇区 of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0001a023 设备 启动 起点 终点 块数 Id 系统 /dev/vda1 * 2048 499711 248832 83 Linux /dev/vda2 501758 62912511 31205377 5 扩展 /dev/vda3 499712 501757 1023 83 Linux /dev/vda4 62912512 314572799 125830144 8e Linux LVM /dev/vda5 501760 62912511 31205376 8e Linux LVM Partition table entries are not in disk order 命令(输入 m 获取帮助): w #保存信息 The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: 设备或资源忙. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
fr_admin@GDNG3BOSS-HDPDN108:~> pvcreate /dev/sdk1 结果:Physical volume "dev/sdk1" successfully created.
fr_admin@GDNG3BOSS-HDPDN108:~> vgextend rootvg /dev/sdk1 结果:Volume group "rootvg" successfully extended 使用以下命令可以看见卷组已被扩容 fr_admin@GDNG3BOSS-HDPDN108:~> vgdisplay --- Volume group --- VG Name rootvg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 10 VG Access read/write VG Status resizable MAX LV 0 Cur LV 8 Open LV 8 Max PV 0 Cur PV 2 Act PV 2 VG Size 5.89 TiB PE Size 4.00 MiB Total PE 1544951 Alloc PE / Size 114295 / 446.46 GiB Free PE / Size 1430656 / 5.46 TiB VG UUID HsfFSL-KBc3-ejNY-NMbf-DWSU-E9Oz-oLNJuG
此时使用的是文件系统,查看方式为
fr_admin@GDNG3BOSS-HDPDN108:~> df -Th 文件系统 类型 容量 已用 可用 已用% 挂载点 devtmpfs devtmpfs 189G 8.0K 189G 1% /dev tmpfs tmpfs 189G 80K 189G 1% /dev/shm tmpfs tmpfs 189G 555M 188G 1% /run tmpfs tmpfs 189G 0 189G 0% /sys/fs/cgroup /dev/mapper/rootvg-lvroot xfs 20G 8.8G 12G 44% / /dev/mapper/rootvg-boot xfs 1014M 152M 863M 15% /boot /dev/mapper/rootvg-lvsrv xfs 60G 33M 60G 1% /srv/BigData /dev/sda1 vfat 156M 4.7M 152M 3% /boot/efi /dev/mapper/rootvg-lvvar xfs 30G 416M 30G 2% /var /dev/mapper/rootvg-lvtmp xfs 20G 136M 20G 1% /tmp /dev/mapper/rootvg-lvhome xfs 30G 37M 30G 1% /home /dev/mapper/rootvg-lvopt xfs 150G 33M 150G 1% /opt /dev/mapper/rootvg-lvlog xfs 136G 509M 135G 1% /var/log tmpfs tmpfs 38G 20K 38G 1% /run/user/484 tmpfs tmpfs 38G 0 38G 0% /run/user/2010 tmpfs tmpfs 38G 0 38G 0% /run/user/2013
扩容1T到home目录对应文件系统命令
fr_admin@GDNG3BOSS-HDPDN108:~> lvresize -L +1024G /dev/mapper/rootvg-lvhome
fr_admin@GDNG3BOSS-HDPDN108:~> sudo xfs_growfs /dev/mapper/rootvg-lvhome xfs_growfs: /dev/mapper/rootvg-lvhome is not a mounted XFS filesystem
resize2fs [挂载点] 命令 针对的是ext2、ext3、ext4文件系统
xfs_growfs [挂载点] 命令 针对的是xfs文件系统
fr_admin@GDNG3BOSS-HDPDN108:~> xfs_growfs /home meta-data=/dev/mapper/rootvg-lvhome isize=512 agcount=16, agsize=491520 blks = sectsz=4096 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 rmapbt=0 = reflink=0 data = bsize=4096 blocks=7864320, imaxpct=25 = sunit=64 swidth=64 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=3840, version=2 = sectsz=4096 sunit=1 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 7864320 to 276299776
文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 189G 8.0K 189G 1% /dev tmpfs 189G 80K 189G 1% /dev/shm tmpfs 189G 555M 188G 1% /run tmpfs 189G 0 189G 0% /sys/fs/cgroup /dev/mapper/rootvg-lvroot 2.1T 8.9G 2.1T 1% / /dev/mapper/rootvg-boot 1014M 152M 863M 15% /boot /dev/mapper/rootvg-lvsrv 60G 33M 60G 1% /srv/BigData /dev/sda1 156M 4.7M 152M 3% /boot/efi /dev/mapper/rootvg-lvvar 30G 416M 30G 2% /var /dev/mapper/rootvg-lvtmp 20G 136M 20G 1% /tmp /dev/mapper/rootvg-lvhome 1.1T 69M 1.1T 1% /home /dev/mapper/rootvg-lvopt 150G 33M 150G 1% /opt /dev/mapper/rootvg-lvlog 136G 509M 135G 1% /var/log tmpfs 38G 20K 38G 1% /run/user/484 tmpfs 38G 0 38G 0% /run/user/2010 tmpfs 38G 0 38G 0% /run/user/2013