0 背景

迁移var目录的数据回sda盘中。

迁移前:

NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 931.5G  0 disk
|-sda1                    8:1    0   487M  0 part /boot
|-sda2                    8:2    0     1K  0 part
`-sda5                    8:5    0   931G  0 part
  |-HsServer--vg-root   254:2    0  23.3G  0 lvm  /
  |-HsServer--vg-var    254:3    0   9.3G  0 lvm
  |-HsServer--vg-swap_1 254:4    0   976M  0 lvm  [SWAP]
  `-HsServer--vg-tmp    254:5    0   1.9G  0 lvm  /tmp
sdb                       8:16   0 111.8G  0 disk
|-sdb1                    8:17   0   100M  0 part
|-sdb2                    8:18   0  67.9G  0 part
|-sdb3                    8:19   0     1K  0 part
`-sdb5                    8:21   0  43.8G  0 part
sdc                       8:32   0   1.8T  0 disk
|-sdc1                    8:33   0   500G  0 part
| `-Vol1-lvtest         254:1    0   500G  0 lvm  /var
`-sdc2                    8:34   0     1T  0 part
  `-Vol2-lvtest         254:0    0  1024G  0 lvm  /home

迁移后的结果:

NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 931.5G  0 disk
|-sda1                    8:1    0   487M  0 part /boot
|-sda2                    8:2    0     1K  0 part
`-sda5                    8:5    0   931G  0 part
  |-HsServer--vg-root   254:0    0  23.3G  0 lvm  /
  |-HsServer--vg-swap_1 254:1    0   976M  0 lvm  [SWAP]
  |-HsServer--vg-tmp    254:2    0   1.9G  0 lvm  /tmp
  `-HsServer--vg-var    254:3    0   300G  0 lvm  /var
sdb                       8:16   0 111.8G  0 disk
|-sdb1                    8:17   0   100M  0 part
|-sdb2                    8:18   0  67.9G  0 part
|-sdb3                    8:19   0     1K  0 part
`-sdb5                    8:21   0  43.8G  0 part
sdc                       8:32   0   1.8T  0 disk
|-sdc1                    8:33   0   500G  0 part
| `-Vol2-lvtest         254:4    0     1T  0 lvm  /home
`-sdc2                    8:34   0     1T  0 part
  `-Vol2-lvtest         254:4    0     1T  0 lvm  /home

1 查看当前情况

在sda5中,创建新分区,然后把sdc1分区的var文件放到sda5的分区中。

1.1 查看磁盘空间

root@HsServer:~# df -h
Filesystem                     Size  Used Avail Use% Mounted on
udev                            11G     0   11G   0% /dev
tmpfs                          2.2G  3.2M  2.2G   1% /run
/dev/mapper/HsServer--vg-root   23G   11G   11G  50% /
tmpfs                           11G     0   11G   0% /dev/shm
tmpfs                          5.0M   16K  5.0M   1% /run/lock
/dev/mapper/Vol1-lvtest        492G  9.6G  457G   3% /var
/dev/mapper/Vol2-lvtest       1007G   56G  901G   6% /home
/dev/mapper/HsServer--vg-tmp   1.8G   80K  1.7G   1% /tmp
/dev/sda1                      455M  216M  215M  51% /boot
tmpfs                          2.2G   56K  2.2G   1% /run/user/113
tmpfs                          2.2G   44K  2.2G   1% /run/user/0

1.2 列出所有可用块设备的信息,而且还能显示他们之间的依赖关系

root@HsServer:~# lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 931.5G  0 disk
|-sda1                    8:1    0   487M  0 part /boot
|-sda2                    8:2    0     1K  0 part
`-sda5                    8:5    0   931G  0 part
  |-HsServer--vg-root   254:2    0  23.3G  0 lvm  /
  |-HsServer--vg-var    254:3    0   9.3G  0 lvm
  |-HsServer--vg-swap_1 254:4    0   976M  0 lvm  [SWAP]
  `-HsServer--vg-tmp    254:5    0   1.9G  0 lvm  /tmp
sdb                       8:16   0 111.8G  0 disk
|-sdb1                    8:17   0   100M  0 part
|-sdb2                    8:18   0  67.9G  0 part
|-sdb3                    8:19   0     1K  0 part
`-sdb5                    8:21   0  43.8G  0 part
sdc                       8:32   0   1.8T  0 disk
|-sdc1                    8:33   0   500G  0 part
| `-Vol1-lvtest         254:1    0   500G  0 lvm  /var
`-sdc2                    8:34   0     1T  0 part
  `-Vol2-lvtest         254:0    0  1024G  0 lvm  /home

