我创建了一个名为test的大约3个gig文件,并将其分区 fdisk
。然后我设置一个带有该文件的循环设备(和一个偏移量),以便格式化第二个分区中的ext4文件系统。但是,在我这样做之后,我的分区表似乎被截断了!我很确定我已正确计算了偏移量......
为什么会这样?
请注意,此分区表有很多分区。我不得不增加我的内核 max_loop
设置为比正常的8个循环设备更多。目前, max_loop
设置为32。
这是捕获的输出,显示正在发生的事情:
steve@steve-VirtualBox:/s/src/scripted/image$ ls -l test
-rw-r--r-- 1 root root 3072000000 Jul 21 17:13 test
steve@steve-VirtualBox:/s/src/scripted/image$ fdisk -l test
Disk test: 3072 MB, 3072000000 bytes
255 heads, 63 sectors/track, 373 cylinders, total 6000000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b8bbe0f
Device Boot Start End Blocks Id System
test1 * 2048 67583 32768 c W95 FAT32 (LBA)
test2 67584 133119 32768 83 Linux
test3 133120 5999999 2933440 5 Extended
test5 135168 1708031 786432 83 Linux
test6 1710080 3282943 786432 83 Linux
test7 3284992 3416063 65536 83 Linux
test8 3418112 3428351 5120 83 Linux
test9 3430400 3440639 5120 83 Linux
test10 3442688 3452927 5120 83 Linux
test11 3454976 3465215 5120 83 Linux
test12 3467264 3991551 262144 83 Linux
test13 3993600 4255743 131072 83 Linux
test14 4257792 4268031 5120 83 Linux
test15 4270080 4280319 5120 83 Linux
test16 4282368 5999999 858816 83 Linux
steve@steve-VirtualBox:/s/src/scripted/image$ sudo losetup /dev/loop0 test -o 34603008
steve@steve-VirtualBox:/s/src/scripted/image$ sudo mkfs.ext4 /dev/loop0
mke2fs 1.42 (29-Nov-2011)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
185472 inodes, 741552 blocks
37077 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=763363328
23 block groups
32768 blocks per group, 32768 fragments per group
8064 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
steve@steve-VirtualBox:/s/src/scripted/image$ sudo losetup -d /dev/loop0
steve@steve-VirtualBox:/s/src/scripted/image$ fdisk -l test
Warning: invalid flag 0x0000 of partition table 5 will be corrected by w(rite)
Disk test: 3072 MB, 3072000000 bytes
255 heads, 63 sectors/track, 373 cylinders, total 6000000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b8bbe0f
Device Boot Start End Blocks Id System
test1 * 2048 67583 32768 c W95 FAT32 (LBA)
test2 67584 133119 32768 83 Linux
test3 133120 5999999 2933440 5 Extended
steve@steve-VirtualBox:/s/src/scripted/image$