1 增加一块2G的硬盘
打开VMware点击VM---settings—add—Hard Disk—---Create a new virtual disk—SCSI—disk size(GB)2.0----重启虚拟机系统
2 验证硬盘:
[root@viong ~]# fdisk -l
1234 #已增加了2G的/dev/sdb
Disk /dev/sdb: 2147 MB, 2147483648 bytes -----------à说明已经生效了
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
3 先把/dev/sdb划分为一个扩展分区,再新建一个逻辑分区,格式化为ext3分区,然后设置为重启自动加载。
[root@viong ~]# fdisk /dev/sdb
#对/dev/sdb进行分区
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)
Command (m for help): n #增加一个分区
Command action
e extended
p primary partition (1-4)
#e增加扩展分区
Partition number (1-4): 1
First cylinder (1-261, default 1): 回车
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 回车
Using default value 261
Command (m for help): w #保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@viong ~]# fdisk /dev/sdb
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
#l增加逻辑分区
First cylinder (1-261, default 1): 回车
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): 回车
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
4 验证/dev/sdb的分区情况
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 5 Extended
/dev/sdb5 1 261 2096419+ 83 Linux
5 格式化 /dev/sdb5
[root@viong ~]# mkfs.ext3 /dev/sdb5 格式化sdb5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524104 blocks
26205 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
6 创建一个目录来挂载sdb5
[root@viong ~]# mkdir /mnt/ftp
[root@viong ~]# mount /dev/sdb5 /mnt/ftp/
挂载sdb5到/mnt/ftp/
[root@viong ~]# vi /etc/fstab
添加最后一条信息,来达到重启自动挂载上去
/dev/sdb5 /mnt/ftp ext3 defaults 0 0
7 #mount -a 最后重启系统看有没有被自动挂载上
8 创建一个ftp用户做测试
[root@red-hat-5 ~]# useradd -d /mnt/ftp/hom -s /sbin/nologin hom
[root@red-hat-5 ~]# passwd hom
Changing password for user hom.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@red-hat-5 ~]# ll /mnt/ftp/
总计 20
drwx------ 2 hom hom 4096 01-10 17:15 hom
drwx------ 2 root root 16384 01-10 16:53 lost+found
[root@red-hat-5 ~]# service vsftpd start
为 vsftpd 启动 vsftpd:[确定]
9 为ftp用户做磁盘配额
刚才创建的hom用户是在/dev/sdb5分区中,那么如果我们要对hom用户进行磁盘限额,那我们需要修改/etc/fstab中根分区的记录,将/dev/sdb5分区的第4个字段改成defaults,usrquota,如下:
/dev/sdb5 /mnt/ftp ext3 defaults,usrquota 0 0
为了不然系统重启才生效,利用一下命令直接生效
# mount -o remount /dev/sdb5