1.查看要挂载的空间
1 [root@iZuf6610s5jsqm9fr53nslZ ~]# fdisk -l 2 3 Disk /dev/vda: 42.9 GB, 42949672960 bytes 4 255 heads, 63 sectors/track, 5221 cylinders 5 Units = cylinders of 16065 * 512 = 8225280 bytes 6 Sector size (logical/physical): 512 bytes / 512 bytes 7 I/O size (minimum/optimal): 512 bytes / 512 bytes 8 Disk identifier: 0x00053156 9 10 Device Boot Start End Blocks Id System11 /dev/vda1 * 1 5222 41942016 83 Linux12 13 Disk /dev/vdb: 107.4 GB, 107374182400 bytes14 16 heads, 63 sectors/track, 208050 cylinders15 Units = cylinders of 1008 * 512 = 516096 bytes16 Sector size (logical/physical): 512 bytes / 512 bytes17 I/O size (minimum/optimal): 512 bytes / 512 bytes18 Disk identifier: 0x00000000
2.添加分区
1 [root@iZuf6610s5jsqm9fr53nslZ ~]# fdisk /dev/vdb 2 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel 3 Building a new DOS disklabel with disk identifier 0x65cce73f. 4 Changes will remain in memory only, until you decide to write them. 5 After that, of course, the previous content won't be recoverable. 6 7 Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) 8 9 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to10 switch off the mode (command 'c') and change display units to11 sectors (command 'u').12 13 Command (m for help): n14 Command action15 e extended16 p primary partition (1-4)17 118 Invalid partition number for type `1'19 Command action20 e extended21 p primary partition (1-4)22 p23 Partition number (1-4): 124 First cylinder (1-208050, default 1): 25 Using default value 126 Last cylinder, +cylinders or +size{K,M,G} (1-208050, default 208050): 27 Using default value 20805028 29 Command (m for help): wq30 The partition table has been altered!31 32 Calling ioctl() to re-read partition table.33 Syncing disks.
fdisk 对应分区 相继输入 n, p, 1, wq
3.查看当前分区情况
1 [root@iZuf6610s5jsqm9fr53nslZ ~]# fdisk -l 2 3 Disk /dev/vda: 42.9 GB, 42949672960 bytes 4 255 heads, 63 sectors/track, 5221 cylinders 5 Units = cylinders of 16065 * 512 = 8225280 bytes 6 Sector size (logical/physical): 512 bytes / 512 bytes 7 I/O size (minimum/optimal): 512 bytes / 512 bytes 8 Disk identifier: 0x00053156 9 10 Device Boot Start End Blocks Id System11 /dev/vda1 * 1 5222 41942016 83 Linux12 13 Disk /dev/vdb: 107.4 GB, 107374182400 bytes14 16 heads, 63 sectors/track, 208050 cylinders15 Units = cylinders of 1008 * 512 = 516096 bytes16 Sector size (logical/physical): 512 bytes / 512 bytes17 I/O size (minimum/optimal): 512 bytes / 512 bytes18 Disk identifier: 0x65cce73f19 20 Device Boot Start End Blocks Id System21 /dev/vdb1 1 208050 104857168+ 83 Linux
4.格式化分区
1 [root@iZuf6610s5jsqm9fr53nslZ ~]# mkfs.ext3 /dev/vdb1 2 mke2fs 1.41.12 (17-May-2010) 3 Filesystem label= 4 OS type: Linux 5 Block size=4096 (log=2) 6 Fragment size=4096 (log=2) 7 Stride=0 blocks, Stripe width=0 blocks 8 6553600 inodes, 26214292 blocks 9 1310714 blocks (5.00%) reserved for the super user10 First data block=011 Maximum filesystem blocks=429496729612 800 block groups13 32768 blocks per group, 32768 fragments per group14 8192 inodes per group15 Superblock backups stored on blocks: 16 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 17 4096000, 7962624, 11239424, 20480000, 2388787218 19 Writing inode tables: done 20 Creating journal (32768 blocks): done21 Writing superblocks and filesystem accounting information: done22 23 This filesystem will be automatically checked every 31 mounts or24 180 days, whichever comes first. Use tune2fs -c or -i to override.
5.挂载硬盘
1 #创建要挂载的目录 2 mkdir /data 3 4 #挂载分区 5 mount /dev/vdb1 /data/ 6 7 #写入分区信息 8 echo "/dev/vdb1 /data ext3 defaults 0 0" >> /etc/fstab 9 10 #查看分许信息11 cat /etc/fstab