背景:
现有系统中有一块硬盘,已经建立好lvm分区和划分好pv和vg了,
有270G可用空间,现在要划分10G空间给一个分区被叫做dmadmin分区。
现有分区状态截图:
[liul@develop ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
59G 38G 18G 68% /
/dev/sda1 251M 48M 191M 20% /boot
tmpfs 7.8G 4.1G 3.8G 53% /dev/shm
/dev/mapper/develop_vol-oradat1d_lv
63G 34G 27G 57% /oradata1d
/dev/mapper/develop_vol-oradcs1d_lv
30G 26G 2.5G 92% /oradata1d/oradcs
/dev/mapper/dbdevvg-dbdevlv
12G 159M 12G 2% /dbdevaic
[root@develop ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
oradat1d_lv develop_vol -wi-ao 64.00G
oradcs1d_lv develop_vol -wi-ao 30.00G
oradat1p_lv product_vol -wi-a- 64.00G
etlstg1_lv stage_vol -wi-a- 64.00G
dbdevlv dbdevvg -wi-ao 12.00G
dmadmin dbdevvg -wi-ao 10.00G
rootvol rootvg -wi-ao 60.00G
swapvol rootvg -wi-ao 8.00G
[root@develop ~]#
[root@develop ~]# vgs
VG #PV #LV #SN Attr VSize VFree
develop_vol 2 2 0 wz--n- 127.99G 34.00G
product_vol 3 1 0 wz--n- 191.99G 127.99G
stage_vol 2 1 0 wz--n- 127.99G 63.99G
dbdevvg 1 2 0 wz--n- 272.25G 250.25G
rootvg 1 2 0 wz--n- 135.84G 67.84G
[root@develop ~]#
[root@develop ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
oradat1d_lv develop_vol -wi-ao 64.00G
oradcs1d_lv develop_vol -wi-ao 30.00G
oradat1p_lv product_vol -wi-a- 64.00G
etlstg1_lv stage_vol -wi-a- 64.00G
dbdevlv dbdevvg -wi-ao 12.00G
rootvol rootvg -wi-ao 60.00G
swapvol rootvg -wi-ao 8.00G
[root@develop ~]#
步骤:
1/新建用户和密码,作为分区的所属用户和组
[root@develop ~]# useradd dmadmin
[root@develop ~]# passwd dmadmin
2/ 增加分区:大小10G,名字为dmadmin,所属卷组为dbdevvg
[root@develop ~]# lvcreate -L 10g -n dmadmin dbdevvg
Logical volume "dmadmin" created
3/ 查看一下
[root@develop ~]# pvs
[root@develop ~]# lvs
[root@develop ~]# df -h
4/ 格式化分区
[root@develop ~]# mkfs.ext3 /dev/dbdevvg/dmadmin
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@develop ~]#
5/ 新建目录
[root@develop ~]# mkdir /dmadmin
6/ 给目录权限
[root@develop ~]# chown -R dmadmin.dba /dmadmin
7/ 查看目录权限
[root@develop ~]# ll -d /dmadmin
8/ 设置开机自动挂载
[root@develop ~]# vim /etc/fstab
插入以下行
/dev/dbdevvg/dmadmin /dmadmin ext3 defaults 0 0
9/ 挂载到当前系统:
[root@develop ~]# mount -a
10/ 查看一下:
[root@develop ~]# mount
[root@develop ~]# pvs
[root@develop ~]# lvs
[root@develop ~]# df -h
[root@develop ~]# cat /etc/fstab
11/ 增加lv的分区空间
11.1 增加分区空间
[root@develop ~]# lvextend -L +1G /dev/dbdevvg/dmadmin
Extending logical volume dmadmin to 11.00 GB
Logical volume dmadmin successfully resized
11.2 增加文件系统空间
[root@develop ~]# resize2fs /dev/dbdevvg/dmadmin
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/dbdevvg/dmadmin is mounted on /dmadmin; on-line resizing required
Performing an on-line resize of /dev/dbdevvg/dmadmin to 2883584 (4k) blocks.
The filesystem on /dev/dbdevvg/dmadmin is now 2883584 blocks long.
12/ 查看。 已经增加了1G空间。
[root@develop ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootvol
59G 38G 18G 68% /
/dev/sda1 251M 48M 191M 20% /boot
tmpfs 7.8G 4.1G 3.8G 53% /dev/shm
/dev/mapper/develop_vol-oradat1d_lv
63G 34G 27G 57% /oradata1d
/dev/mapper/develop_vol-oradcs1d_lv
30G 26G 2.5G 92% /oradata1d/oradcs
/dev/mapper/dbdevvg-dbdevlv
12G 159M 12G 2% /dbdevaic
/dev/mapper/dbdevvg-dmadmin
11G 154M 11G 2% /dmadmin
成功增加lv分区空间
13/ 减小磁盘空间:
13.1 卸载分区和目录的映射关系
[root@develop ~]# umount /dmadmin
13.2 强制检查lv分区:
[root@develop ~]# e2fsck -f /dev/dbdevvg/dmadmin
e2fsck 1.39 (29-May-2006)
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
/dev/dbdevvg/dmadmin: 11/1441792 files (9.1% non-contiguous), 84450/2883584 blocks
13.3 文件系统减小到10G大小:
[root@develop ~]# resize2fs /dev/dbdevvg/dmadmin 10G
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/dbdevvg/dmadmin to 2621440 (4k) blocks.
The filesystem on /dev/dbdevvg/dmadmin is now 2621440 blocks long.
13.4 分区减小到10G大小:
[root@develop ~]# lvresize -L 10G /dev/dbdevvg/dmadmin
WARNING: Reducing active logical volume to 10.00 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce dmadmin? [y/n]: y
Reducing logical volume dmadmin to 10.00 GB
Logical volume dmadmin successfully resized
13.5 重新挂载
[root@develop ~]# mount -a
14/ 查看一下:
[root@develop ~]# mount
[root@develop ~]# pvs
[root@develop ~]# lvs
[root@develop ~]# df -h
14. 重新分配目录权限
阅读(2691) | 评论(0) | 转发(0) |