LVM管理之減少LV的大小
LVM管理之減少LV的大小
規定動作
1.umount filesystem
2.e2fsck filesystem
3.resize2fs filesystem
4.lvredure
例項演示————減少/home目錄的大小,由40G調整到15G:
1.當前環境的VG,PV,LV的相關資訊:
[root@powerpd ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_powerpd 1 3 0 wz--n- 278.38g 123.35g
[root@powerpd ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_powerpd lvm2 a-- 278.38g 123.35g
[root@powerpd ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv_home vg_powerpd -wi-ao 40.00g
lv_root vg_powerpd -wi-ao 50.00g
lv_swap vg_powerpd -wi-ao 65.03g
[root@powerpd ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_powerpd-lv_root
50G 4.4G 43G 10% /
tmpfs 32G 260K 32G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/vg_powerpd-lv_home
40G 176M 38G 1% /home
2.umount filesystem
#umount /home
3.e2fsck filesystem
[root@powerpd ~]# e2fsck /dev/vg_powerpd/lv_home
e2fsck 1.41.12 (17-May-2010)
/dev/vg_powerpd/lv_home: clean, 11/2621440 files, 209554/10485760 blocks
4.resize2fs filesystem
[root@powerpd ~]# resize2fs -f /dev/vg_powerpd/lv_home 15g
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg_powerpd/lv_home to 3932160 (4k) blocks.
The filesystem on /dev/vg_powerpd/lv_home is now 3932160 blocks long.
5.lvreduce
[root@powerpd ~]# lvreduce -L15g /dev/vg_powerpd/lv_home
WARNING: Reducing active logical volume to 15.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Reducing logical volume lv_home to 15.00 GiB
Logical volume lv_home successfully resized
[root@powerpd ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv_home vg_powerpd -wi-a- 15.00g
lv_root vg_powerpd -wi-ao 50.00g
lv_swap vg_powerpd -wi-ao 65.03g
6.mount filesystem
[root@powerpd ~]# mount /dev/vg_powerpd/lv_home
[root@powerpd ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_powerpd-lv_root
50G 4.4G 43G 10% /
tmpfs 32G 260K 32G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/vg_powerpd-lv_home
15G 168M 14G 2% /home
經驗總結:
減少檔案的大小一定需要按照上面提高的4個規定動作順序來做,在縮減LV大小前,首先要縮減filesystem的大小,否則將導致檔案系統破壞等惡劣影響.
錯誤操作示例
將/home目錄修改為10G大小.
1.umount filesystem
[root@powerpd ~]# umount /home
2.修改lv的大小
[root@powerpd ~]# lvreduce -L10G /dev/vg_powerpd/lv_home
WARNING: Reducing active logical volume to 10.00 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
Reducing logical volume lv_home to 10.00 GiB
Logical volume lv_home successfully resized
[root@powerpd ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv_home vg_powerpd -wi-a- 10.00g
lv_root vg_powerpd -wi-ao 50.00g
lv_swap vg_powerpd -wi-ao 65.03g
[root@powerpd ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_powerpd 1 3 0 wz--n- 278.38g 153.35g
3.e2fsck filesystem時,會報很多錯誤
[root@powerpd ~]# e2fsck -f /dev/vg_powerpd/lv_home
e2fsck 1.41.12 (17-May-2010)
The filesystem size (according to the superblock) is 3932160 blocks
The physical size of the device is 2621440 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Error reading block 2621440 (Attempt to read block from filesystem resulted in short read) while reading inode and block bitmaps. Ignore error
e2fsck: Can't read an block bitmap while retrying to read bitmaps for /dev/vg_powerpd/lv_home
4.修改檔案系統大小
[root@powerpd ~]# resize2fs /dev/vg_powerpd/lv_home
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/vg_powerpd/lv_home' first.
[root@powerpd ~]# resize2fs -f /dev/vg_powerpd/lv_home
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg_powerpd/lv_home to 2621440 (4k) blocks.
resize2fs: Can't read an block bitmap while trying to resize /dev/vg_powerpd/lv_home
Please run 'e2fsck -fy /dev/vg_powerpd/lv_home' to fix the filesystem
after the aborted resize operation.
操作失敗,提示需要先fsck檔案系統.
到此檔案系統縮減大小失敗,補救的方法是將lv修改為改變前的大小.
[root@powerpd ~]# lvextend -L15G /dev/vg_powerpd/lv_home
Extending logical volume lv_home to 15.00 GiB
Logical volume lv_home successfully resized
[root@powerpd ~]# mount /home
[root@powerpd ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_powerpd-lv_root
50G 4.4G 43G 10% /
tmpfs 32G 260K 32G 1% /dev/shm
/dev/sda1 485M 37M 423M 8% /boot
/dev/mapper/vg_powerpd-lv_home
15G 168M 14G 2% /home
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/32980/viewspace-1123851/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- LVM管理LVM
- lvm extend vg_centos-lv_root 大小LVMCentOS
- LVM磁碟管理LVM
- LVM管理操作LVM
- aix lvm 管理AILVM
- lvm 線上擴充 / 目錄的大小LVM
- lvm管理之pv遷移與lv擴充套件LVM套件
- LVM : 縮減檔案系統的容量LVM
- linux 縮減LV大小Linux
- 減少apk包大小的一種思路APK
- linux之lvmLinuxLVM
- linux 之LVMLinuxLVM
- LVM 邏輯卷管理LVM
- AIX系統 LVM 管理AILVM
- HP-UX lvm管理UXLVM
- LVM 管理linux磁碟LVMLinux
- 邏輯卷管理-LVMLVM
- LVM管理全面總結LVM
- Linux_lvm管理LinuxLVM
- 減少Android APK的大小99.99%AndroidAPK
- LVM_邏輯卷管理LVM
- 【譯】如何使用webpack減少vuejs打包的大小WebVueJS
- MySQL 減少InnoDB系統表空間的大小MySql
- Linux LVM邏輯卷配置過程詳解(建立,增加,減少,刪除,解除安裝)LinuxLVM
- 使用LVM擴充Linux邏輯卷大小LVMLinux
- LVMLVM
- 如何在Mac上減少PDF檔案大小Mac
- linux之 LVM擴容LinuxLVM
- lvm的使用LVM
- 如何使用 LVM 管理滴滴雲 EBSLVM
- LVM邏輯卷管理器LVM
- 邏輯卷管理---LVM2LVM
- AIX System Administration之儲存管理、LVM、FS(一)AILVM
- Lvm邏輯卷管理、建立、使用、擴充套件、縮減、遷移、快照、恢復LVM套件
- 邏輯卷管理實驗---縮減/home目錄使用空間並建立新的LVMLVM
- [譯] 怎樣減少 Android 應用包 60% 的大小?Android
- Docker的`COPY --chmod`可將映象檔案大小減少35%Docker
- linux之LVM邏輯卷LinuxLVM