linux中挂载硬盘报错(you must specify the filesystem type)

转载:

https://www.cnblogs.com/fjping0606/p/4699649.html


公司有台服务器做了raid1,由于容量小,需扩容,原先打算再添加两块硬盘进去做多一组raid1,组成两组raid1混合使用,但是公司抠门,买到服务器只能安装3块硬盘,无奈之下只能放多一块进去单独挂载分区使用。

开始的时候把新加的硬盘接入raid卡,服务器开机无法识别,解决方法是把新加的硬盘接入主板的SATA接口,服务器开机登录后顺利识别到。

先说说开始时候的操作方法:

首先用fdisk进行分区

# fdisk /dev/sdb

整块硬盘全部空间只建立一个分区,分完区后查看

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x0005f698

Device Boot  Start  End    Blocks    Id  System
/dev/sdb1      1    121601   976760001   83     Linux

可以看到建立了一个新分区/dev/sdb1

然后进行格式化并挂载分区

mkfs -t ext4 -c /dev/sdb1   (快速格式化:mkfs.ext4 /dev/sdb1)
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
61054976 inodes, 244190000 blocks
12209500 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7453 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, 214990848

Checking for bad blocks (read-only test): done 
Writing inode tables: done 
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

mount /dev/sdb1  /data

df -h

可以看到已经成功挂载了

修改/etc/fstab,添加下面这行,使之开机自动挂载

/dev/sdb1               /data                   ext4    defaults        0 0

保存后重启服务器init 6

执行df -h发现竟然没有挂载成功

执行fdisk -l还能看到/dev/sdb1分区

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x0005f698

Device Boot  Start  End    Blocks    Id  System
/dev/sdb1      1    121601   976760001   83     Linux

 

但是没有存在/dev/sdb1

ll /dev/sdb1

ls: cannot access /dev/sdb1: No such file or directory

重新执行挂载

# mount /dev/sdb1 /data/

mount: you must specify the filesystem type

加上分区类型重新挂载,提示不存在分区

mount -t ext4 /dev/sdb1 /data/
mount: special device /dev/sdb1 does not exist

 

按照网上大神的方法,成功解决:

mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
61054976 inodes, 244190646 blocks
12209532 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7453 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, 214990848

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

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

格式化整块硬盘

格式化完毕后fdisk -l查看

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x00000000

没有了/dev/sdb1分区

重新挂载

mount /dev/sdb /data/

df -h

成功挂载,修改/etc/fstab使之开机自动挂载,添加以下内容

/dev/sdb                /data                   ext4    defaults        0 0

 

init 6重启后发现能正常自动挂载,到此已成功解决问题

用lsblk命令查看已识别的硬盘和挂载的分区

lsblk

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值