######################1、查看未挂载的硬盘(名称为/dev/xvdb)
[root@iZ23zw1ss97Z ~]# fdisk -l
Disk /dev/xvda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x0009e68a
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 41943039 20970496 83 Linux
Disk /dev/xvdb: 107.4 GB, 107374182400 bytes, 209715200 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、创建分区(我这里就创建了一个分区,便于后续扩展)
[root@iZ23zw1ss97Z ~]# fdisk /dev/xvdb
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 0x629aca47.
Command (m for help): n #####这里输入n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p #####这里输入p
Partition number (1-4, default 1): 1 #####这里输入1
First sector (2048-209715199, default 2048): #####这里我默认从2048开始
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): #####这里我默认到209715199结束,也就是整个数据盘的大小
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): w #####输入w,分区
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@iZ23zw1ss97Z ~]#
######################3、格式化分区任#######
# 下面有三种文件格式,我选择的是mkfs.ext4
# mkfs.ext3 /dev/xvdb
# mkfs.ext4 /dev/xvdb
# mkfs.xfs -f /dev/xvdb
##########################################
[root@iZ23zw1ss97Z ~]# mkfs.ext4 /dev/xvdb
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
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@iZ23zw1ss97Z ~]#
###################### 查看当前磁盘目录情况
[root@iZ23zw1ss97Z ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 1.6G 18G 9% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs 3.7G 8.3M 3.7G 1% /run
tmpfs 3.7G 0 3.7G 0% /sys/fs/cgroup
###################### 查看未挂载的硬盘情况
[root@iZ23zw1ss97Z ~]# fdisk -l
Disk /dev/xvda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x0009e68a
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 41943039 20970496 83 Linux
Disk /dev/xvdb: 107.4 GB, 107374182400 bytes, 209715200 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
######################4、创建挂载目录
[root@iZ23zw1ss97Z ~]# mkdir /zjw
######################5、挂载分区,挂载/dev/xvdb到目录/zjw
[root@iZ23zw1ss97Z ~]# mount /dev/xvdb /zjw
######################6、设置开机自动挂载
[root@iZ23zw1ss97Z ~]# vi /etc/fstab
[root@iZ23zw1ss97Z ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Nov 21 18:16:53 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=6634633e-001d-43ba-8fab-202f1df93339 / ext4 defaults,barrier=0 1 1
/dev/xvdb /zjw ext4 defaults 0 0
[root@iZ23zw1ss97Z ~]#
######################7、确认是否挂载成功
[root@iZ23zw1ss97Z ~]# reboot ####重启服务器
######################重新连接ssh后,查看是否挂载成功
# /dev/xvdb 99G 60M 94G 1% /zjw
# 这里可以看到以及挂载成功
##################################################
[root@iZ23zw1ss97Z ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 1.6G 18G 9% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs 3.7G 8.3M 3.7G 1% /run
tmpfs 3.7G 0 3.7G 0% /sys/fs/cgroup
/dev/xvdb 99G 60M 94G 1% /zjw
阿里云ECS,数据盘挂载
猜你喜欢
转载自my.oschina.net/90888/blog/1790506
今日推荐
周排行