暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Linux下硬盘格式化的相关命令Partprobe

原创 eygle 2010-07-02
422
这几天格式化硬盘,记录一下用到的命令:
[root@db ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 253981.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 2089.0 GB, 2089072092672 bytes
255 heads, 63 sectors/track, 253981 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      124495  1000006056   83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (124496-253981, default 124496):
Using default value 124496
Last cylinder or +size or +sizeM or +sizeK (124496-253981, default 253981):
Using default value 253981


Command (m for help): p

Disk /dev/sdb: 2089.0 GB, 2089072092672 bytes
255 heads, 63 sectors/track, 253981 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      124495  1000006056   83  Linux
/dev/sdb2          124496      253981  1040096295   83  Linux


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.

Syncing disks.

此时,分区里看不到新建的磁盘分区,提示通过重启才可以重用分区表,此时可以通过partprobe探测硬盘:
[root@db ~]# ls -al /dev/sdb*
brw-rw----  1 root disk 8, 16 Jun 25 04:40 /dev/sdb
brw-rw----  1 root disk 8, 17 Jun 29 22:07 /dev/sdb1
[root@db ~]# partprobe
[root@db ~]# ls -al /dev/sdb*
brw-rw----  1 root disk 8, 16 Jun 25 04:40 /dev/sdb
brw-rw----  1 root disk 8, 17 Jun 29 22:07 /dev/sdb1
brw-rw----  1 root disk 8, 18 Jul  2 22:37 /dev/sdb2
分区容量:
[root@db ~]# mkfs /dev/sdb2
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
130023424 inodes, 260024073 blocks
13001203 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7936 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, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848

Writing inode tables: 4076/7936
.done                           
Writing superblocks and filesystem accounting information:
.done

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

此时可以正常使用该磁盘分区了。
[root@db ~]# sfdisk -l /dev/sdb

Disk /dev/sdb: 253981 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdb1          0+ 124494  124495- 1000006056   83  Linux
/dev/sdb2     124495  253980  129486  1040096295   83  Linux
/dev/sdb3          0       -       0          0    0  Empty
/dev/sdb4          0       -       0          0    0  Empty




「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论