1.3 查看可用磁盘

root@HsServer:~# fdisk -l
Disk /dev/sdb: 111.79 GiB, 120034123776 bytes, 234441648 sectors
Disk model: INTEL SSDSC2BW12
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: 0x36e496ea

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sdb1  *         2048    206847    204800  100M  7 HPFS/NTFS/exFAT
/dev/sdb2          206848 142580655 142373808 67.9G  7 HPFS/NTFS/exFAT
/dev/sdb3       142580656 234441647  91860992 43.8G  f W95 Ext'd (LBA)
/dev/sdb5       142580719 234441647  91860929 43.8G  7 HPFS/NTFS/exFAT


Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST31000528AS
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: 0xb8213fff

Device     Boot   Start        End    Sectors  Size Id Type
/dev/sda1  *       2048     999423     997376  487M 83 Linux
/dev/sda2       1001470 1953523711 1952522242  931G  5 Extended
/dev/sda5       1001472 1953523711 1952522240  931G 8e Linux LVM


Disk /dev/sdc: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000DM001-1ER1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x97be5b6a

Device     Boot      Start        End    Sectors  Size Id Type
/dev/sdc1             2048 1048578047 1048576000  500G  1 FAT12
/dev/sdc2       1048578048 3196061695 2147483648    1T 8e Linux LVM


Disk /dev/mapper/Vol2-lvtest: 1024 GiB, 1099507433472 bytes, 2147475456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/Vol1-lvtest: 500 GiB, 536866717696 bytes, 1048567808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/HsServer--vg-root: 23.28 GiB, 24998051840 bytes, 48824320 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/HsServer--vg-var: 9.31 GiB, 9999220736 bytes, 19529728 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/HsServer--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 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/HsServer--vg-tmp: 1.86 GiB, 1996488704 bytes, 3899392 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
root@HsServer:~# vgdisplay mapper
  Volume group "mapper" not found
  Cannot process volume group mapper
root@HsServer:~# vgdisplay /dev/mapper
  Volume group "mapper" not found
  Cannot process volume group mapper

1.4 查看卷组

root@HsServer:~# vgdisplay
  --- Volume group ---
  VG Name               Vol2
  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               <1024.00 GiB
  PE Size               4.00 MiB
  Total PE              262143
  Alloc PE / Size       262143 / <1024.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               lFyMbP-ZLeb-Ux0U-b4Ss-wUva-8cfP-7dTZXE

  --- Volume group ---
  VG Name               Vol1
  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               <500.00 GiB
  PE Size               4.00 MiB
  Total PE              127999
  Alloc PE / Size       127999 / <500.00 GiB
  Free  PE / Size       0 / 0
  VG UUID               0gCdSf-eX51-ZlfK-TYoq-BVLe-Rg86-CLj7uT

  --- Volume group ---
  VG Name               HsServer-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               931.03 GiB
  PE Size               4.00 MiB
  Total PE              238344
  Alloc PE / Size       9064 / <35.41 GiB
  Free  PE / Size       229280 / 895.62 GiB
  VG UUID               SrHizr-6keh-Hwce-6Bmg-eklk-GlbG-BvTaQ2
  
  root@HsServer:~# vgdisplay  HsServer-vg
  --- Volume group ---
  VG Name               HsServer-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               931.03 GiB
  PE Size               4.00 MiB
  Total PE              238344
  Alloc PE / Size       9064 / <35.41 GiB
  Free  PE / Size       229280 / 895.62 GiB
  VG UUID               SrHizr-6keh-Hwce-6Bmg-eklk-GlbG-BvTaQ2

2 卷组中创建逻辑卷

root@HsServer:~# lvcreate -L 300G -n var HsServer-vg
WARNING: ext4 signature detected on /dev/HsServer-vg/var at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/HsServer-vg/var.
  Logical volume "var" created.
  • 1,-l选项定义了要为逻辑卷指定多少可用的卷组空间。注意,你可以按照卷组空闲空间的百分比来指定这个值。本例中为新逻辑卷使用了所有的空闲空间(或者用-L选项以字节、千字节(KB)、兆字节(MB)或吉字节(GB)为单位来指定实际的大小)。
  • 2,-n选项允许你为逻辑卷指定一个名称(在本例中称作var)

查看磁盘分区情况:

root@HsServer:~# fdisk -l

Disk /dev/mapper/HsServer--vg-var: 300 GiB, 322122547200 bytes, 629145600 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 创建文件系统

