1.使用fdisk成功创建主分区/dev/sdb1,查看/proc/partitions中的分区信息
[root@localhost ~]# cat /proc/partitionsmajor minor #blocks name 8 0 20971520 sda 8 1 512000 sda1 8 2 20458496 sda2 8 16 10485760 sdb 8 17 522081 sdb1 8 32 10485760 sdc 8 33 1060258 sdc1 8 34 1060290 sdc2 8 35 1060290 sdc3 8 36 1 sdc4 8 37 1060258 sdc5 253 0 18849792 dm-0 253 1 1605632 dm-1 253 2 1060258 dm-2 253 3 1060290 dm-3 253 4 1060290 dm-4 253 5 1 dm-5 253 6 1060258 dm-6 253 7 112423 dm-7 253 8 1 dm-8 253 9 522081 dm-9
2.使用mke2fs创建文件系统提示/dev/sdb1正在被系统使用
[root@localhost ~]# mke2fs -t ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010)/dev/sdb1 is apparently in use by the system; will not make a filesystem here!
3.使用mount查看/dev/sdb1是否被挂载,发现/dev/sdb1并没有被挂载
[root@localhost ~]# mount/dev/mapper/VolGroup-lv_root on / type ext4 (rw)proc on /proc type proc (rw)sysfs on /sys type sysfs (rw)devpts on /dev/pts type devpts (rw,gid=5,mode=620)tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")/dev/sda1 on /boot type ext4 (rw)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
4.使用dd命令发现磁盘读写正常
[root@localhost ~]# fdisk -l /dev/sdbDisk /dev/sdb: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x1c69f2ed Device Boot Start End Blocks Id System/dev/sdb1 1 65 522081 83 Linux[root@localhost ~]# dd if=/dev/zero of=/dev/sdb bs=512 count=11+0 records in1+0 records out512 bytes (512 B) copied, 0.000116963 s, 4.4 MB/s[root@localhost ~]# fdisk -l /dev/sdbDisk /dev/sdb: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000
5.使用fuser查看/dev/sdb1磁盘被系统中那个进程使用,发现并没用进程使用该磁盘
[root@localhost ~]# fuser /dev/sdb1[root@localhost ~]#
6.使用dmsetup status命令发现 /dev/sd1 正在被dm服务占用,所以我们创建文件系统时提示报错。我们手工的移除,就可以正常的创建文件系统
[root@localhost ~]# dmsetup statusVolGroup-lv_swap: 0 3211264 linearVolGroup-lv_root: 0 37699584 linearsdb2: 0 2 linearsdb1: 0 224847 linearsdc5: 0 2120517 linearsdc4: 0 2 linearsdc3: 0 2120580 linearsdc2: 0 2120580 linearsdc1: 0 2120517 linearsdb5: 0 1044162 linear
7.手工的移除/dev/sdb的映射关系(取消占用),就可以正常的创建文件系统
[root@localhost ~]# dmsetup remove sdb1[root@localhost ~]# dmsetup remove sdb2[root@localhost ~]# dmsetup remove sdb5[root@localhost ~]# dmsetup statusVolGroup-lv_swap: 0 3211264 linearVolGroup-lv_root: 0 37699584 linearsdc5: 0 2120517 linearsdc4: 0 2 linearsdc3: 0 2120580 linearsdc2: 0 2120580 linearsdc1: 0 2120517 linear
8.成功创建文件系统且类型为ext4
[root@localhost ~]# mke2fs -t ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)Stride=0 blocks, Stripe width=0 blocks130560 inodes, 522080 blocks26104 blocks (5.00%) reserved for the super userFirst data block=1Maximum filesystem blocks=6763315264 block groups8192 blocks per group, 8192 fragments per group2040 inodes per groupSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409Writing inode tables: done Creating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 24 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.[root@localhost ~]#
[root@localhost ~]# blkid /dev/sdb1/dev/sdb1: UUID="7fe362b4-389b-40f8-91ed-07572abc350a" TYPE="ext4"