文章目录
3.1、查看分区空间大小
3.2、列出所有可用块设备的信息
3.3、新建分区
3.4、重读分区表信息
3.5、格式化分区信息
3.6、查看卷组的详细状态
3.7、创建物理卷
3.8、扩容卷组
3.9、逻辑卷在线扩容
3.10、显示物理卷属性
3.11、XFS 文件系统的大小
1、需求
2、vSphere 操作流程
3、服务器操作
1、需求
vCenter虚拟机中把硬盘扩容,vCenter本质上只有一个磁盘,一个磁盘分为多个分区。原磁盘位置已经不够使用,需要给磁盘进行扩容。
然后给 /home 分区扩容
2、vSphere 操作流程
在数据中找到需要扩容的虚拟机,找到操作按钮,选择编辑设置,找到硬盘选项,添加硬盘的容量。
示例如下:
3、服务器操作
进入到服务器的shell命令行
3.1、查看分区空间大小
df -h
$ df -hFilesystem Size Used Avail Use% Mounted on devtmpfs 16G 0 16G 0% /dev tmpfs 16G 0 16G 0% /dev/shm tmpfs 16G 492K 16G 1% /run tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/mapper/rl-root 150G 5.8G 145G 4% / /dev/mapper/rl-home 1.9T 511G 1.4T 28% /home /dev/sda2 10G 360M 9.7G 4% /boot /dev/sda1 1022M 5.8M 1017M 1% /boot/efi tmpfs 3.2G 0 3.2G 0% /run/user/0
3.2、列出所有可用块设备的信息
列出所有可用块设备的信息,而且还能显示他们之间的依赖关系
此时我们可以清晰的看到磁盘sda有3T的空间,但是下方有依赖关系的分区只使用了2T
我们现在需求是为了给 /home 也就是 /dev/mapper/rl-home 分区扩容,请记住它的分区类型lvm
lsblk
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 3T 0 disk ├─sda1 8:1 0 1G 0 part /boot/efi ├─sda2 8:2 0 10G 0 part /boot └─sda3 8:3 0 2T 0 part ├─rl-root 253:0 0 150G 0 lvm / ├─rl-swap 253:1 0 15.8G 0 lvm [SWAP] └─rl-home 253:2 0 1.8T 0 lvm /home sr0 11:0 1 1024M 0 rom
3.3、新建分区
新建一个分区sda4
fdisk /dev/sda
$ fdisk /dev/sda Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.### n代表新建分区Command (m for help): n### 直接回车,选择默认值Partition number (4-128, default 4): 4### 直接回车,选择默认值开始位置First sector (4294965248-6442450910, default 4294965248): ### 直接回车,选择默认值结束位置Last sector, +sectors or +size{K,M,G,T,P} (4294965248-6442450910, default 6442450910): Created a new partition 4 of type 'Linux filesystem' and of size 1 TiB.### t代表设置分区类型Command (m for help): t### 输入刚才输入的分区数字Partition number (1-4, default 4): 4### 输入L获取所有类型,找到我们要扩容分区的类型,记住序号,然后:q退出类型查看Partition type (type L to list all types): L 1 EFI System C12A7328-F81F-11D2-BA4B-00A0C93EC93B 2 MBR partition scheme 024DEE41-33E7-11D3-9D69-0008C781F39F 3 Intel Fast Flash D3BFE2DE-3DAF-11DF-BA40-E3A556D89593 4 BIOS boot 21686148-6449-6E6F-744E-656564454649 5 Sony boot partition F4019732-066E-4E12-8273-346C5641494F 6 Lenovo boot partition BFBFAFE7-A34F-448A-9A5B-6213EB736C22 7 PowerPC PReP boot 9E1A2D38-C612-4316-AA26-8B49521E5A8B 8 ONIE boot 7412F7D5-A156-4B13-81DC-867174929325 9 ONIE config D4E6E2CD-4469-46F3-B5CB-1BFF57AFC149 10 Microsoft reserved E3C9E316-0B5C-4DB8-817D-F92DF00215AE 11 Microsoft basic data EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 12 Microsoft LDM metadata 5808C8AA-7E8F-42E0-85D2-E1E90434CFB3 13 Microsoft LDM data AF9B60A0-1431-4F62-BC68-3311714A69AD 14 Windows recovery environment DE94BBA4-06D1-4D40-A16A-BFD50179D6AC 15 IBM General Parallel Fs 37AFFC90-EF7D-4E96-91C3-2D7AE055B174 16 Microsoft Storage Spaces E75CAF8F-F680-4CEE-AFA3-B001E56EFC2D 17 HP-UX data 75894C1E-3AEB-11D3-B7C1-7B03A0000000 18 HP-UX service E2A1E728-32E3-11D6-A682-7B03A0000000 19 Linux swap 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F 20 Linux filesystem 0FC63DAF-8483-4772-8E79-3D69D8477DE4 21 Linux server data 3B8F8425-20E0-4F3B-907F-1A25A76F98E8 22 Linux root (x86) 44479540-F297-41B2-9AF7-D131D5F0458A 23 Linux root (ARM) 69DAD710-2CE4-4E3C-B16C-21A1D49ABED3 24 Linux root (x86-64) 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709 25 Linux root (ARM-64) B921B045-1DF0-41C3-AF44-4C6F280D3FAE 26 Linux root (IA-64) 993D8D3D-F80E-4225-855A-9DAF8ED7EA97 27 Linux reserved 8DA63339-0007-60C0-C436-083AC8230908 28 Linux home 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 29 Linux RAID A19D880F-05FC-4D3B-A006-743F0F84911E 30 Linux extended boot BC13C2FF-59E6-4262-A352-B275FD6F7172 31 Linux LVM E6D6D379-F507-44C2-A23C-238F2A3DF928 32 FreeBSD data 516E7CB4-6ECF-11D6-8FF8-00022D09712B 33 FreeBSD boot 83BD6B9D-7F41-11DC-BE0B-001560B84F0F 34 FreeBSD swap 516E7CB5-6ECF-11D6-8FF8-00022D09712B 35 FreeBSD UFS 516E7CB6-6ECF-11D6-8FF8-00022D09712B 36 FreeBSD ZFS 516E7CBA-6ECF-11D6-8FF8-00022D09712B 37 FreeBSD Vinum 516E7CB8-6ECF-11D6-8FF8-00022D09712B 38 Apple HFS/HFS+ 48465300-0000-11AA-AA11-00306543ECAC 39 Apple UFS 55465300-0000-11AA-AA11-00306543ECAC 40 Apple RAID 52414944-0000-11AA-AA11-00306543ECAC 41 Apple RAID offline 52414944-5F4F-11AA-AA11-00306543ECAC 42 Apple boot 426F6F74-0000-11AA-AA11-00306543ECAC 43 Apple label 4C616265-6C00-11AA-AA11-00306543ECAC 44 Apple TV recovery 5265636F-7665-11AA-AA11-00306543ECAC 45 Apple Core storage 53746F72-6167-11AA-AA11-00306543ECAC 46 Solaris boot 6A82CB45-1DD2-11B2-99A6-080020736631 47 Solaris root 6A85CF4D-1DD2-11B2-99A6-080020736631 48 Solaris /usr & Apple ZFS 6A898CC3-1DD2-11B2-99A6-080020736631 49 Solaris swap 6A87C46F-1DD2-11B2-99A6-080020736631 50 Solaris backup 6A8B642B-1DD2-11B2-99A6-080020736631 51 Solaris /var 6A8EF2E9-1DD2-11B2-99A6-080020736631 52 Solaris /home 6A90BA39-1DD2-11B2-99A6-080020736631 53 Solaris alternate sector 6A9283A5-1DD2-11B2-99A6-080020736631 54 Solaris reserved 1 6A945A3B-1DD2-11B2-99A6-080020736631 55 Solaris reserved 2 6A9630D1-1DD2-11B2-99A6-080020736631### 输入刚到记住的类型序号Partition type (type L to list all types): 31Changed type of partition 'Linux filesystem' to 'Linux LVM'.### 输入w保存我们的配置Command (m for help): w The partition table has been altered. Syncing disks.
3.4、重读分区表信息
partprobe
fdisk -l
$ partprobe $ fdisk -lDisk /dev/sda: 3 TiB, 3298534883328 bytes, 6442450944 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: gpt Disk identifier: 0988E2ED-39B3-4128-BA84-8F99010C4CD6 Device Start End Sectors Size Type /dev/sda1 2048 2099199 2097152 1G EFI System /dev/sda2 2099200 23070719 20971520 10G Linux filesystem /dev/sda3 23070720 4294965247 4271894528 2T Linux LVM /dev/sda4 4294965248 6442450910 2147485663 1T Linux LVM Disk /dev/mapper/rl-root: 150 GiB, 161061273600 bytes, 314572800 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 Disk /dev/mapper/rl-swap: 15.8 GiB, 16915628032 bytes, 33038336 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 Disk /dev/mapper/rl-home: 1.8 TiB, 2009230999552 bytes, 3924279296 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
3.5、格式化分区信息
mkfs.xfs /dev/sda4
$ mkfs.xfs /dev/sda4 meta-data=/dev/sda4 isize=512 agcount=4, agsize=67108927 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=0 inobtcount=0data = bsize=4096 blocks=268435707, imaxpct=5 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1log =internal log bsize=4096 blocks=131072, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0
3.6、查看卷组的详细状态
记住下方 VG Name 的值 rl 下方要用到vgdisplay
$ vgdisplay --- Volume group --- VG Name rl System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 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 <1.99 TiB PE Size 4.00 MiB Total PE 521471 Alloc PE / Size 521471 / <1.99 TiB Free PE / Size 0 / 0 VG UUID UjKiNx-bg9k-JGUV-wJ3P-uneJ-smV0-rtlMtg
3.7、创建物理卷
pvcreate /dev/sda4
$ pvcreate /dev/sda4 WARNING: xfs signature detected on /dev/sda4 at offset 0. Wipe it? [y/n]: y Wiping xfs signature on /dev/sda4. Physical volume "/dev/sda4" successfully created.
3.8、扩容卷组
扩容卷组,即把物理卷加入卷组vgextend rl /dev/sda4
$ vgextend rl /dev/sda4 Volume group "rl" successfully extended
3.9、逻辑卷在线扩容
逻辑卷在线扩容
lvextend -l +100%FREE /dev/mapper/rl-home
$ lvextend -l +100%FREE /dev/mapper/rl-home Size of logical volume rl/home changed from <1.83 TiB (479038 extents) to <2.83 TiB (741181 extents). Logical volume rl/home successfully resized.
3.10、显示物理卷属性
显示物理卷属性pvdisplay
$ pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name rl PV Size <1.99 TiB / not usable 2.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 521471 Free PE 0 Allocated PE 521471 PV UUID gZTu7E-xJG4-UcoT-SfxT-LbDM-OEyL-MlL4rw --- Physical volume --- PV Name /dev/sda4 VG Name rl PV Size 1.00 TiB / not usable 4.98 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 262143 Free PE 0 Allocated PE 262143 PV UUID 62dZHF-RaoD-VLTf-ccaf-eFT8-8AKv-rS60kU
3.11、XFS 文件系统的大小
/home 是 /dev/mapper/rl-home的实际目录
xfs_growfs /home
$ xfs_growfs /home meta-data=/dev/mapper/rl-home isize=512 agcount=4, agsize=122633728 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=0 inobtcount=0data = bsize=4096 blocks=490534912, imaxpct=5 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1log =internal log bsize=4096 blocks=239519, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0data blocks changed from 490534912 to 758969344
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/6408.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~