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


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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31015730/viewspace-2146812/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值