查看新硬盘
[root@localhost ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 78 522112+ 82 Linux swap / Solaris
/dev/sda3 79 1044 7759395 83 Linux
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
把第一块新硬盘 转化为pv
[root@localhost ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
查看PV
[root@localhost ~]# pvdisplay
/dev/hdc: open failed: No medium found
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 20.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID iC7CD3-J1qd-Lz2c-Cri6-t5Vo-uQZf-KfMhZF
创建一个名为NEWGV的GV
[root@localhost ~]# vgcreate newvg /dev/sdb
Volume group "newvg" successfully created
创建一个名字为home的逻辑卷
[root@localhost ~]# lvcreate -L 19g –n home newvg
Logical volume "home”ated
格式化home的逻辑卷
[root@localhost ~]# mkfs -t ext3 /dev/newvg/home
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2490368 inodes, 4980736 blocks
249036 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
152 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
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.
挂载home分区到/mnt下
[root@localhost ~]# mount /dev/newvg/home /mnt/
开机自动挂载并检查
[root@localhost ~]# vim /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/newvg/home /home ext3 defaults,usrquota,grpquota 0 1
~
~
~
:wq
保持权限复制/home 下的文件到 新的分区
[root@localhost ~]# cp -a /home/* /mnt/
删除/home 下所有文件
[root@localhost mnt]# rm -rf /home/*
重新挂载
[root@localhost home]# umount /mnt/
[root@localhost home]# mount /dev/newvg/home /home/
重新挂载开启磁盘配额
[root@localhost home]# mount -o uerquota,grpquota,remount /dev/newvg/home
mount: /home not mounted already, or bad option
开启磁盘配额
[root@localhost home]#mount –o usrquota,grpquota /dev/newvg/home
重新生成配额文件
[root@localhost home]# quotacheck -cuvg /home
quotacheck: Scanning /dev/mapper/newvg-home [/home] quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
done
quotacheck: Checked 4 directories and 6 files
quotacheck: Old file not found.
[root@localhost home]# ls -l
total 36
-rw------- 1 root root 7168 Feb 21 02:02 aquota.group
-rw------- 1 root root 7168 Feb 21 02:02 aquota.user
drwx------ 2 root root 16384 Feb 21 01:28 lost+found
drwx------ 2 redhat redhat 4096 Aug 17 2008 redhat
创建用户并设置密码
[root@localhost home]# useradd yueyang
[root@localhost home]# passwd yueyang
Changing password for user yueyang.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
设置对用户yueyang的配额
[root@localhost home]# edquota -u yueyang
Disk quotas for user yueyang (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/newvg-home 0 4000000 5000000 0 40000 50000
~
~
~
~
~:wq
将第二块磁盘转化为pv
[root@localhost home]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
将新硬盘添加到newvg这个vg里
[root@localhost home]# vgextend newvg /dev/sdc
Volume group "newvg" successfully extended
添加/home逻辑卷的大小
[root@localhost home]# lvextend -L +10g /dev/newvg/home
Extending logical volume home to 29.00 GB
Logical volume home successfully resized
在线更新逻辑卷大小
[root@localhost home]# resize2fs /dev/newvg/home
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/newvg/home is mounted /home; -line resizing required
Performing an -line resize of /dev/newvg/home to 7602176 (4k) blocks.
The filesystem /dev/newvg/home is now 7602176 blocks long.
查看
[root@localhost home]# df -h /home/
Filesystem Size Used Avail Use% Mounted
/dev/mapper/newvg-home
29G 173M 27G 1% /home
[root@localhost ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 78 522112+ 82 Linux swap / Solaris
/dev/sda3 79 1044 7759395 83 Linux
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
把第一块新硬盘 转化为pv
[root@localhost ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
查看PV
[root@localhost ~]# pvdisplay
/dev/hdc: open failed: No medium found
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 20.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID iC7CD3-J1qd-Lz2c-Cri6-t5Vo-uQZf-KfMhZF
创建一个名为NEWGV的GV
[root@localhost ~]# vgcreate newvg /dev/sdb
Volume group "newvg" successfully created
创建一个名字为home的逻辑卷
[root@localhost ~]# lvcreate -L 19g –n home newvg
Logical volume "home”ated
格式化home的逻辑卷
[root@localhost ~]# mkfs -t ext3 /dev/newvg/home
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2490368 inodes, 4980736 blocks
249036 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
152 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
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.
挂载home分区到/mnt下
[root@localhost ~]# mount /dev/newvg/home /mnt/
开机自动挂载并检查
[root@localhost ~]# vim /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/newvg/home /home ext3 defaults,usrquota,grpquota 0 1
~
~
~
:wq
保持权限复制/home 下的文件到 新的分区
[root@localhost ~]# cp -a /home/* /mnt/
删除/home 下所有文件
[root@localhost mnt]# rm -rf /home/*
重新挂载
[root@localhost home]# umount /mnt/
[root@localhost home]# mount /dev/newvg/home /home/
重新挂载开启磁盘配额
[root@localhost home]# mount -o uerquota,grpquota,remount /dev/newvg/home
mount: /home not mounted already, or bad option
开启磁盘配额
[root@localhost home]#mount –o usrquota,grpquota /dev/newvg/home
重新生成配额文件
[root@localhost home]# quotacheck -cuvg /home
quotacheck: Scanning /dev/mapper/newvg-home [/home] quotacheck: Cannot stat old group quota file: No such file or directory
quotacheck: Cannot stat old group quota file: No such file or directory
done
quotacheck: Checked 4 directories and 6 files
quotacheck: Old file not found.
[root@localhost home]# ls -l
total 36
-rw------- 1 root root 7168 Feb 21 02:02 aquota.group
-rw------- 1 root root 7168 Feb 21 02:02 aquota.user
drwx------ 2 root root 16384 Feb 21 01:28 lost+found
drwx------ 2 redhat redhat 4096 Aug 17 2008 redhat
创建用户并设置密码
[root@localhost home]# useradd yueyang
[root@localhost home]# passwd yueyang
Changing password for user yueyang.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
设置对用户yueyang的配额
[root@localhost home]# edquota -u yueyang
Disk quotas for user yueyang (uid 501):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/newvg-home 0 4000000 5000000 0 40000 50000
~
~
~
~
~:wq
将第二块磁盘转化为pv
[root@localhost home]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
将新硬盘添加到newvg这个vg里
[root@localhost home]# vgextend newvg /dev/sdc
Volume group "newvg" successfully extended
添加/home逻辑卷的大小
[root@localhost home]# lvextend -L +10g /dev/newvg/home
Extending logical volume home to 29.00 GB
Logical volume home successfully resized
在线更新逻辑卷大小
[root@localhost home]# resize2fs /dev/newvg/home
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/newvg/home is mounted /home; -line resizing required
Performing an -line resize of /dev/newvg/home to 7602176 (4k) blocks.
The filesystem /dev/newvg/home is now 7602176 blocks long.
查看
[root@localhost home]# df -h /home/
Filesystem Size Used Avail Use% Mounted
/dev/mapper/newvg-home
29G 173M 27G 1% /home