linux 磁盘分区

【知识点】

linux命令: df   fdisk mount/unmount

【步骤】

1. 查看磁盘信息  fdisk -l

[root@host-10-14-40-177 dev]# fdisk -l
Disk /dev/vda: 4294 MB, 4294967296 bytes
43 heads, 32 sectors/track, 6096 cylinders
Units = cylinders of 1376 * 512 = 704512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dcf96
Device Boot Start End Blocks Id System
/dev/vda1 * 2 6097 4193280 83 Linux
Disk /dev/vdb: 2147.5 GB, 2147483648000 bytes
16 heads, 63 sectors/track, 4161015 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb29abbe6
Device Boot Start End Blocks Id System
/dev/vdb1 1 208052 104858176+ 83 Linux
/dev/vdb2 208053 2288561 1048576536 83 Linux

2. 添加分区 fdisk 磁盘

    fdisk /dev/vdb   #在磁盘/dev/vdb划分磁盘

[root@host-10-14-40-177 dev]# fdisk /dev/vdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n         
#添加分区
Command action
e extended
p primary partition (1-4)
p                                             #添加主分区
Partition number (1-4): 3          
First cylinder (2288562-4161015, default 2288562):
Using default value 2288562
Last cylinder, +cylinders or +size{K,M,G} (2288562-4161015, default 4161015): +50G
Command (m for help): w                  
#写入分区
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

3. 格式化磁盘

  mkfs.exts4 /dev/vdb3

备注:格式分区方法

mkfs - 支持ext2、ext3(日志)、vfat、msdos、jfs、reiserfs等

用法1:mkfs -t <fstype> <partition>

例:#mkfs -t ext3 /dev/hda1

用法2:mkfs.<fstype> <partition>

例:#mkfs.vfat /dev/hda2

4. 挂载分区

  mount /dev/vdb3 /home

5. 写入/etc/fstab文件

  以上操作,在系统重启后,swap文件的大小又会变回原大小,我们可以在/etc/fstab里增加下面的配置,使其重启后,我们刚刚的配置仍然有效。添加如下:

/dev/vdb1 /u01 ext4 defaults 0 0

/dev/vdb2 /data ext4 defaults 0 0

/dev/vdb3 /home ext4 defaults 0 0

/dev/vdb4 swap swap defaults 0 0

posted @ 2015-07-06 17:07  lottu  阅读(363)  评论(0编辑  收藏  举报