Linux格式化扩展分区时会报错,因为Linux扩展分区格式化无意义,它是为logicalpartition服务的,它们大小一
样。在一块硬盘里你最多只能创造fourpartiton,包括主分区与expand分区,而一个expand分区可以创造去多个
logicalpartition,是在logicalpartition使用space的。此时,为了解决问题,可以在扩展分区上创建主分区(p)
或逻辑分区(l)
以下演示出错解决过程:
1、创建扩展分区
[root@localhosttmp]# fdisk /dev/sda
WARNING:DOS-compatible mode is deprecated. It's strongly recommended to
switchoff the mode (command 'c') and change display units to
sectors(command 'u').
Command(m for help): n
Firstcylinder (4106-4178, default 4106):
Usingdefault value 4106
Lastcylinder, +cylinders or +size{K,M,G} (4106-4178, default 4178): +100M
Command(m for help): W
Thepartition table has been altered!
Callingioctl() to re-read partition table.
WARNING:Re-reading the partition table failed with error 16: 设备或资源忙.
Thekernel still uses the old table. The new table will be used at
thenext reboot or after you run partprobe(8) or kpartx(8)
Syncingdisks.
[root@localhosttmp]# fdisk -l
Disk/dev/sda: 34.4 GB, 34359738368 bytes
255heads, 63 sectors/track, 4177 cylinders
Units= cylinders of 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical): 512 bytes / 512 bytes
I/Osize (minimum/optimal): 512 bytes / 512 bytes
Diskidentifier: 0x0003d455
DeviceBoot Start End Blocks Id System
/dev/sda1 * 1 128 1024000 83 Linux
Partition1 does not end on cylinder boundary.
/dev/sda2 128 2040 15360000 83 Linux
/dev/sda3 2040 3825 14336000 83 Linux
/dev/sda4 3825 4178 2833408 5 Extended
/dev/sda5 3825 4106 2252800 82 Linux swap / Solaris
/dev/sda6 4106 4119 109964 83 Linux
2、格式化磁盘分区
[root@localhost~]# mount /dev/sda6 /data
mount:you must specify the filesystem type
显示分区未格式化
[root@localhost~]# mkfs -t ext3 -c /dev/sda6
mke2fs1.41.12 (17-May-2010)
mkfs.ext3:inode_size (128) * inodes_count (0) too big for a
filesystemwith 0 blocks, specify higher inode_ratio (-i)
orlower inode count (-N).
3、格式化扩展分区报错解决
格式磁盘时发现如下错误,原因是扩展分区无法格式化,
解决方法是在扩展分区上创建主分区(p)或逻辑分区(l)
[root@localhost~]# fdisk /dev/sda6
Devicecontains neither a valid DOS partition table, nor Sun, SGI or OSFdisklabel
Buildinga new DOS disklabel with disk identifier 0xcbd45cde.
Changeswill remain in memory only, until you decide to write them.
Afterthat, of course, the previous content won't be recoverable.
Warning:invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING:DOS-compatible mode is deprecated. It's strongly recommended to
switchoff the mode (command 'c') and change display units to
sectors(command 'u').
Command(m for help): p
Disk/dev/sda6: 112 MB, 112603136 bytes
255heads, 63 sectors/track, 13 cylinders
Units= cylinders of 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical): 512 bytes / 512 bytes
I/Osize (minimum/optimal): 512 bytes / 512 bytes
Diskidentifier: 0xcbd45cde
DeviceBoot Start End Blocks Id System
Command(m for help): n
Commandaction
e extended
p primary partition (1-4)
p
Partitionnumber (1-4): 1
Firstcylinder (1-13, default 1):
Usingdefault value 1
Lastcylinder, +cylinders or +size{K,M,G} (1-13, default 13): 13M
Command(m for help): P
Disk/dev/sda6: 112 MB, 112603136 bytes
255heads, 63 sectors/track, 13 cylinders
Units= cylinders of 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical): 512 bytes / 512 bytes
I/Osize (minimum/optimal): 512 bytes / 512 bytes
Diskidentifier: 0xcbd45cde
DeviceBoot Start End Blocks Id System
/dev/sda6p1 1 13 104391 83 Linux
Command(m for help): W
Thepartition table has been altered!
Callingioctl() to re-read partition table.
WARNING:Re-reading the partition table failed with error 22: 无效的参数.
Thekernel still uses the old table. The new table will be used at
thenext reboot or after you run partprobe(8) or kpartx(8)
Syncingdisks.
此处要重启使生效,也可以使用partprobe命令
[root@localhost~]# partprobe
Warning:WARNING: the kernel failed to re-read the partition table on /dev/sda(设备或资源忙). As a
result, it may not reflect all of your changes until afterreboot.
Warning:无法以读写方式打开/dev/sr0(只读文件系统)。/dev/sr0已按照只读方式打开。
Warning:无法以读写方式打开/dev/sr0(只读文件系统)。/dev/sr0已按照只读方式打开。
Error:无效的分区表 -/dev/sr0 出现递归分区。
[root@localhost~]# fdisk -l
Disk/dev/sda: 34.4 GB, 34359738368 bytes
255heads, 63 sectors/track, 4177 cylinders
Units= cylinders of 16065 * 512 = 8225280 bytes
Sectorsize (logical/physical): 512 bytes / 512 bytes
I/Osize (minimum/optimal): 512 bytes / 512 bytes
Diskidentifier: 0x0003d455
DeviceBoot Start End Blocks Id System
/dev/sda1 * 1 128 1024000 83 Linux
Partition1 does not end on cylinder boundary.
/dev/sda2 128 2040 15360000 83 Linux
/dev/sda3 2040 3825 14336000 83 Linux
/dev/sda4 3825 4178 2833408 5 Extended
/dev/sda5 3825 4106 2252800 82 Linux swap / Solaris
/dev/sda6 4106 4119 109964 83 Linux
[root@localhost~]# mkdir /data
再次格式化,显示格式化成功。
[root@localhost~]# mkfs.ext3 /dev/sda6
mke2fs1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=1024(log=0)
分块大小=1024(log=0)
Stride=0blocks, Stripe width=0 blocks
27552inodes, 109964 blocks
5498blocks (5.00%) reserved for the super user
第一个数据块=1
Maximumfilesystem blocks=67371008
14block groups
8192blocks per group, 8192 fragments per group
1968inodes per group
Superblockbackups stored on blocks:
8193,24577, 40961, 57345, 73729
正在写入inode表:完成
Creatingjournal (4096 blocks): 完成
Writingsuperblocks and filesystem accounting information: 完成
Thisfilesystem will be automatically checked every 24 mounts or
180days, whichever comes first. Use tune2fs -c or -i to override.
4、再次挂载磁盘分区,挂载成功
[root@localhost~]# mount /dev/sda6 /data
[root@localhost~]# df -hT
[root@localhost/]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 15G 8.4G 5.9G 59% /
/dev/sda1 ext4 969M 54M 865M 6% /boot
/dev/sda3 ext4 14G 525M 13G 5% /home
/dev/sr0 iso9660 1.8G 1.8G 0 100% /mnt/iso
share vboxsf 222G 93G 129G 42% /mnt/share
/dev/sda6 ext3 104M 5.7M 93M 6% /data