为什么Linux下fdisk删除分区后,再新建分区可以不用格式化直接挂载?
PHPz
PHPz 2017-04-17 16:03:51
0
4
566

我新建了分区/dev/sdb3,并且格式化为ext4

Device     Boot   Start     End Sectors Size Id Type
/dev/sdb1          2048 2099199 2097152   1G 83 Linux
/dev/sdb2       2099200 6293503 4194304   2G 83 Linux
/dev/sdb3       6293504 6313983   20480  10M 83 Linux

/dev/sdb3: UUID="6b300a6f-0579-458a-8000-ed24629f3da0" TYPE="ext4" PARTUUID="81a3aca2-03"

然后我把/dev/sdb3分区删掉,重新新建/dev/sdb3分区,结果不用mke2fs格式化,就能直接挂载该分区,而且还是ext4文件系统,难道删除分区重建不需要重新格式化么?求指导


2016-10-31 18:27:23

还是有点疑惑
例如/dev/sdb3分区
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
/dev/sdb2 2099200 6293503 4194304 2G 83 Linux
/dev/sdb3 6293504 6313983 20480 10M 83 Linux

我删除/dev/sdb3分区后,重建,size是5M,reboot
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
/dev/sdb2 2099200 6293503 4194304 2G 83 Linux
/dev/sdb3 6293504 6303743 10240 5M 83 Linux

/dev/sdb3: UUID="6b300a6f-0579-458a-8000-ed24629f3da0" TYPE="ext4" PARTUUID="81a3aca2-03"

我再删除/dev/sdb3分区后,再重建,size是15M,reboot
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
/dev/sdb2 2099200 6293503 4194304 2G 83 Linux
/dev/sdb3 6293504 6324223 30720 15M 83 Linux

/dev/sdb3: UUID="6b300a6f-0579-458a-8000-ed24629f3da0" TYPE="ext4" PARTUUID="81a3aca2-03"

依然是已分区状态,已经把分区范围变化了,为何还是没变化呢?


2016-10-31 18:34:27
我再再删除/dev/sdb3分区后,再重建,size是15M,reboot
把First sector赋值为6293505,不使用默认值6293504

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
/dev/sdb2 2099200 6293503 4194304 2G 83 Linux
/dev/sdb3 6293505 6334463 40959 20M 83 Linux

/dev/sdb3: PARTUUID="81a3aca2-03"

这下就对了
结论:重建分区,如果改变了First sector的序号,就需要格式化;仅仅改变size,则会继续使用原文件系统格式。
PS:感谢各位答主!

PHPz
PHPz

学习是最好的投资!

reply all(4)
Ty80

Enclose an open space with a fence, draw two large grids, (partition, format)
Remove the fence (delete partition). But the grid you drew is there.
Enclose fences (and partitions) outside the two drawn grids, so you don’t have to draw grids (use the original file system). Of course, you can also erase the original drawing and draw 3 small grids (format to other file systems)

Ty80

My understanding is: deleting and creating partitions with fdisk will change the description data in the partition table (you can view the first sector data of /dev/sdb)
Because the previous partitions have not changed, the third partition is described in the partition table The starting address has not changed. If only the size is changed, the partition header data will still be the most recently formatted data, and ext4 will still be recognized.

阿神

fdisk only modifies the records of the partition table. If your partition parameters are exactly the same as before, you can of course continue to use them. This is also the principle of retrieving partitions after the partition table is destroyed. Search the file system header and rebuild the partition table. But this is limited to the case where the starting sector and the total number of sectors of your partition remain unchanged. If it changes, for example, becomes smaller, then the file system data is incorrect. At this time, you need to reformat and create a new file system structure

迷茫

Deleting a partition only means that the block where MBRGPT中的记录清除,而ext系的文件系统具体信息是由SuperBlock提供的。SuperBlock通常与Boot sector在同一个Block(2k或4k的Block)中,所以如果你填充了对应的分区的前2k字节,就会发现文件系统被损坏。
因此如果Boot sectorSuperBlock is located has not been filled with content. When the block is still used as the first block next time, the file system information will be restored.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!