root@HsServer:~# sudo mkfs.ext4  /dev/mapper/HsServer--vg-var
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 78643200 4k blocks and 19660800 inodes
Filesystem UUID: dc8871ab-f3b6-476d-b5d4-9f4e6f5b5b5d
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks):
done
Writing superblocks and filesystem accounting information: done

如果没有创建文件系统,则会爆出如下的错误:

mount: /backVar: wrong fs type, bad option, bad superblock on /dev/mapper/HsServer--vg-var, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

4 创建临时文件夹并挂载,然后备份源文件

root@HsServer:~# mkdir /backVar/
root@HsServer:~# mount /dev/mapper/HsServer--vg-var /backVar
root@HsServer:~# cp -r /var/* /backVar/

5 修改开机挂载配置

5.1 查看原配置文件

root@HsServer:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/HsServer--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=de772acf-c0c7-4dbc-b213-2ce826d6e055 /boot           ext2    defaults        0       2
#/dev/mapper/HsServer--vg-home /home           ext4    defaults        0       2
/dev/mapper/HsServer--vg-tmp /tmp            ext4    defaults        0       2
#/dev/mapper/HsServer--vg-var /var            ext4    defaults        0       2
/dev/mapper/HsServer--vg-swap_1 none            swap    sw              0       0
/dev/Vol1/lvtest /var ext4  defaults 0 2
/dev/Vol2/lvtest /home ext4 defaults 0 2

5.2 修改配置文件

root@HsServer:~# vi /etc/fstab

添加新挂载内容:/dev/mapper/HsServer--vg-var /var

注释掉原挂载内容:/dev/Vol1/lvtest /var ext4 defaults 0 2

然后重启计算机,reboot

查看结果(可以看到,已经成功更换挂载的盘):

root@HsServer:~# df -h
Filesystem                     Size  Used Avail Use% Mounted on
udev                            11G     0   11G   0% /dev
tmpfs                          2.2G  2.9M  2.2G   1% /run
/dev/mapper/HsServer--vg-root   23G   11G   11G  50% /
tmpfs                           11G     0   11G   0% /dev/shm
tmpfs                          5.0M   16K  5.0M   1% /run/lock
/dev/mapper/Vol2-lvtest       1007G   56G  901G   6% /home
/dev/sda1                      455M  216M  215M  51% /boot
/dev/mapper/HsServer--vg-tmp   1.8G   80K  1.7G   1% /tmp
/dev/mapper/HsServer--vg-var   295G  9.5G  270G   4% /var
tmpfs                          2.2G   56K  2.2G   1% /run/user/113
tmpfs                          2.2G   44K  2.2G   1% /run/user/0
root@HsServer:~# lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 931.5G  0 disk
|-sda1                    8:1    0   487M  0 part /boot
|-sda2                    8:2    0     1K  0 part
`-sda5                    8:5    0   931G  0 part
  |-HsServer--vg-root   254:0    0  23.3G  0 lvm  /
  |-HsServer--vg-swap_1 254:1    0   976M  0 lvm  [SWAP]
  |-HsServer--vg-tmp    254:2    0   1.9G  0 lvm  /tmp
  `-HsServer--vg-var    254:3    0   300G  0 lvm  /var
sdb                       8:16   0 111.8G  0 disk
|-sdb1                    8:17   0   100M  0 part
|-sdb2                    8:18   0  67.9G  0 part
|-sdb3                    8:19   0     1K  0 part
`-sdb5                    8:21   0  43.8G  0 part
sdc                       8:32   0   1.8T  0 disk
|-sdc1                    8:33   0   500G  0 part
| `-Vol1-lvtest         254:5    0   500G  0 lvm
`-sdc2                    8:34   0     1T  0 part
  `-Vol2-lvtest         254:4    0  1024G  0 lvm  /home

6 删除原始分区

删除LVM之前创建的物理卷,卷组,逻辑卷时,删除顺序应该与创建时的顺序相反。也就是卸载文件系统,删除逻辑卷,删除卷组,删除物理卷。卸载文件系统时需要注意:如果之前没有更新/etc/fstab文件,则需要更新。

1,卸载文件系统

umount /dev/mapper/Vol1-lvtest

2,删除逻辑卷
 lvremove /dev/mapper/Vol1-lvtest

3,删除卷组
 vgremove Vol1

4,删除物理卷
pvremove /dev/sda{1,2,3,5}

6.1 卸载文件系统

查看磁盘的信息:

root@HsServer:~# blkid
/dev/mapper/HsServer--vg-swap_1: UUID="ebdc78fa-f920-47b4-b3ce-4486e0993691" TYPE="swap"
/dev/sdb2: BLOCK_SIZE="512" UUID="D470CFB970CFA09A" TYPE="ntfs" PARTUUID="36e496ea-02"
/dev/sdb5: BLOCK_SIZE="512" UUID="0004A422000CA487" TYPE="ntfs" PARTUUID="36e496ea-05"
/dev/sdb1: LABEL="M-gM-3M-;M-gM-;M-^_M-dM-?M-^]M-gM-^UM-^Y" BLOCK_SIZE="512" UUID="9400C91000C8FA6E" TYPE="ntfs" PARTUUID="36e496ea-01"
/dev/mapper/Vol2-lvtest: UUID="0667b0ac-112e-49b9-b951-b433e559233e" BLOCK_SIZE="4096" TYPE="ext4"
/dev/mapper/HsServer--vg-tmp: UUID="307b0159-746b-4476-866c-ebc2b81632f8" BLOCK_SIZE="4096" TYPE="ext4"
/dev/mapper/HsServer--vg-root: UUID="7117eb71-a277-44b7-a7f8-37418817968d" BLOCK_SIZE="4096" TYPE="ext4"
/dev/sdc2: UUID="IUHj8a-1VcD-ggMn-UzhK-NNBN-ohhT-Zzci3g" TYPE="LVM2_member" PARTUUID="97be5b6a-02"
/dev/sdc1: UUID="roJf0h-R7Bt-tVnm-ml2V-h9ac-fyLZ-jMEa7N" TYPE="LVM2_member" PARTUUID="97be5b6a-01"
/dev/sda5: UUID="W5i2fK-Up60-LCGp-qIrI-e1q1-Ycye-LwEhpl" TYPE="LVM2_member" PARTUUID="b8213fff-05"
/dev/sda1: UUID="de772acf-c0c7-4dbc-b213-2ce826d6e055" BLOCK_SIZE="1024" TYPE="ext2" PARTUUID="b8213fff-01"
/dev/mapper/Vol1-lvtest: UUID="f085a0cc-2c4d-42d1-a8e0-601abbf9a10e" BLOCK_SIZE="4096" TYPE="ext4"
/dev/mapper/HsServer--vg-var: UUID="dc8871ab-f3b6-476d-b5d4-9f4e6f5b5b5d" BLOCK_SIZE="4096" TYPE="ext4"
umount /dev/mapper/Vol1-lvtest

6.2 删除逻辑卷

root@HsServer:~# lvremove /dev/mapper/Vol1-lvtest
Do you really want to remove active logical volume Vol1/lvtest? [y/n]: y
  Logical volume "lvtest" successfully removed.

6.3 删除卷组

root@HsServer:~#  vgremove Vol1
  Volume group "Vol1" successfully removed

6.4 删除物理卷

root@HsServer:~# pvremove /dev/sdc1
  Labels on physical volume "/dev/sdc1" successfully wiped.

查看结果

root@HsServer:~# lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 931.5G  0 disk
|-sda1                    8:1    0   487M  0 part /boot
|-sda2                    8:2    0     1K  0 part
`-sda5                    8:5    0   931G  0 part
  |-HsServer--vg-root   254:0    0  23.3G  0 lvm  /
  |-HsServer--vg-swap_1 254:1    0   976M  0 lvm  [SWAP]
  |-HsServer--vg-tmp    254:2    0   1.9G  0 lvm  /tmp
  `-HsServer--vg-var    254:3    0   300G  0 lvm  /var
sdb                       8:16   0 111.8G  0 disk
|-sdb1                    8:17   0   100M  0 part
|-sdb2                    8:18   0  67.9G  0 part
|-sdb3                    8:19   0     1K  0 part
`-sdb5                    8:21   0  43.8G  0 part
sdc                       8:32   0   1.8T  0 disk
|-sdc1                    8:33   0   500G  0 part
`-sdc2                    8:34   0     1T  0 part
  `-Vol2-lvtest         254:4    0  1024G  0 lvm  /home

6.5 删除分区

root@HsServer:~# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.


Command (m for help): p

Disk /dev/sdc: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000DM001-1ER1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x97be5b6a

Device     Boot      Start        End    Sectors  Size Id Type
/dev/sdc1             2048 1048578047 1048576000  500G  1 FAT12
/dev/sdc2       1048578048 3196061695 2147483648    1T 8e Linux LVM

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

Command (m for help): w
The partition table has been altered.
Syncing disks.

查看结果:

root@HsServer:~# lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 931.5G  0 disk
|-sda1                    8:1    0   487M  0 part /boot
|-sda2                    8:2    0     1K  0 part
`-sda5                    8:5    0   931G  0 part
  |-HsServer--vg-root   254:0    0  23.3G  0 lvm  /
  |-HsServer--vg-swap_1 254:1    0   976M  0 lvm  [SWAP]
  |-HsServer--vg-tmp    254:2    0   1.9G  0 lvm  /tmp
  `-HsServer--vg-var    254:3    0   300G  0 lvm  /var
sdb                       8:16   0 111.8G  0 disk
|-sdb1                    8:17   0   100M  0 part
|-sdb2                    8:18   0  67.9G  0 part
|-sdb3                    8:19   0     1K  0 part
`-sdb5                    8:21   0  43.8G  0 part
sdc                       8:32   0   1.8T  0 disk
`-sdc2                    8:34   0     1T  0 part
  `-Vol2-lvtest         254:4    0  1024G  0 lvm  /home

