云硬盘挂载(linux系统)

///第一步查看挂载信息///

[root@VM_0_16_centos etc]# fdisk -l  //查看已挂载磁盘状态
*Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009ac89
   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   104857566    52427759+  83  Linux
Disk /dev/vdb: 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*

操作解释:Disk /dev/vda显示已经挂载(为系统盘)
Disk /dev/vdb显示未挂载(新购硬盘)

[root@VM_0_16_centos etc]# df -h //查看挂载磁盘信息
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G   40K  3.9G   1% /dev/shm
tmpfs           3.9G  596K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vda1        50G  7.2G   40G  16% /
tmpfs           783M     0  783M   0% /run/user/0

///第二步磁盘分区处理即挂载vdb///

[root@VM_0_16_centos etc]# fdisk /dev/vdb
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 0xbda237a9.

Command (m for help): n 
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{
    
    K,M,G} (2048-209715199, default 209715199): 
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

操作解释:输入"fdisk /dev/vdb",我们需要根据界面的提示,依次输入"n"(新建分区)、“p”(新建主分区)、“1”(使用第1个主分区),两次回车(使用默认配置),输入"wq"(保存分区表),回车开始分区。

[root@VM_0_16_centos etc]# fdisk -l //再次查看挂载磁盘信息

Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009ac89

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   104857566    52427759+  83  Linux

Disk /dev/vdb: 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
Disk label type: dos
Disk identifier: 0xbda237a9

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   209715199   104856576   83  Linux

解释:显示已经挂载成功!!!
第三步进行磁盘格式化操作//

[root@VM_0_16_centos etc]# mkfs.ext3 /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
6553600 inodes, 26214144 blocks
1310707 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@VM_0_16_centos etc]# mkdir -p /home //创建挂载目录点
[root@VM_0_16_centos etc]# mount /dev/vdb1 /home //挂载目录
[root@VM_0_16_centos etc]# mount -a
[root@VM_0_16_centos etc]# echo '/dev/vdb1 /home ext3 defaults 1 2' >> /etc/fstab //设置开机启动
[root@VM_0_16_centos etc]# df -h  //检查挂载后信息显示
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G   40K  3.9G   1% /dev/shm
tmpfs           3.9G  600K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/vda1        50G  7.2G   40G  16% /
tmpfs           783M     0  783M   0% /run/user/0
/dev/vdb1        99G   60M   94G   1% /home
[root@VM_0_16_centos etc]# 

到此就完成了。

另附更改磁盘的挂载目录:
  比如想把已经挂载在home目录上的硬盘挂载到data目录上, 如下操作
  #df -h(查看分区情况及数据盘名称)
  # mkdir /data(如果没有data目录就创建,否则此步跳过)
  # umount /home(卸载硬盘已挂载的home目录)
  # mount /dev/sdb3 /data (挂载到data目录)
  # vi /etc/fstab (编辑fstab文件修改或添加,使重启后可以自动挂载)
  /dev/sdb3 /data ext3 auto 0 0

数据盘 新挂载目录

编辑/etc/fstab里面的/home为/data, 或创建让系统启动的时候自动挂载到/data

vim /etc/rc.local

猜你喜欢

转载自blog.csdn.net/OuNuo5280/article/details/104037782
今日推荐