eygle.com   eygle.com
eygle.com eygle
eygle.com  
 

« ACOUG 第五次地面活动召集中 | Blog首页 | Oracle数据库恢复:解决ORA-600 2831错误 »

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

这几天格式化硬盘,记录一下用到的命令:
[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





历史上的今天...
    >> 2011-07-28文章:
    >> 2008-07-28文章:
    >> 2007-07-28文章:
           遭遇Magpie多年前的一个Bug
    >> 2006-07-28文章:
           Windows Xp重新安装备忘
    >> 2005-07-28文章:
           瑞典游记-预告篇

无觅

By eygle on 2010-07-28 10:30 | Comments (7) | System | 2570 |

7 Comments

盖老大,这个文章,的确是在给凑数,对吧?
呵呵。

partprobe就这个值得一提,但sfidsk -l 这个用到人很少,一般都是fdisk -l或者parted .. print(和fdisk分出来的分区不兼容显示)。

磁盘分区虽然很简单,但是有个disk align的问题还是要注意一下:在IO频繁的硬盘上,是否有disk align据测试能导致10%左右的IO性能差距。

To eygle

看Vmware的文档吧,有够详细了

http://www.vmware.com/pdf/esx3_partition_align.pdf

disk align 的确需要注意,一个关于磁盘优化的亮点, 学习了,感谢各位同仁。


下面这两个命令,可以进行查看已经格式化后的文件系统的相关情况

tune2fs -l /dev/sda1 | grep Block
dumpe2fs /dev/sda1


CopyRight © 2004~2020 云和恩墨,成就未来!, All rights reserved.
数据恢复·紧急救援·性能优化 云和恩墨 24x7 热线电话:400-600-8755 业务咨询:010-59007017-7040 or 7037 业务合作: marketing@enmotech.com