7 扩容

7.1 查看之前的状况

root@HsServer:~# df -Th
Filesystem                    Type      Size  Used Avail Use% Mounted on
udev                          devtmpfs   11G     0   11G   0% /dev
tmpfs                         tmpfs     2.2G  3.1M  2.2G   1% /run
/dev/mapper/HsServer--vg-root ext4       23G   11G   11G  50% /
tmpfs                         tmpfs      11G     0   11G   0% /dev/shm
tmpfs                         tmpfs     5.0M   16K  5.0M   1% /run/lock
/dev/mapper/Vol2-lvtest       ext4     1007G   56G  901G   6% /home
/dev/sda1                     ext2      455M  216M  215M  51% /boot
/dev/mapper/HsServer--vg-tmp  ext4      1.8G   80K  1.7G   1% /tmp
/dev/mapper/HsServer--vg-var  ext4      295G  9.5G  270G   4% /var
tmpfs                         tmpfs     2.2G   56K  2.2G   1% /run/user/113
tmpfs                         tmpfs     2.2G   44K  2.2G   1% /run/user/0

root@HsServer:~# lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda                       8:0    0 931.5G  0 disk
|-sda1                    8:1    0   487M  0 part /boot
|-sda2                    8:2    0     1K  0 part
`-sda5                    8:5    0   931G  0 part
  |-HsServer--vg-root   254:0    0  23.3G  0 lvm  /
  |-HsServer--vg-swap_1 254:1    0   976M  0 lvm  [SWAP]
  |-HsServer--vg-tmp    254:2    0   1.9G  0 lvm  /tmp
  `-HsServer--vg-var    254:3    0   300G  0 lvm  /var
sdb                       8:16   0 111.8G  0 disk
|-sdb1                    8:17   0   100M  0 part
|-sdb2                    8:18   0  67.9G  0 part
|-sdb3                    8:19   0     1K  0 part
`-sdb5                    8:21   0  43.8G  0 part
sdc                       8:32   0   1.8T  0 disk
|-sdc1                    8:33   0   500G  0 part
| `-Vol2-lvtest         254:4    0     1T  0 lvm  /home
`-sdc2                    8:34   0     1T  0 part
  `-Vol2-lvtest         254:4    0     1T  0 lvm  /home

7.2 扩展物理卷

root@HsServer:~# lvextend -L +10G /dev/mapper/HsServer--vg-var
  Size of logical volume HsServer-vg/var changed from 300.00 GiB (76800 extents) to 310.00 GiB (79360 extents).
  Logical volume HsServer-vg/var successfully resized.

查看扩容后的结果:

root@HsServer:~# df -TH
Filesystem                    Type      Size  Used Avail Use% Mounted on
udev                          devtmpfs   12G     0   12G   0% /dev
tmpfs                         tmpfs     2.3G  3.3M  2.3G   1% /run
/dev/mapper/HsServer--vg-root ext4       25G   12G   12G  50% /
tmpfs                         tmpfs      12G     0   12G   0% /dev/shm
tmpfs                         tmpfs     5.3M   17k  5.3M   1% /run/lock
/dev/mapper/Vol2-lvtest       ext4      1.1T   60G  967G   6% /home
/dev/sda1                     ext2      477M  227M  225M  51% /boot
/dev/mapper/HsServer--vg-tmp  ext4      2.0G   82k  1.9G   1% /tmp
/dev/mapper/HsServer--vg-var  ext4      316G   11G  290G   4% /var
tmpfs                         tmpfs     2.3G   58k  2.3G   1% /run/user/113
tmpfs                         tmpfs     2.3G   46k  2.3G   1% /run/user/0

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部