技术分享 Technology to share

CentOS下磁盘挂载

提醒:挂载操作会清空数据,请确认挂载盘无数据或者未使用


第一步:查看所有分区表:命令 fdisk -l


[root@iZ8vb3dk693jocithqbofwZ ~]# 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: 0x0008d73a

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

Disk /dev/vdb: 493.9 GB, 493921239040 bytes, 964689920 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


这里可以看到 这个系统有两个磁盘 分别有 42g和493g 我们现在 vda是系统盘 我们现在来挂载 vdb

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Disk /dev/vdb: 493.9 GB, 493921239040 bytes, 964689920 sectors



第二步:格式化硬盘 命令:fdisk /dev/vdb1



第三步:创建分区 命令:mkfs.ext4 /dev/vdb1



[root@iZ8vb3dk693jocithqbofwZ ~]# mkfs.ext4 /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
30146560 inodes, 120585984 blocks
6029299 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2269118464
3680 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, 71663616, 78675968, 
    102400000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 



第四步:挂载分区 命令:

mount /dev/vdb1 /data0 # 将vdb这个硬盘挂载成为 /data0


[root@iZ8vb3dk693jocithqbofwZ ~]# mount /dev/vdb1 /data0

如果成功你可以在 /etc/fstab 文件里面看到

UUID=eb448abb-3012-4d8d-bcde-xxxxxxxxx /            ext4  defaults    1 1


或者使用lsblk -f 来查看挂载


[root@iz8vb3dk693jocithqbofwz local]# lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
vda                                                      
└─vda1 ext4         eb448abb-3012-4d8d-bcde-xxxx /
vdb    ext3         cb4e4e59-953d-4f87-93ef-xxxxx 
└─vdb1 ext4         52d8cfbe-44d0-4906-a67e-xxxx /data0


第五步:将信息写入fstab,让系统开启自动挂载。在fstab文件添加如下代码

/dev/vdb1  /data0 ext4    defaults    0  0


上一篇: 前端也要做android开发

下一篇: 相似图片搜索

分享到以下平台: