一、创建分区 >**** 目的:**** 将独立磁盘 /dev/vdb 挂载到 /data 目录,并实现开机自动挂载 1. 查询分区 ``` [root@iZ2zeibok6t3svl00dy8jyZ ~]# df -h Filesystem Size Used Avail Use% Mounted on /de ..

Linux 创建分区并自动挂载

本贴最后更新于 344 天前,其中的信息可能已经物是人非

一、创建分区

>**** 目的:**** 将独立磁盘 /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>




































  • Linux

    Linux 是一套免费使用和自由传播的类 Unix 操作系统,是一个基于 POSIX 和 Unix 的多用户、多任务、支持多线程和多 CPU 的操作系统。它能运行主要的 Unix 工具软件、应用程序和网络协议,并支持 32 位和 64 位硬件。Linux 继承了 Unix 以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统。

    605 引用 • 778 回帖 • 735 关注
  • 自动挂载
    1 引用
回帖   
请输入回帖内容...