Centos 7.0挂载硬盘

Centos 7.0挂载硬盘

1.输入fdisk -l命令看当前磁盘信息
fdisk -l

查看硬盘信息

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000d2717

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux

Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

2.进入需要挂载的分区
fdisk /dev/vdb1

Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x4873179f.
Command (m for help): n

3.按n进行分区

Partition type:
p primary (0 primary, 0 extended, 4 free) //主分区
e extended //扩展分区

4.选择默认的主分区
Select (default p): p

5.选择安装到第几个主分区,这里我选择第一个分区
Partition number (1-4, default 1): 1

6.选择该分区的起始磁盘数(默认),选择默认值就好
First sector (2048-419430399, default 2048):

7.定义该分区的大小,如果按默认(按回车)即是使用全部可用存储额
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):
Using default value 419430399

8.输入w 写入分区,成功后会出现如下提示
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

9.格式化分区

mkfs -t ext3 -c /dev/vdb1

[root@izbp10ndtnrkwpf2c01z5cz ~]# mkfs -t ext3 -c /dev/vdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428544 blocks
2621427 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 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, 20480000, 23887872

Checking for bad blocks (read-only test): done
Allocating group tables: done
Writing inode tables: ^[[C^[[Cdone
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

10 .如果想每次系统重启都能自动挂载该分区可修改/etc/fstab文件

echo “/dev/vdb1 /home ext3 defaults 1 2” >> /etc/fstab

11. 挂载分区到home目录

mount /dev/vdb1 /home

12. 查看是否挂载成功

这里显示已经挂载了一个187G的硬盘

df -lh

Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.6G 36G 5% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 292K 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 783M 0 783M 0% /run/user/0
/dev/vdb1 197G 60M 187G 1% /home

你可能感兴趣的:(linux)