#!/bin/bash

#修改分区大小
path=/home
size=20G
size1=10G

df -h
sudo umount $path
sudo e2fsck -f /dev/mapper/VolGroup-lv_home
sudo resize2fs -p /dev/mapper/VolGroup-lv_home
mount $path
df -h
lvreduce -L $size /dev/mapper/VolGroup-lv_home
Vgdisplay
lvextend -L +$size1 /dev/mapper/VolGroup-lv_root
resize2fs -p /dev/mapper/VolGroup-lv_root
#####上面的谨慎使用,可能会导致数据丢失########


#对新加磁盘进行分区
fdisk -l
fdisk /dev/xvdb  //新磁盘

#划分为几个分区后,进行格式化
mkfs -t ext4 /dev/xvdb1   #更快的格式化方法mkfs.ext4 -T largefile /dev/xvdb1
mkfs -t ext4 /dev/xvdb2
mount /dev/xvdb1 /opt
mount /dev/xvdb2 /var
#写入/etc/fsatab
#blkid /dev/xvdb1
#blkid /dev/xvdb2
#UUID=7d1c5c94-2d2a-47ab-94a1-b1aef9a8ff57 /opt ext4 defaults 1 2
uuid=`blkid /dev/xvdc1 | awk '{print $2}' | sed 's/"//g'`
echo $uuid /opt ext4 defaults 1 2>> /etc/fstab

posted on 2017-04-10 19:35  流浪在伯纳乌  阅读(189)  评论(0编辑  收藏  举报