LVM扩展根目录

[root@MSLINUX ~]# df

将sdb划9G给根目录使用:


文件系统                 1K-块      已用      可用 已用% 挂载点
/dev/mapper/vg_mslinux-lv_root  16134560   6843500   8471452  45%  /
tmpfs                  1955576        72   1955504   1% /dev/shm
/dev/sda1               495844     37797    432447   9% /boot
//193.168.120.3/e$    51207152  18612592  32594560  37% /shared

[root@MSLINUX ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d8e9e

   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        2611    20458496   8e  Linux LVM

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_mslinux-lv_root: 16.8 GB, 16785604608 bytes
255 heads, 63 sectors/track, 2040 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vg_mslinux-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@MSLINUX ~]# fdisk  /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xdc6052f1.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10G

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@MSLINUX ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_mslinux/lv_root
  LV Name                lv_root
  VG Name                vg_mslinux
  LV UUID                rmUL10-kznP-SNeL-WtlO-sefO-pl26-YtGhGX
  LV Write Access        read/write
  LV Creation host, time MSLINUX, 2016-12-13 19:17:00 +0800
  LV Status              available
  # open                 1
  LV Size                15.63 GiB
  Current LE             4002
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/vg_mslinux/lv_swap
  LV Name                lv_swap
  VG Name                vg_mslinux
  LV UUID                gocgis-2vvH-0gOF-qmLC-dlYW-A3x3-HOFg4b
  LV Write Access        read/write
  LV Creation host, time MSLINUX, 2016-12-13 19:17:09 +0800
  LV Status              available
  # open                 1
  LV Size                3.88 GiB
  Current LE             992
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

[root@MSLINUX ~]# vgextend vg_mslinux /dev/sdb1 
  No physical volume label read from /dev/sdb1
  Physical volume "/dev/sdb1" successfully created
  Volume group "vg_mslinux" successfully extended
You have new mail in /var/spool/mail/root


[root@MSLINUX ~]# lvextend -L +9000M /dev/vg_mslinux/lv_root
  Extending logical volume lv_root to 24.42 GiB
  Logical volume lv_root successfully resized

[root@MSLINUX ~]# resize2fs -p /dev/vg_mslinux/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_mslinux/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_mslinux/lv_root to 6402048 (4k) blocks.
The filesystem on /dev/vg_mslinux/lv_root is now 6402048 blocks long.

[root@MSLINUX ~]# df
文件系统                 1K-块      已用      可用 已用% 挂载点
/dev/mapper/vg_mslinux-lv_root
                      25207436   6846512  17086772  29% /
tmpfs                  1955576        72   1955504   1% /dev/shm
/dev/sda1               495844     37797    432447   9% /boot
//193.168.120.3/e$    51207152  18612592  32594560  37% /shared

猜你喜欢

转载自blog.csdn.net/lsysafe/article/details/81224277