linux中掛載硬盤報錯(you must specify the filesystem type)


公司有台服務器做了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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM