解決"/dev/sdX is apparently in use by the systemwill not make a filesystem here"

迷倪小魏發表於2017-11-03

Linux上配置multipath,在HP EVA儲存上劃分一個100G大小的LUN,然後把它對映給Linux主機,將該100G空間使用fdisk進行分割槽,分為3個區(關於Linux multipath多路徑配置與使用案例請參考作者的另一篇博文:http://blog.itpub.net/31015730/viewspace-2146732/

 

[root@seaing mapper]# cat /proc/partitions

major minor  #blocks  name

 

   8     0  488386584 sda

   8     1     104391 sda1

   8     2  488279610 sda2

   8    16  104857600 sdb

   8    17   48837568 sdb1

   8    18   29302560 sdb2

   8    19   19543072 sdb3

   8    32  209715200 sdc

   8    48  104857600 sdd

   8    49   48837568 sdd1

   8    50   29302560 sdd2

   8    51   19543072 sdd3

   8    64  209715200 sde

   8    80  104857600 sdf

   8    81   48837568 sdf1

   8    82   29302560 sdf2

   8    83   19543072 sdf3

   8    96  209715200 sdg

   8   112  104857600 sdh

   8   113   48837568 sdh1

   8   114   29302560 sdh2

   8   115   19543072 sdh3

   8   128  209715200 sdi

 253     0  469794816 dm-0

 253     1   18481152 dm-1

 253     2  104857600 dm-2

 253     3  209715200 dm-3

 

但是在格式化檔案系統的時候,出現了報錯

[root@seaing mapper]# mkfs.ext3 /dev/sdb1

mke2fs 1.39 (29-May-2006)

/dev/sdb1 is apparently in use by the system; will not make a filesystem here!

 

 

提示/dev/sdb1 正在被使用。 /dev/sdb1 正在被DM管理,所以我們建立檔案系統時提示報錯,我們手工的移除,就可以正常的建立檔案系統,具體操作如下:

 

[root@seaing mapper]# dmsetup status

mpath2: 0 419430400 multipath 2 0 0 0 2 1 A 0 2 0 8:64 A 0 8:128 A 0 E 0 2 0 8:32 A 0 8:96 A 0

mpath1: 0 209715200 multipath 2 0 0 0 2 1 A 0 2 0 8:16 A 0 8:80 A 0 E 0 2 0 8:48 A 0 8:112 A 0

VolGroup00-LogVol01: 0 36962304 linear

VolGroup00-LogVol00: 0 939589632 linear

 

[root@seaing mapper]# mkdir /dev/mapper/mpath1 /comsys/

mkdir: cannot create directory `/dev/mapper/mpath1': File exists

mkdir: cannot create directory `/comsys/': File exists

[root@seaing mapper]#

[root@seaing mapper]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                      434G  4.9G  407G   2% /

/dev/sda1              99M   18M   77M  19% /boot

tmpfs                 7.9G     0  7.9G   0% /dev/shm

[root@seaing mapper]#

[root@seaing mapper]#

[root@seaing mapper]# mount /dev/mapper/mpath1 /comsys/

mount: you must specify the filesystem type

 

[root@seaing mapper]# mount /dev/sdb1 /comsys/

mount: /dev/sdb1 already mounted or /comsys/ busy

 

 

刪除對映關係,取消對映

[root@seaing mapper]# dmsetup remove_all(或dmsetup remove mpath1

[root@seaing mapper]#

[root@seaing mapper]# dmsetup status

VolGroup00-LogVol01: 0 36962304 linear

VolGroup00-LogVol00: 0 939589632 linear

[root@seaing mapper]#

[root@seaing mapper]# ll /dev/mapper

total 0

crw------- 1 root root  10, 63 Oct 24 18:02 control

brw-rw---- 1 root disk 253,  0 Oct 24 18:02 VolGroup00-LogVol00

brw-rw---- 1 root disk 253,  1 Oct 24 18:02 VolGroup00-LogVol01

 

 

再次建立檔案系統,建立成功

[root@seaing mapper]# mkfs.ext3 /dev/sdb1

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

6111232 inodes, 12209392 blocks

610469 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

373 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424

 

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 33 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

 

掛載成功

[root@seaing mapper]# mount /dev/sdb1 /comsys/

[root@seaing mapper]#

[root@seaing mapper]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                      434G  4.9G  407G   2% /

/dev/sda1              99M   18M   77M  19% /boot

tmpfs                 7.9G     0  7.9G   0% /dev/shm

/dev/sdb1              46G  181M   44G   1% /comsys

 

 

設定為開機掛載

[root@seaing mapper]# vi /etc/fstab

/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0

/dev/sdb1             /comsys                  ext3  defaults        0 0

 

 

重新啟動作業系統,檢視自動掛載是否成功

[root@seaing /]# reboot

 

Broadcast message from root (pts/1) (Wed Oct 25 10:16:35 2017):

 

The system is going down for reboot NOW!

Last login: Wed Oct 25 08:54:28 2017 from 10.1.1.44

 

[root@seaing ~]# cd /dev/mapper/

[root@seaing mapper]#

[root@seaing mapper]# ll

total 0

crw------- 1 root root  10, 63 Oct 25 10:19 control

brw-rw---- 1 root disk 253,  2 Oct 25 10:19 mpath1

brw-rw---- 1 root disk 253,  4 Oct 25 10:19 mpath1p1

brw-rw---- 1 root disk 253,  5 Oct 25 10:19 mpath1p2

brw-rw---- 1 root disk 253,  6 Oct 25 10:19 mpath1p3

brw-rw---- 1 root disk 253,  3 Oct 25 10:19 mpath2

brw-rw---- 1 root disk 253,  0 Oct 25 10:19 VolGroup00-LogVol00

brw-rw---- 1 root disk 253,  1 Oct 25 10:19 VolGroup00-LogVol01

[root@seaing mapper]#

[root@seaing mapper]# ll /dev/mpath/

total 0

lrwxrwxrwx 1 root root 7 Oct 25 10:19 mpath1 -> ../dm-2

lrwxrwxrwx 1 root root 7 Oct 25 10:19 mpath1p1 -> ../dm-4

lrwxrwxrwx 1 root root 7 Oct 25 10:19 mpath1p2 -> ../dm-5

lrwxrwxrwx 1 root root 7 Oct 25 10:19 mpath1p3 -> ../dm-6

lrwxrwxrwx 1 root root 7 Oct 25 10:19 mpath2 -> ../dm-3

 

 

重啟後測試,該檔案不能正常掛載,手工掛載也會失敗。

[root@seaing mapper]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                      434G  4.9G  407G   2% /

/dev/sda1              99M   18M   77M  19% /boot

tmpfs                 7.9G     0  7.9G   0% /dev/shm

 

 

手動掛載也不能成功

[root@seaing mapper]# mount -a

mount: /dev/sdb1 already mounted or /comsys busy

 

 

所以說這種方法只能暫時性掛載,個人覺得不太不可取!!!想要永久的進行掛載,還是按照作者的另一篇博文(http://blog.itpub.net/31015730/viewspace-2146732/)的方法進行比較穩妥一點。


作者:SEian.G(苦練七十二變,笑對八十一難)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31015730/viewspace-2146812/,如需轉載,請註明出處,否則將追究法律責任。

相關文章