(7)Windows Linux 操作系统分区管理、LVM逻辑卷管理

张开发
2026/4/14 3:54:17 15 分钟阅读

分享文章

(7)Windows  Linux 操作系统分区管理、LVM逻辑卷管理
目录1. Windows 操作系统 分区管理1.1 Windows操作系统对磁盘分区的管理的三种方式1.2 虚拟机新建硬盘1.3 分区操作步骤1.4 windows动态磁盘管理2. Linux 操作系统 分区管理2.1 新建虚拟硬盘2.2 对新虚拟硬盘进行分区1查看系统中的磁盘设备2用fdisk给新添加的硬盘sdc分区,并分配5G存储3分区可视化4挂载5永久挂载写入开机自启文件3. 逻辑卷管理LVM3.1 sdb创建两个分区sdb1、sdb21查看磁盘分区2创建两个磁盘分区3.2 将标准分区格式改为LVM格式3.3 创建物理卷3.4 创建卷组3.5 创建逻辑卷3.6 格式化逻辑卷3.7 LV逻辑卷扩容3.8 VG卷组扩容1. Windows 操作系统 分区管理1.1 Windows操作系统对磁盘分区的管理的三种方式1可以在安装操作系统的时候进行操作2在操作系统安装完毕之后使用操作系统自带的磁盘管理程序进行管理3安装第三方软件进行管理1.2 虚拟机新建硬盘1.3 分区操作步骤1.4windows动态磁盘管理重复1.2 新建磁盘首先新建简单卷将基本磁盘转换为动态磁盘右键点击需要转换的基本磁盘点选“转换到动态磁盘”合并多块磁盘以突破容量限制使用跨区卷 具体应用当你手头有几块容量不一的小硬盘想将它们整合成一个盘符例如D盘来存放电影、备份文件时跨区卷能帮你实现。它可以将2到32个不同磁盘的未分配空间合并成一个逻辑卷。需要留意的是这种模式没有容错能力一旦其中任何一块物理硬盘损坏整个跨区卷上的所有数据都将丢失。这个场景实验具体如何一步一步做出来稍等一会2. Linux 操作系统 分区管理【目的】1、了解分区的结构2、理解分区的主分区3、理解分区的逻辑分区4、掌握分区的方法【环境】1、硬件环境CPU建议INTEL CORE I5以上内存建议4G以上、硬盘可用磁盘空间建议50G以上2、软件环境建议WINDOW 2003 64位及以上操作系统 、Vmare Workstation 7及以上版本虚拟机镜像用LINUX CENTOS 6.5 64位 及以上操作系统。3、网络环境可以接入INTERNET2.1 新建虚拟硬盘2.2对新虚拟硬盘进行分区1查看系统中的磁盘设备[rootYL ~]# fdisk -l Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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/sda: 64.4 GB, 64424509440 bytes, 125829120 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 label type: dos Disk identifier: 0x000d7b77 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 17803263 8388608 82 Linux swap / Solaris /dev/sda3 17803264 125829119 54012928 83 Linux Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors Units sectors of 1 * 512 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes2用fdisk给新添加的硬盘sdc分区,并分配5G存储[rootYL ~]# 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 new DOS disklabel with disk identifier 0xe57013ca. Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table 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 partitions system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): p Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0xe57013ca 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): Using default response p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048 Last sector, sectors or size{K,M,G} (2048-41943039, default 41943039): 5G Partition 1 of type Linux and of size 5 GiB is set Command (m for help): p Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0xe57013ca Device Boot Start End Blocks Id System /dev/sdc1 2048 10487807 5242880 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.3分区可视化[rootYL ~]# # 分区可视化 [rootYL ~]# mkfs.xfs /dev/sdc1 meta-data/dev/sdc1 isize512 agcount4, agsize327680 blks sectsz512 attr2, projid32bit1 crc1 finobt0, sparse0 data bsize4096 blocks1310720, imaxpct25 sunit0 swidth0 blks naming version 2 bsize4096 ascii-ci0 ftype1 log internal log bsize4096 blocks2560, version2 sectsz512 sunit0 blks, lazy-count1 realtime none extsz4096 blocks0, rtextents04挂载[rootYL ~]# # 4.挂载 [rootYL ~]# mkdir Cloud_File [rootYL ~]# ll total 8 drwxr-xr-x. 2 root root 6 Oct 24 15:56 abc -rw-------. 1 root root 1515 Oct 14 23:04 anaconda-ks.cfg drwxr-xr-x. 2 root root 6 Oct 24 15:56 Cloud_File drwxr-xr-x. 2 root root 6 Oct 15 00:11 Desktop drwxr-xr-x. 2 root root 6 Oct 15 00:11 Documents drwxr-xr-x. 2 root root 6 Oct 15 00:11 Downloads -rw-r--r--. 1 root root 1563 Oct 14 23:53 initial-setup-ks.cfg drwxr-xr-x. 2 root root 6 Oct 15 00:11 Music drwxr-xr-x. 2 root root 6 Oct 15 00:11 Pictures drwxr-xr-x. 2 root root 6 Oct 15 00:11 Public drwxr-xr-x. 2 root root 6 Oct 15 00:11 Templates drwxr-xr-x. 2 root root 6 Oct 15 00:11 Videos [rootYL ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 12K 781M 1% /run/user/42 tmpfs tmpfs 781M 0 781M 0% /run/user/0 [rootYL ~]# pwd /root [rootYL ~]# mount /dev/sdc1 /root/Cloud_File [rootYL ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 12K 781M 1% /run/user/42 tmpfs tmpfs 781M 0 781M 0% /run/user/0 /dev/sdc1 xfs 5.0G 33M 5.0G 1% /root/Cloud_File重启后Cloud_File目录消失了需要再次手动挂载5永久挂载写入开机自启文件Type help to learn how to use Xshell prompt. [C:\~]$ Connecting to 192.168.153.151:22... Connection established. To escape to local shell, press CtrlAlt]. Last login: Fri Oct 24 15:08:51 2025 from 192.168.153.1 [rootYL ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 8.0K 781M 1% /run/user/42 tmpfs tmpfs 781M 0 781M 0% /run/user/0 [rootYL ~]# #6.创建永久挂载点 [rootYL ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Oct 14 22:50:53 2025 # # Accessible filesystems, by reference, are maintained under /dev/disk # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID85b48939-96e5-4fd0-814e-07926858a442 / xfs defaults 0 0 UUID187b4d37-33eb-44e4-aeaa-1e78e2651b89 /boot xfs defaults 0 0 UUID1ee82ec0-163a-4c6f-b85f-f3ae67ad6b70 swap swap defaults 0 0 [rootYL ~]# vim /etc/fstab [rootYL ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Oct 14 22:50:53 2025 # # Accessible filesystems, by reference, are maintained under /dev/disk # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID85b48939-96e5-4fd0-814e-07926858a442 / xfs defaults 0 0 UUID187b4d37-33eb-44e4-aeaa-1e78e2651b89 /boot xfs defaults 0 0 UUID1ee82ec0-163a-4c6f-b85f-f3ae67ad6b70 swap swap defaults 0 0 /dev/sdc1 /root/Cloud_File xfs defaults 0 0 [rootYL ~]# mount -a [rootYL ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 12K 781M 1% /run/user/42 tmpfs tmpfs 781M 0 781M 0% /run/user/0 /dev/sdc1 xfs 5.0G 33M 5.0G 1% /root/Cloud_File重启之后依然生效会自动通过fstab文件挂载分区查看UUID,并添加记录Connecting to 192.168.153.151:22... Connection established. To escape to local shell, press CtrlAlt]. Last login: Fri Oct 24 16:06:24 2025 from 192.168.153.1 [rootYL ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sdc1 xfs 5.0G 33M 5.0G 1% /root/Cloud_File /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 8.0K 781M 1% /run/user/42 tmpfs tmpfs 781M 0 781M 0% /run/user/0 [rootYL ~]# blkid /dev/sda3: UUID85b48939-96e5-4fd0-814e-07926858a442 TYPExfs /dev/sr0: UUID2020-11-02-15-15-23-00 LABELCentOS 7 x86_64 TYPEiso9660 PTTYPEdos /dev/sda1: UUID187b4d37-33eb-44e4-aeaa-1e78e2651b89 TYPExfs /dev/sda2: UUID1ee82ec0-163a-4c6f-b85f-f3ae67ad6b70 TYPEswap /dev/sdc1: UUID7dd52d1a-7d47-48e4-9e81-1b1af0e6a9f7 TYPExfs [rootYL ~]# vim /etc/fstab [rootYL ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Oct 14 22:50:53 2025 # # Accessible filesystems, by reference, are maintained under /dev/disk # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID85b48939-96e5-4fd0-814e-07926858a442 / xfs defaults 0 0 UUID187b4d37-33eb-44e4-aeaa-1e78e2651b89 /boot xfs defaults 0 0 UUID1ee82ec0-163a-4c6f-b85f-f3ae67ad6b70 swap swap defaults 0 0 UUID7dd52d1a-7d47-48e4-9e81-1b1af0e6a9f7 /dev/sdc1 /root/Cloud_File xfs defaults 0 03. 逻辑卷管理LVM3.1 sdb创建两个分区sdb1、sdb21查看磁盘分区[rootYL ~]# fdisk -l Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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 label type: dos Disk identifier: 0x000d7b77 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 17803263 8388608 82 Linux swap / Solaris /dev/sda3 17803264 125829119 54012928 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0xe57013ca Device Boot Start End Blocks Id System /dev/sdc1 2048 10487807 5242880 83 Linux2创建两个磁盘分区[rootYL ~]# fdisk /dev/sdb 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 new DOS disklabel with disk identifier 0x39f9ec19. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048 Last sector, sectors or size{K,M,G} (2048-41943039, default 41943039): 4G Partition 1 of type Linux and of size 4 GiB is set Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0x39f9ec19 Device Boot Start End Blocks Id System /dev/sdb1 2048 8390655 4194304 83 Linux Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): Using default response p Partition number (2-4, default 2): First sector (8390656-41943039, default 8390656): Using default value 8390656 Last sector, sectors or size{K,M,G} (8390656-41943039, default 41943039): 5G Partition 2 of type Linux and of size 5 GiB is set Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0x39f9ec19 Device Boot Start End Blocks Id System /dev/sdb1 2048 8390655 4194304 83 Linux /dev/sdb2 8390656 18876415 5242880 83 Linux3.2 将标准分区格式改为LVM格式Command (m for help): l 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Extd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 3 61 SpeedStor ab Darwin boot f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 1e Hidden W95 FAT1 80 Old Minix Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table 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 partitions system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): t Partition number (1,2, default 2): 1 Hex code (type L to list all codes): 8e Changed type of partition Linux to Linux LVM Command (m for help): t Partition number (1,2, default 2): Hex code (type L to list all codes): 8e Changed type of partition Linux to Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.查看[rootYL ~]# fdisk -l Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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 label type: dos Disk identifier: 0x000d7b77 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 17803263 8388608 82 Linux swap / Solaris /dev/sda3 17803264 125829119 54012928 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0x39f9ec19 Device Boot Start End Blocks Id System /dev/sdb1 2048 8390655 4194304 8e Linux LVM /dev/sdb2 8390656 18876415 5242880 8e Linux LVM Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0xe57013ca Device Boot Start End Blocks Id System /dev/sdc1 2048 10487807 5242880 83 Linux3.3 创建物理卷[rootYL ~]# #查看系统是否有PV [rootYL ~]# pvdisplay [rootYL ~]# #创建物理卷 [rootYL ~]# pvcreate /dev/sdb1 /dev/sdb2 Physical volume /dev/sdb1 successfully created. Physical volume /dev/sdb2 successfully created. [rootYL ~]# pvdisplay /dev/sdb2 is a new physical volume of 5.00 GiB --- NEW Physical volume --- PV Name /dev/sdb2 VG Name PV Size 5.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID vFVzor-Ik2A-hqxN-e1h5-88qS-foNB-man7ZT /dev/sdb1 is a new physical volume of 4.00 GiB --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 4.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID le0lRG-9F8i-gjLI-XG8x-60Ex-9D2T-JopzOz3.4 创建卷组[rootYL ~]# # 查看卷组 [rootYL ~]# vgdisplay [rootYL ~]# # 创建卷组 [rootYL ~]# vgcreate vg666 /dev/sdb1 /dev/sdb2 Volume group vg666 successfully created [rootYL ~]# vgdisplay --- Volume group --- VG Name vg666 System ID Format lvm2 Metadata Areas 2 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 2 Act PV 2 VG Size 8.99 GiB PE Size 4.00 MiB Total PE 2302 Alloc PE / Size 0 / 0 Free PE / Size 2302 / 8.99 GiB VG UUID VZy28x-UYp8-kwrc-UVIS-0MV1-UN2S-amGwW03.5 创建逻辑卷[rootYL ~]# #查看逻辑卷 [rootYL ~]# lvdisplay [rootYL ~]# lvcreate -L 500M -n lv66 vg666 Logical volume lv66 created. [rootYL ~]# lvdisplay --- Logical volume --- LV Path /dev/vg666/lv66 LV Name lv66 VG Name vg666 LV UUID qBTDPz-oLLQ-eP3Z-62Zc-VmLQ-BSDp-2uyBGP LV Write Access read/write LV Creation host, time YL, 2025-10-26 14:32:23 0800 LV Status available # open 0 LV Size 500.00 MiB Current LE 125 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:03.6 格式化逻辑卷[rootYL ~]# # 格式化 [rootYL ~]# mkfs.xfs /dev/vg666/lv66 meta-data/dev/vg666/lv66 isize512 agcount4, agsize32000 blks sectsz512 attr2, projid32bit1 crc1 finobt0, sparse0 data bsize4096 blocks128000, imaxpct25 sunit0 swidth0 blks naming version 2 bsize4096 ascii-ci0 ftype1 log internal log bsize4096 blocks855, version2 sectsz512 sunit0 blks, lazy-count1 realtime none extsz4096 blocks0, rtextents0 [rootYL ~]# mkdir /yl [rootYL ~]# mount /dev/vg666/lv66 /yl/ [rootYL ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sdc1 xfs 5.0G 33M 5.0G 1% /root/Cloud_File /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 28K 781M 1% /run/user/0 /dev/sr0 iso9660 9.5G 9.5G 0 100% /run/media/root/CentOS 7 x86_64 /dev/mapper/vg666-lv66 xfs 497M 26M 472M 6% /yl3.7 LV逻辑卷扩容[rootYL ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sdc1 xfs 5.0G 33M 5.0G 1% /root/Cloud_File /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 28K 781M 1% /run/user/0 /dev/sr0 iso9660 9.5G 9.5G 0 100% /run/media/root/CentOS 7 x86_64 /dev/mapper/vg666-lv66 xfs 497M 26M 472M 6% /yl [rootYL ~]# # 分区中添加400M文件 [rootYL ~]# cd /yl [rootYL yl]# dd if/dev/zero ofaaa bs1M count400 4000 records in 4000 records out 419430400 bytes (419 MB) copied, 3.90542 s, 107 MB/s [rootYL yl]# sync [rootYL yl]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sdc1 xfs 5.0G 33M 5.0G 1% /root/Cloud_File /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 28K 781M 1% /run/user/0 /dev/sr0 iso9660 9.5G 9.5G 0 100% /run/media/root/CentOS 7 x86_64 /dev/mapper/vg666-lv66 xfs 497M 426M 72M 86% /yl [rootYL yl]# # 如何做分区扩容 [rootYL yl]# vgs VG #PV #LV #SN Attr VSize VFree vg666 2 1 0 wz--n- 8.99g 8.50g [rootYL yl]# #LV 逻辑卷扩容 [rootYL yl]# lvextend -L 500M /dev/vg666/lv66 Size of logical volume vg666/lv66 changed from 500.00 MiB (125 extents) to 1000.00 MiB (250 extents). Logical volume vg666/lv66 successfully resized. [rootYL yl]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv66 vg666 -wi-ao---- 1000.00m [rootYL yl]# # 刷新文件系统大小 [rootYL yl]# xfs_growfs /yl/ meta-data/dev/mapper/vg666-lv66 isize512 agcount4, agsize32000 blks sectsz512 attr2, projid32bit1 crc1 finobt0 spinodes0 data bsize4096 blocks128000, imaxpct25 sunit0 swidth0 blks naming version 2 bsize4096 ascii-ci0 ftype1 log internal bsize4096 blocks855, version2 sectsz512 sunit0 blks, lazy-count1 realtime none extsz4096 blocks0, rtextents0 data blocks changed from 128000 to 256000 [rootYL yl]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 13M 3.8G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda3 xfs 52G 6.2G 46G 12% / /dev/sdc1 xfs 5.0G 33M 5.0G 1% /root/Cloud_File /dev/sda1 xfs 497M 173M 324M 35% /boot tmpfs tmpfs 781M 28K 781M 1% /run/user/0 /dev/sr0 iso9660 9.5G 9.5G 0 100% /run/media/root/CentOS 7 x86_64 /dev/mapper/vg666-lv66 xfs 997M 426M 572M 43% /yl3.8 VG卷组扩容[rootYL yl]# # 如果卷组VG容量不足如何 [rootYL yl]# # 继续添加pp 物理分区 [rootYL yl]# fdisk /dev/sdb 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. Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): Using default response p Partition number (3,4, default 3): First sector (18876416-41943039, default 18876416): Using default value 18876416 Last sector, sectors or size{K,M,G} (18876416-41943039, default 41943039): 5G Partition 3 of type Linux and of size 5 GiB is set Command (m for help): t Partition number (1-3, default 3): 8e Partition number (1-3, default 3): Hex code (type L to list all codes): 8e Changed type of partition Linux to Linux LVM Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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 label type: dos Disk identifier: 0x39f9ec19 Device Boot Start End Blocks Id System /dev/sdb1 2048 8390655 4194304 8e Linux LVM /dev/sdb2 8390656 18876415 5242880 8e Linux LVM /dev/sdb3 18876416 29362175 5242880 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. 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. [rootYL yl]# # 刷新重新加载 [rootYL yl]# partprobe /dev/sdb [rootYL yl]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 60G 0 disk ├─sda1 8:1 0 500M 0 part /boot ├─sda2 8:2 0 8G 0 part [SWAP] └─sda3 8:3 0 51.5G 0 part / sdb 8:16 0 20G 0 disk ├─sdb1 8:17 0 4G 0 part │ └─vg666-lv66 253:0 0 1000M 0 lvm /yl ├─sdb2 8:18 0 5G 0 part └─sdb3 8:19 0 5G 0 part sdc 8:32 0 20G 0 disk └─sdc1 8:33 0 5G 0 part /root/Cloud_File sr0 11:0 1 9.5G 0 rom /run/media/root/CentOS 7 x86_64 [rootYL yl]# pvcreate /dev/sdb3 Physical volume /dev/sdb3 successfully created. [rootYL yl]# # VG扩容 [rootYL yl]# vgs VG #PV #LV #SN Attr VSize VFree vg666 2 1 0 wz--n- 8.99g 8.02g [rootYL yl]# vgextend vg666 /dev/sdb3 Volume group vg666 successfully extended [rootYL yl]# vgs VG #PV #LV #SN Attr VSize VFree vg666 3 1 0 wz--n- 13.99g 13.01g

更多文章