技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機(jī)純凈版,64位旗艦版,綠色軟件,免費(fèi)軟件下載基地!

當(dāng)前位置:主頁(yè) > 教程 > 服務(wù)器類 >

Linux中的LVM之增加容量與刪除卷的方法詳解

來源:技術(shù)員聯(lián)盟┆發(fā)布時(shí)間:2018-02-06 00:15┆點(diǎn)擊:

  放大LV容量涉及到LVM管理中的命令lvresize,我們先創(chuàng)建一個(gè)卷組VG VolGroup02,它建立在磁盤/dev/sdc (大小為8G)上。創(chuàng)建邏輯卷LV時(shí),我們故意只使用了一小部分。具體情況如下所示

  復(fù)制代碼

  代碼如下:

  [root@localhost ~]# vgdisplay

  --- Volume group ---

  VG Name VolGroup02

  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 7.97 GiB

  PE Size 32.00 MiB

  Total PE 255

  Alloc PE / Size 0 / 0

  Free PE / Size 255 / 7.97 GiB

  VG UUID SETgjx-dobd-Uayt-AWgN-HKID-hsYe-tEotIS

  [root@localhost ~]# lvcreate -L7.97 -n LogVol00 VolGroup02

  Rounding up size to full physical extent 32.00 MiB

  Logical volume "LogVol00" created

  [root@localhost ~]# mkfs -t ext4 /dev/VolGroup02/LogVol00

  mke2fs 1.41.12 (17-May-2010)

  Filesystem label=

  OS type: Linux

  Block size=1024 (log=0)

  Fragment size=1024 (log=0)

  Stride=0 blocks, Stripe width=0 blocks

  8192 inodes, 32768 blocks

  1638 blocks (5.00%) reserved for the super user

  First data block=1

  Maximum filesystem blocks=33554432

  4 block groups

  8192 blocks per group, 8192 fragments per group

  2048 inodes per group

  Superblock backups stored on blocks:

  8193, 24577

  Writing inode tables: done

  Creating journal (4096 blocks): done

  Writing superblocks and filesystem accounting information: done

  This filesystem will be automatically checked every 23 mounts or

  180 days, whichever comes first. Use tune2fs -c or -i to override.

  [root@localhost ~]# cd /

  [root@localhost /]# mkdir /u01

  [root@localhost /]# mount /dev/VolGroup02/LogVol00 /u01

  [root@localhost /]# vi /etc/fstab

  #

  # /etc/fstab

  # Created by anaconda on Mon Aug 17 15:08:21 2015

  #

  # 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

  #

  UUID=3440ad55-6486-45ed-876f-e942b08013bf / ext4 defaults 1 1

  UUID=d3abb655-db70-4c42-967d-57c421abfda0 /boot ext4 defaults 1 2

  UUID=660624ff-335d-42ca-b779-f130a80d9da8 /home ext4 defaults 1 2

  UUID=6f534bf0-e486-4937-84ae-ed1221cf34f1 swap swap defaults 0 0

  /dev/VolGroup02/LogVol00 /u01 ext4 defaults 1 1

  tmpfs /dev/shm tmpfs defaults 0 0

  devpts /dev/pts devpts gid=5,mode=620 0 0

  sysfs /sys sysfs defaults 0 0

  proc /proc proc defaults 0 0

Linux中的LVM之增加容量與刪除卷的方法詳解

  此時(shí),我們要放大文件系統(tǒng)/u01的大小,那么就需要使用到lvresize 放大LV容量

  復(fù)制代碼

  代碼如下:

  [root@localhost ~]# lvscan

  ACTIVE '/dev/VolGroup02/LogVol00' [32.00 MiB] inherit

  [root@localhost ~]# lvdisplay /dev/VolGroup02/LogVol00

  --- Logical volume ---

  LV Path /dev/VolGroup02/LogVol00

  LV Name LogVol00

  VG Name VolGroup02

  LV UUID OCHwx1-EL9P-6C5J-RNuz-2Xu5-4215-H3xt5s

  LV Write Access read/write

  LV Creation host, time localhost.localdomain, 2015-09-01 10:50:10 +0800

  LV Status available

  # open 1

  LV Size 32.00 MiB

  Current LE 1

  Segments 1

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:0

  [root@localhost ~]# lvresize -L +7.89G /dev/VolGroup02/LogVol00

  Rounding size to boundary between physical extents: 7.91 GiB

  Size of logical volume VolGroup02/LogVol00 changed from 32.00 MiB (1 extents) to 7.94 GiB (254 extents).

  Logical volume LogVol00 successfully resized

Linux中的LVM之增加容量與刪除卷的方法詳解

  復(fù)制代碼

  代碼如下:

  [root@localhost ~]# resize2fs -p /dev/VolGroup02/LogVol00

  resize2fs 1.41.12 (17-May-2010)

  Filesystem at /dev/VolGroup02/LogVol00 is mounted on /u01; on-line resizing required

  old desc_blocks = 1, new_desc_blocks = 32

  Performing an on-line resize of /dev/VolGroup02/LogVol00 to 8323072 (1k) blocks.

  The filesystem on /dev/VolGroup02/LogVol00 is now 8323072 blocks long.

  [root@localhost ~]# df -h

  Filesystem Size Used Avail Use% Mounted on

  /dev/sda2 27G 6.0G 20G 24% /

  tmpfs 5.9G 0 5.9G 0% /dev/shm

  /dev/sda1 477M 32M 420M 8% /boot

  /dev/sdb1 99G 60M 94G 1% /home

  /dev/mapper/VolGroup02-LogVol00

  7.7G 2.7M 7.3G 1% /u01

Linux中的LVM之增加容量與刪除卷的方法詳解