玩会儿LVM2

news/2025/3/16 1:06:46/

首先新建几个分区,再调个格式。

Command (m for help): t
Partition number (1-9): 8
Hex code (type L to list codes): 8e
Changed system type of partition 8 to 8e (Linux LVM)

Command (m for help): t
Partition number (1-9): 9
Hex code (type L to list codes): 8e
Changed system type of partition 9 to 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: 设备或资源忙.
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.

同步一下
[root@sctest 桌面]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
BLKPG: Device or resource busy
error adding partition 7
BLKPG: Device or resource busy
error adding partition 8
BLKPG: Device or resource busy
error adding partition 9
[root@sctest 桌面]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
BLKPG: Device or resource busy
error adding partition 3
BLKPG: Device or resource busy
error adding partition 4
BLKPG: Device or resource busy
error adding partition 5
BLKPG: Device or resource busy
error adding partition 6
BLKPG: Device or resource busy
error adding partition 7
BLKPG: Device or resource busy
error adding partition 8
BLKPG: Device or resource busy
error adding partition 9
[root@sctest 桌面]# pv
bash: pv: command not found
[root@sctest 桌面]# pv
pvchange   pvck       pvcreate   pvdisplay  pvmove     pvremove   pvresize   pvs        pvscan     pv.sh      
[root@sctest 桌面]# blkid
/dev/sda2: UUID="a52d371b-98b3-4760-9bae-ffa65741c29f" TYPE="ext4" 
/dev/sda3: UUID="98401299-31a2-4d31-a7f5-02d37b0cf894" TYPE="swap" 
/dev/sda5: UUID="e9d20116-d021-49c6-9352-9a601f3e8aa3" TYPE="ext4" 
/dev/sda1: UUID="28def929-d957-4af2-9ff5-b39fdc0e9fd5" TYPE="ext4" 
/dev/sda6: UUID="e6805083-14b0-4d65-bc7c-7f466a698a7c" TYPE="ext4" 
[root@sctest 桌面]# fdisk /dev/sda

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0009ecf4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       51057   409600000   83  Linux
/dev/sda3           51057       53224    17408000   82  Linux swap / Solaris
/dev/sda4           53224      121601   549239008+   5  Extended
/dev/sda5           53225       66280   104864288   83  Linux
/dev/sda6           66281       66935     5253256   8e  Linux LVM
/dev/sda7           66936       67980     8393960+  8e  Linux LVM
Partition 7 does not start on physical sector boundary.
/dev/sda8           67981       69287    10490416+  8e  Linux LVM
Partition 8 does not start on physical sector boundary.
/dev/sda9           69288       71899    20980888+  8e  Linux LVM
Partition 9 does not start on physical sector boundary.

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: 设备或资源忙.
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.
[root@sctest 桌面]# pvs
[root@sctest 桌面]# pvmove /dev/sda6
  Failed to find physical volume "/dev/sda6".
  Run `pvmove --help' for more information.

将6789分区创建为PV
[root@sctest 桌面]# pvcreate -v /dev/sda6
    Wiping cache of LVM-capable devices
    Set up physical volume for "/dev/sda6" with 10506512 available sectors
    Zeroing start of device /dev/sda6
    Writing physical volume data to disk "/dev/sda6"
  Physical volume "/dev/sda6" successfully created
[root@sctest 桌面]# pvcreate -v /dev/sda7
    Wiping cache of LVM-capable devices
    Set up physical volume for "/dev/sda7" with 16787921 available sectors
    Zeroing start of device /dev/sda7
    Writing physical volume data to disk "/dev/sda7"
  Physical volume "/dev/sda7" successfully created
[root@sctest 桌面]# pvcreate -v /dev/sda8
    Wiping cache of LVM-capable devices
    Set up physical volume for "/dev/sda8" with 20980833 available sectors
    Zeroing start of device /dev/sda8
    Writing physical volume data to disk "/dev/sda8"
  Physical volume "/dev/sda8" successfully created
[root@sctest 桌面]# pvcreate -v /dev/sda9
    Wiping cache of LVM-capable devices
    Set up physical volume for "/dev/sda9" with 41961777 available sectors
    Zeroing start of device /dev/sda9
    Writing physical volume data to disk "/dev/sda9"
  Physical volume "/dev/sda9" successfully created
[root@sctest 桌面]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda6       lvm2 ----  5.01g  5.01g
  /dev/sda7       lvm2 ----  8.01g  8.01g
  /dev/sda8       lvm2 ---- 10.00g 10.00g
  /dev/sda9       lvm2 ---- 20.01g 20.01g
[root@sctest 桌面]# pvdisplay /dev/sda6
  "/dev/sda6" is a new physical volume of "5.01 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda6
  VG Name               
  PV Size               5.01 GiB
  Allocatable           NO                      #NO,因为还未加入VG
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               phIlht-xYXk-qFHl-ec2j-GqEd-FzGU-Hkn1vb
   
[root@sctest 桌面]# pvmove /dev/sda9
  No extents available for allocation
[root@sctest 桌面]# pvre
pvremove  pvresize  

删除PV
[root@sctest 桌面]# pvremove /dev/sda9
  Labels on physical volume "/dev/sda9" successfully wiped
[root@sctest 桌面]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda6       lvm2 ----  5.01g  5.01g
  /dev/sda7       lvm2 ----  8.01g  8.01g
  /dev/sda8       lvm2 ---- 10.00g 10.00g
[root@sctest 桌面]# pvcreate /dev/sda9
  Physical volume "/dev/sda9" successfully created
[root@sctest 桌面]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda6       lvm2 ----  5.01g  5.01g
  /dev/sda7       lvm2 ----  8.01g  8.01g
  /dev/sda8       lvm2 ---- 10.00g 10.00g
  /dev/sda9       lvm2 ---- 20.01g 20.01g
[root@sctest 桌面]# vg
vgcfgbackup    vgchange       vgconvert      vgdb           vgexport       vgimport       vgmerge        vgreduce       vgrename       vgscan         
vgcfgrestore   vgck           vgcreate       vgdisplay      vgextend       vgimportclone  vgmknodes      vgremove       vgs            vgsplit        
[root@sctest 桌面]# vgs
[root@sctest 桌面]# vgdisplay 

创建VG,包含一个PV 为sda6
[root@sctest 桌面]# vgcreate vg1 /dev/sda6
  Volume group "vg1" successfully created
[root@sctest 桌面]# vgd
vgdb       vgdisplay  
[root@sctest 桌面]# vgd
vgdb       vgdisplay  
[root@sctest 桌面]# vgdisplay 
  --- Volume group ---
  VG Name               vg1
  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               5.01 GiB     
  PE Size               4.00 MiB     #默认PE大小,非重建不可更改
  Total PE              1282
  Alloc PE / Size       0 / 0   
  Free  PE / Size       1282 / 5.01 GiB
  VG UUID               dG2bea-FB3v-5tws-f823-cdiW-ZDBx-HB25nI


PV信息   
[root@sctest 桌面]# pvdisplay 
  --- Physical volume ---
  PV Name               /dev/sda6
  VG Name               vg1
  PV Size               5.01 GiB / not usable 2.13 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              1282
  Free PE               1282
  Allocated PE          0
  PV UUID               phIlht-xYXk-qFHl-ec2j-GqEd-FzGU-Hkn1vb
   
  "/dev/sda7" is a new physical volume of "8.01 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda7
  VG Name               
  PV Size               8.01 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               Fzqf0J-83H6-ECvJ-Kyon-PvN9-QH2m-MmqVbZ
   
  "/dev/sda8" is a new physical volume of "10.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda8
  VG Name               
  PV Size               10.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               p7kems-MBfO-5i8c-0UGR-AZ4H-qvfb-70sFNj
   
  "/dev/sda9" is a new physical volume of "20.01 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda9
  VG Name               
  PV Size               20.01 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               YuNkL6-MJrW-v50K-Mn8f-ShEI-dtPW-pIjZG1
   
[root@sctest 桌面]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda6  vg1  lvm2 a--u  5.01g  5.01g
  /dev/sda7       lvm2 ----  8.01g  8.01g
  /dev/sda8       lvm2 ---- 10.00g 10.00g
  /dev/sda9       lvm2 ---- 20.01g 20.01g

VG扩展,加入sda7
[root@sctest 桌面]# vgextend vg1 /dev/sda7
  Volume group "vg1" successfully extended
[root@sctest 桌面]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda6  vg1  lvm2 a--u  5.01g  5.01g
  /dev/sda7  vg1  lvm2 a--u  8.00g  8.00g
  /dev/sda8       lvm2 ---- 10.00g 10.00g
  /dev/sda9       lvm2 ---- 20.01g 20.01g
[root@sctest 桌面]# vgdisplay vg1
  --- Volume group ---
  VG Name               vg1
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  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               13.01 GiB    #扩展后大小变为13G
  PE Size               4.00 MiB
  Total PE              3331
  Alloc PE / Size       0 / 0   
  Free  PE / Size       3331 / 13.01 GiB
  VG UUID               dG2bea-FB3v-5tws-f823-cdiW-ZDBx-HB25nI
   
[root@sctest 桌面]# vgextend vg1 /dev/sda8
  Volume group "vg1" successfully extended
[root@sctest 桌面]# vgextend vg1 /dev/sda9
  Volume group "vg1" successfully extended
[root@sctest 桌面]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda6  vg1  lvm2 a--u  5.01g  5.01g
  /dev/sda7  vg1  lvm2 a--u  8.00g  8.00g
  /dev/sda8  vg1  lvm2 a--u 10.00g 10.00g
  /dev/sda9  vg1  lvm2 a--u 20.01g 20.01g
[root@sctest 桌面]# vgdisplay vg1
  --- Volume group ---
  VG Name               vg1
  System ID             
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               43.02 GiB
  PE Size               4.00 MiB
  Total PE              11013
  Alloc PE / Size       0 / 0   
  Free  PE / Size       11013 / 43.02 GiB
  VG UUID               dG2bea-FB3v-5tws-f823-cdiW-ZDBx-HB25nI
   准备缩减VG,缩减之前,将要移除的PV数据转移
[root@sctest 桌面]# pvmove /dev/sda9
  No data to move for vg1
[root@sctest 桌面]# vgreduce vg1 /dev/sda9
  Removed "/dev/sda9" from volume group "vg1"

VG缩减完成
[root@sctest 桌面]# pvs
  PV         VG   Fmt  Attr PSize  PFree 
  /dev/sda6  vg1  lvm2 a--u  5.01g  5.01g
  /dev/sda7  vg1  lvm2 a--u  8.00g  8.00g
  /dev/sda8  vg1  lvm2 a--u 10.00g 10.00g
  /dev/sda9       lvm2 ---- 20.01g 20.01g
[root@sctest 桌面]# lvs
[root@sctest 桌面]# lvdisplay 

创建LV,在vg1中创建大小为2G,命名为lv1的逻辑卷。创建完成后相当于一个分区,可以进行文件系统格式化和挂载。
[root@sctest 桌面]# lvcreate -L 2G -n lv1 vg1
  Logical volume "lv1" created.

逻辑卷路径:/dev/mapper/vg1-lv1 或者 /dev/vg1/lv1
[root@sctest 桌面]# ls /dev/mapper
control  vg1-lv1
[root@sctest 桌面]# ls /dev
autofs         console          dvd    hidraw0     loop0  lp0      net                 ptmx   ram14  ram8    scd0  sda7      sr0     tty10  tty18  tty25  tty32  tty4   tty47  tty54  tty61  ttyS2    vcs   vcsa1        vhost-net
block          core             dvdrw  hpet        loop1  lp1      network_latency     pts    ram15  ram9    sda   sda8      stderr  tty11  tty19  tty26  tty33  tty40  tty48  tty55  tty62  ttyS3    vcs1  vcsa2        video0
bsg            cpu              fb     hugepages   loop2  lp2      network_throughput  ram0   ram2   random  sda1  sda9      stdin   tty12  tty2   tty27  tty34  tty41  tty49  tty56  tty63  uinput   vcs2  vcsa3        watchdog
btrfs-control  cpu_dma_latency  fb0    hvc0        loop3  lp3      null                ram1   ram3   raw     sda2  sg0       stdout  tty13  tty20  tty28  tty35  tty42  tty5   tty57  tty7   urandom  vcs3  vcsa4        zero
bus            crash            fb1    infiniband  loop4  MAKEDEV  nvram               ram10  ram4   rfkill  sda3  sg1       systty  tty14  tty21  tty29  tty36  tty43  tty50  tty58  tty8   usbmon0  vcs4  vcsa5
cdrom          disk             fd     input       loop5  mapper   oldmem              ram11  ram5   root    sda4  shm       tty     tty15  tty22  tty3   tty37  tty44  tty51  tty59  tty9   usbmon1  vcs5  vcsa6
cdrw           dm-0             full   kmsg        loop6  mcelog   port                ram12  ram6   rtc     sda5  snapshot  tty0    tty16  tty23  tty30  tty38  tty45  tty52  tty6   ttyS0  usbmon2  vcs6  vg1
char           dri              fuse   log         loop7  mem      ppp                 ram13  ram7   rtc0    sda6  snd       tty1    tty17  tty24  tty31  tty39  tty46  tty53  tty60  ttyS1  v4l      vcsa  vga_arbiter
[root@sctest 桌面]# ls /dev/vg1
lv1

为路径/dev/vg1/lv1下的逻辑卷创建文件系统,格式化为ext4,块大小1024,卷标LV1,
[root@sctest 桌面]# mke2fs -t ext4 -b 1024 -L LV1 /dev/vg1/lv1
mke2fs 1.41.12 (17-May-2010)
Warning: specified blocksize 1024 is less than device physical sectorsize 4096
文件系统标签=LV1
操作系统:Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=4 blocks, Stripe width=0 blocks
131072 inodes, 2097152 blocks
104857 blocks (5.00%) reserved for the super user
第一个数据块=1
Maximum filesystem blocks=69206016
256 block groups
8192 blocks per group, 8192 fragments per group
512 inodes per group
Superblock backups stored on blocks: 
    8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, 663553, 
    1024001, 1990657

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@sctest 桌面]# cd /home
[root@sctest home]# ls /
bin  boot  cgroup  dev  etc  home  lib  lib64  lost+found  media  misc  mnt  net  opt  proc  root  sbin  selinux  srv  sys  tmp  usr  var
[root@sctest home]# cd h
bash: cd: h: 没有那个文件或目录

逻辑卷挂载到/test1
[root@sctest home]# mkdir /test1
[root@sctest home]# ls /test1/
[root@sctest home]# mount /dev/vg1/lv1 /test1/
[root@sctest home]# ls /test1/
lost+found
[root@sctest home]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/sda5 on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/RHEL-6.9 Server.x86_64 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
/dev/mapper/vg1-lv1 on /test1 type ext4 (rw)
[root@sctest home]# cd /test1/

复制两个文件到逻辑卷中,作为后续验证
[root@sctest test1]# cp /etc/issue /test1/
[root@sctest test1]# cp /etc//grub.conf  /test1/
[root@sctest test1]# ls
grub.conf  issue  lost+found
[root@sctest test1]# cat issue
Red Hat Enterprise Linux Server release 6.9 (Santiago)
Kernel \r on an \m

[root@sctest test1]# cd

扩展/dev/vg1/lv1逻辑卷,扩展到5G大小
[root@sctest ~]# lvextend -L 5G /dev/vg1/lv1
  Size of logical volume vg1/lv1 changed from 2.00 GiB (512 extents) to 5.00 GiB (1280 extents).
  Logical volume lv1 successfully resized.

扩展完成后查看大小仍为2G
[root@sctest ~]# df -lh
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda2            385G  5.0G  360G   2% /
tmpfs                1.9G  332K  1.9G   1% /dev/shm
/dev/sda1            477M   45M  407M  10% /boot
/dev/sda5             99G   60M   94G   1% /home
/dev/sr0             3.7G  3.7G     0 100% /media/RHEL-6.9 Server.x86_64
/dev/mapper/vg1-lv1  2.0G  3.1M  1.9G   1% /test1

重新挂载,还是2G
[root@sctest ~]# umount /test1/
[root@sctest ~]# mount /dev/vg1/lv1 /test1/
[root@sctest ~]# df -lh
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda2            385G  5.0G  360G   2% /
tmpfs                1.9G  332K  1.9G   1% /dev/shm
/dev/sda1            477M   45M  407M  10% /boot
/dev/sda5             99G   60M   94G   1% /home
/dev/sr0             3.7G  3.7G     0 100% /media/RHEL-6.9 Server.x86_64
/dev/mapper/vg1-lv1  2.0G  3.1M  1.9G   1% /test1
[root@sctest ~]# 

重设文件系统逻辑边界
[root@sctest ~]# resize2fs /dev/vg1/lv1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg1/lv1 is mounted on /test1; on-line resizing required
old desc_blocks = 8, new_desc_blocks = 20
Performing an on-line resize of /dev/vg1/lv1 to 5242880 (1k) blocks.
The filesystem on /dev/vg1/lv1 is now 5242880 blocks long.

变更为5G

[root@sctest ~]# df -lh
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda2            385G  5.0G  360G   2% /
tmpfs                1.9G  332K  1.9G   1% /dev/shm
/dev/sda1            477M   45M  407M  10% /boot
/dev/sda5             99G   60M   94G   1% /home
/dev/sr0             3.7G  3.7G     0 100% /media/RHEL-6.9 Server.x86_64
/dev/mapper/vg1-lv1  4.9G  3.4M  4.7G   1% /test1

逻辑卷缩减:

1、卸载
[root@sctest ~]# umount /dev/vg1/lv1
[root@sctest ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/sda5 on /home type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/RHEL-6.9 Server.x86_64 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)

2、强制检查修复文件系统
[root@sctest ~]# e2fsck -f /dev/vg1/lv1
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
LV1: 13/327680 files (0.0% non-contiguous), 119695/5242880 blocks

3、缩减逻辑边界
[root@sctest ~]# resize2fs /dev/vg1/lv1 3G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg1/lv1 to 3145728 (1k) blocks.
The filesystem on /dev/vg1/lv1 is now 3145728 blocks long.

4、缩减物理边界

[root@sctest ~]# lvreduce -L 3G /dev/vg1/lv1
  WARNING: Reducing active logical volume to 3.00 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vg1/lv1? [y/n]: y
  Size of logical volume vg1/lv1 changed from 5.00 GiB (1280 extents) to 3.00 GiB (768 extents).
  Logical volume lv1 successfully resized.

5、重新挂载
[root@sctest ~]# mount /dev/vg1/lv1 /test1/
[root@sctest ~]# df -lh
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda2            385G  5.0G  360G   2% /
tmpfs                1.9G  332K  1.9G   1% /dev/shm
/dev/sda1            477M   45M  407M  10% /boot
/dev/sda5             99G   60M   94G   1% /home
/dev/sr0             3.7G  3.7G     0 100% /media/RHEL-6.9 Server.x86_64
/dev/mapper/vg1-lv1  3.0G  3.3M  2.8G   1% /test1

完成,由5G缩减为3G

查看之前拷贝的文件,正常读取,没有损坏。
[root@sctest ~]# cd /test1/
[root@sctest test1]# ls
grub.conf  issue  lost+found
[root@sctest test1]# cat issue 
Red Hat Enterprise Linux Server release 6.9 (Santiago)
Kernel \r on an \m

[root@sctest test1]# cat grub.conf 
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux 6 (2.6.32-696.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-696.el6.x86_64 ro root=UUID=a52d371b-98b3-4760-9bae-ffa65741c29f rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=128M LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
    initrd /initramfs-2.6.32-696.el6.x86_64.img
[root@sctest test1]# 

。。。理论上逻辑卷分区的扩展是可以在线进行的,甚至不会影响业务。但是缩减操作,慎重进行。


http://www.ppmy.cn/news/246726.html

相关文章

二十一、C++11(中)

文章目录 一、左值&右值(一)基本概念1.左值是什么2.右值是什么 (二)左值引用和右值引用1.左值引用2.右值引用 二、右值引用使用场景和意义(一)引入(二)左值引用的使用场景&#…

Activiti6.0(四)流程变量的使用

目录 一、前言 二、流程变量介绍 1、设置流程变量 2、在流程线上使用流程变量 3、流程变量存储 4、经验总结 一、前言 流程变量也是流程使用中一个很重要的东西,主要承担传递业务参数的作用,其作用范围仅在当前流程实例中有效,因此也常…

Kubeadm部署高可用K8S集群

目录: 1. 设备清单2. 初始环境准备2.1 主机名解析2.2 关闭防火墙及SElinux2.3 关闭NetworkManager2.4 进行时间同步2.5 升级系统(可选,我没做)命令如下:2.6 升级内核2.7 设置安装源2.7.1 设置k8s源2.7.2 设置docker源 …

020 ceph作openstack的后端存储

一、使用ceph做glance后端 1.1 创建用于存储镜像的池 [rootserverc ~]# ceph osd pool create images 128 128 pool images created [rootserverc ~]# ceph osd pool application enable images rbd enabled application rbd on pool images 1.2 创建client.glance账号并授权 …

java crontab_CrontabGenerate 本项目主要是为了生成 表达式。 Java Develop 272万源代码下载- www.pudn.com...

文件名称: CrontabGenerate下载 收藏√ [ 5 4 3 2 1 ] 开发工具: Java 文件大小: 957 KB 上传时间: 2017-03-11 下载次数: 0 详细说明:本项目主要是为了生成crontab表达式。-for crontab el generate 文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):…

Redis 集群架构的搭建基于5.03

哨兵架构存在的一些缺陷: 1. 瞬断问题,哨兵架构中,当主节点挂断后需要选举,然后切换,中间有几秒到几十秒的服务暂停时间 2. 高并发受限问题,哨兵对外只有一个节点提供写服务,一台就几w的QPS。…

getticket时errcode 40097 errmsg invalid args hint

{"errcode":40097,"errmsg":"invalid args hint: [*****************]"} 结尾需加上&offset_type1 https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_tokenACCESS_TOKEN&typejsapi&offset_type1 其他见文档&#xff…

第三方登录(QQ登录)

public void login() { // 在腾讯开放平台获取的APPIDmTencent Tencent.createInstance("1106541335", this.getApplicationContext());if (!mTencent.isSessionValid()) {mTencent.login(this, Scope, listener);}}Overrideprot…