自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何在Linux中減少/縮小LVM大小(邏輯卷調(diào)整)

系統(tǒng) Linux
當(dāng)你在 LVM 中的磁盤空間耗盡時(shí),你可以通過縮小現(xiàn)有的沒有使用全部空間的 LVM,而不是增加一個(gè)新的物理磁盤,在卷組上騰出一些空閑空間。

[[347857]]

減少/縮小邏輯卷是數(shù)據(jù)損壞的最高風(fēng)險(xiǎn)。

所以,如果可能的話,盡量避免這種情況,但如果沒有其他選擇的話,那就繼續(xù)。

縮減 LVM 之前,建議先做一個(gè)備份。

當(dāng)你在 LVM 中的磁盤空間耗盡時(shí),你可以通過縮小現(xiàn)有的沒有使用全部空間的 LVM,而不是增加一個(gè)新的物理磁盤,在卷組上騰出一些空閑空間。

需要注意的是: 在 GFS2 或者 XFS 文件系統(tǒng)上不支持縮小。

如果你是邏輯卷管理 (LVM) 的新手,我建議你從我們之前的文章開始學(xué)習(xí)。

 

減少邏輯卷涉及以下步驟:

  • 卸載文件系統(tǒng)
  • 檢查文件系統(tǒng)是否有任何錯(cuò)誤
  • 縮小文件系統(tǒng)的大小
  • 縮小邏輯卷的大小
  • 重新檢查文件系統(tǒng)是否存在錯(cuò)誤(可選)
  • 掛載文件系統(tǒng)
  • 檢查減少后的文件系統(tǒng)大小

比如: 你有一個(gè) 100GB 的沒有使用全部空間的 LVM,你想把它減少到 80GB,這樣 20GB 可以用于其他用途。

  1. # df -h /testlvm1
  2.  
  3. Filesystem Size Used Avail Use% Mounted on
  4. /dev/mapper/vg01-lv002 100G 15G 85G 12% /testlvm1

卸載文件系統(tǒng)

使用 umount 命令卸載文件系統(tǒng):

  1. # umount /testlvm1

檢查文件系統(tǒng)是否有任何錯(cuò)誤

使用 e2fsck 命令檢查文件系統(tǒng)是否有錯(cuò)誤:

  1. # e2fsck -f /dev/mapper/vg01-lv002
  2.  
  3. e2fsck 1.42.9 (28-Dec-2013)
  4. Pass 1: Checking inodes, blocks, and sizes
  5. Pass 2: Checking directory structure
  6. Pass 3: Checking directory connectivity
  7. Pass 4: Checking reference counts
  8. Pass 5: Checking group summary information
  9. /dev/mapper/vg01-lv002: 13/6553600 files (0.0% non-contiguous), 12231854/26212352 blocks

縮小文件系統(tǒng)

下面的命令將把 testlvm1 文件系統(tǒng)從 100GB 縮小到 80GB。

文件系統(tǒng)大小調(diào)整的常用語法(resize2fs

  1. resize2fs [現(xiàn)有邏輯卷名] [新的文件系統(tǒng)大小]

實(shí)際命令如下:

  1. # resize2fs /dev/mapper/vg01-lv002 80G
  2.  
  3. resize2fs 1.42.9 (28-Dec-2013)
  4. Resizing the filesystem on /dev/mapper/vg01-lv002 to 28321400 (4k) blocks.
  5. The filesystem on /dev/mapper/vg01-lv002 is now 28321400 blocks long.

減少邏輯卷 (LVM) 容量

現(xiàn)在使用 lvreduce 命令縮小邏輯卷(LVM) 的大小。通過下面的命令, /dev/mapper/vg01-lv002 將把邏輯卷 (LVM) 從 100GB 縮小到 80GB。

LVM 縮減 (lvreduce) 的常用語法

  1. lvreduce [新的 LVM 大小] [現(xiàn)有邏輯卷名稱]

實(shí)際命令如下:

  1. # lvreduce -L 80G /dev/mapper/vg01-lv002
  2.  
  3. WARNING: Reducing active logical volume to 80.00 GiB
  4. THIS MAY DESTROY YOUR DATA (filesystem etc.)
  5. Do you really want to reduce lv002? [y/n]: y
  6. Reducing logical volume lv002 to 80.00 GiB
  7. Logical volume lv002 successfully resized

可選:檢查文件系統(tǒng)是否有錯(cuò)誤

縮減 LVM 后再次檢查文件系統(tǒng)是否有錯(cuò)誤:

  1. # e2fsck -f /dev/mapper/vg01-lv002
  2.  
  3. e2fsck 1.42.9 (28-Dec-2013)
  4. Pass 1: Checking inodes, blocks, and sizes
  5. Pass 2: Checking directory structure
  6. Pass 3: Checking directory connectivity
  7. Pass 4: Checking reference counts
  8. Pass 5: Checking group summary information
  9. /dev/mapper/vg01-lv002: 13/4853600 files (0.0% non-contiguous), 1023185/2021235 blocks

掛載文件系統(tǒng)并檢查縮小后的大小

最后掛載文件系統(tǒng),并檢查縮小后的文件系統(tǒng)大小。

使用 mount 命令掛載邏輯卷

  1. # mount /testlvm1

使用 df 命令檢查掛載的卷。

 

  1. # df -h /testlvm1
  2.  
  3. Filesystem Size Used Avail Use% Mounted on
  4. /dev/mapper/vg01-lv002 80G 15G 65G 18% /testlvm1

 

責(zé)任編輯:龐桂玉 來源: Linux中國(guó)
相關(guān)推薦

2020-10-09 11:15:14

LinuxLVM邏輯卷管理

2015-08-05 15:10:24

UbuntuLVM

2013-10-22 16:03:00

LVM

2017-12-25 09:50:46

Linux邏輯卷管理文件系統(tǒng)

2009-09-07 09:36:34

2021-04-27 08:00:00

存儲(chǔ)分區(qū)磁盤

2019-04-10 10:15:52

Linux邏輯卷文件系統(tǒng)

2021-06-04 09:23:44

LVM邏輯卷物理卷

2020-10-25 17:48:54

LVM系統(tǒng)運(yùn)維

2014-06-20 10:51:35

Linux LVM邏輯卷

2016-05-18 14:20:12

LinuxgThumb圖片

2016-08-31 14:16:55

LinuxLVM卷轉(zhuǎn)移

2023-07-26 07:11:50

LVM底層抽象

2015-08-05 15:02:15

UbuntuLVM

2020-11-27 20:02:17

LVM邏輯卷管理器

2023-09-05 15:17:48

LinuxLUN磁盤

2020-07-20 07:00:00

KubernetesHostPath

2012-09-20 10:49:49

IBMdw

2019-07-19 14:06:48

APP代碼打包

2019-10-30 13:52:49

Windows 10電源模式Windows
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)