VMware Linux 创建/增加/减小 文件系统

来源:互联网 发布:上手机淘宝怎么买东西 编辑:程序博客网 时间:2024/06/06 02:15
Vmware create new file system:

1: Get approval for the extra disk resource from the virtual team.

2: Once aprove, grow the size of the existing disk in Vmware:
  Edit Settings
  selkect hard Disk
  Increase "Provision Size"
  Click "OK"
 
3: Run the following command to tell the kernel to re-scan the block devices and look for changes:
  PV=sdb
  echo 1 > /sys/block/${PV}/device/rescan
 
4: Now tell LVM to check the physical volumes and re-size them if neccesary:
  pvresize /dev/$PV
 
5: Now create new logical volume:
  lvcreate -n lv_data -l 100%FREE datavg
 
6: create a filesystem in it:
  mkfs.ext4 /dev/datavg/lv_data
 
7: add the file system in /etc/fstab:
  echo "echo/dev/datavg/lv_data  /data  ext4  defaults,nodev,nosuid  1 2" >> /etc/fstab
 
8: Mount it:
  umask 022
  mkdir /data
  mount /data
 
--------------------------

Grow File system:

1: Find the name of the physical volume, in in this case its "dev/sdb"
  vgdisplay -v appvg | grep "PV Name"
  The result of : PV Name  /dev/sdb
 
  Notice: if you see /dev/sdb1, or /dev/sdb2, them this process will not work and you will need to re-partition the disk
  and reboot the server.
 
2: In the VirtualCenter, increase the size of the disk that corresponds to /dev/sdb
  Edit Setting
  Select Harddisk
  Increase "Provisioned Size"
  Click OK
 
3: run command to rescan:
  PV=sdb
  echo 1 > /sys/block/${PV}/device/rescan
 
  the result is the Operating system sees the new size
 
4:Now tell LVM to check the physical volumes and re-size them if necessary:
  pvresize /dev/$PV
 
5: Now LVM can see the new size of the physical volume
  Notice: If the disk has partitions, then you need to repartition the disk as well so the "slice" has the extra disk allocated before the
  pvresize will work.
 
  Now you need see free space in the physical volune and its volume group.
  pvs
  vgs appvg
 

6: Grow the file system:
  lvextend -L +10G /dev/appvg/lv_apps
 
7: then use "resize2fs" to increase filesystem:
  resize2fs  <logical volume name>
 
---------------

Shrink File system:

1: Vmware:
  This action can only be done OFFLINE
 
  Unmount the file system:
  df <filesystem mount point>
  umount <filesystem mount point>
 
2: Check filesystem:
  fsck -n <logical volume name>
 
3: Use the resize2fs and lvreduce commands to decrease the filesystem:
  resize2fs <logical volume name> 50G
  lvresuce -L 50G /dev/appvg/lv_apps
 
  Attecntion: 50G is the new total size
 
4: Remount file system:
  mount <filesystem mount point>
 

0 0
原创粉丝点击