一、创建分区
>****目的:**** 将独立磁盘/dev/vdb挂载到/data目录,并实现开机自动挂载1.查询分区
``` [root@iZ2zeibok6t3svl00dy8jyZ ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/vda1 40G 1004M 37G 3% / tmpfs 1.9G 0 1.9G 0% /dev/shm /dev/vdb1 59G 52M 56G 1% /data</font>
### 2.查询磁盘
<font size=4>
[root@iZ2zeibok6t3svl00dy8jyZ ~]# fdisk -l
Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003a7b4
Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41940992 83 Linux
Disk /dev/vdb: 64.4 GB, 64424509440 bytes
16 heads, 63 sectors/track, 124830 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: 0x00000000
</font>
### 3.创建分区
<font size=4>
[root@iZ2zeibok6t3svl00dy8jyZ ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa503aec3.
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)
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): p
Disk /dev/vdb: 64.4 GB, 64424509440 bytes
16 heads, 63 sectors/track, 124830 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: 0xa503aec3
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-124830, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-124830, default 124830):
Using default value 124830
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
</font>
### 4.分区格式化
<font size=4>
root@iZ2zeibok6t3svl00dy8jyZ ~]# mkfs.ext4 /dev/vdb1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3932160 inodes, 15728572 blocks
786428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
480 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
</font>
## 二、自动挂载
### 1.挂载分区
<font size=4>
[root@iZ2zeibok6t3svl00dy8jyZ ~]# mkdir /data/
[root@iZ2zeibok6t3svl00dy8jyZ ~]# mount /dev/vdb1 /data
</font>
### 2.查询分区
<font size=4>
[root@iZ2zeibok6t3svl00dy8jyZ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1004M 37G 3% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/vdb1 59G 52M 56G 1% /data
</font>
### 3.开机挂载
<font size=4>
[root@iZ2zeibok6t3svl00dy8jyZ ~]# vim /etc/fstab
添加:
/dev/vdb1 /data ext4 defaults 1 1
</font>
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于