使用 MBR 分区在基于 x86 的机器上运行的 FreeBSD 10.1 上创建 ext2 分区

使用 MBR 分区在基于 x86 的机器上运行的 FreeBSD 10.1 上创建 ext2 分区

我有旧的 FreeBSD 机器在基于 x86 的平台上运行,MBR 分区如下

pod0226-wsa115:rtestuser 1] uname -a
FreeBSD pod0226-wsa115 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Mon Mar 10 15:25:29 PDT 2014     [email protected]:/usr/build/iproot/freebsd/mods/src/sys/amd64/compile/MESSAGING_GATEWAY.amd64  amd64


pod0226-wsa115:rtestuser 2] df -h 
Filesystem       Size    Used   Avail Capacity  Mounted on
/dev/mfid0s1a    1.9G    356M    1.4G    20%    / 
devfs            1.0K    1.0K      0B   100%    /dev
/dev/mfid0s1d    1.9G    2.0K    1.7G     0%    /nextroot
/dev/mfid0s1e    374M    112K    344M     0%    /var
/dev/mfid0s1g    789G     45G    681G     6%    /data
/dev/mfid0s1h    1.9G     31K    1.8G     0%    /var/db/godspeed
procfs           4.0K    4.0K      0B   100%    /proc
linprocfs        4.0K    4.0K      0B   100%    /compat/linux/proc
linsysfs         4.0K    4.0K      0

我将 FreeBSD 升级到 10.1(下一个根分区用于升级)。由于内核不支持 ext2 启用,我将 /boot/kernel/kernel 替换为启用了 ext2 支持的 FreeBSD 内核。

尝试将分区格式化为 ext2 失败的帖子:

pod0226-wsa115:rtestuser 2] umount /dev/mfid0s1a
pod0226-wsa115:rtestuser 3] mke2fs /dev/mfid0s1a   -------------------------------------formatting nextroot  
mke2fs 1.42.10 (18-May-2014)
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: 7d23f5c1-1a72-4044-b167-26957605f4fd
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
**Warning: could not erase sector 0: Attempt to write block to filesystem resulted in short write**
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done 

a) 我已经确认硬盘是好的。如果我使用 GPT 分区格式化 HDD,则格式化时不会遇到任何问题。

我的疑问:使用 MBR 分区时,我是否需要在 FreeBSD 内核中启用其他任何功能才能创建 ext2 分区?

观察:我在 dmesg 中看到以下消息

ip_dn_ctl  dummynet: compat option 62
GEOM: mfid0s1a: invalid disklabel.
GEOM: ufsid/59ab725d8197dcee: invalid disklabel.
GEOM: mfid0s1a: invalid disklabel. ------------> first try 
GEOM: mfid0s1a: invalid disklabel. ------------> second try 
pod0226-wsa115:rtestuser 12] 

将分区格式化为 UFS 时,我没有看到“GEOM:mfid0s1a:无效磁盘标签”。对此有什么好的解释吗?

编辑:

从 ext2fs 实用程序维护者那里得到了以下响应。有人可以帮我破译一下吗。对 geom 或 BSDDISKLABELS 没有太多了解

    You can't freely write to bootblocks or other "Rank 1 geom providers",
    https://www.freebsd.org/cgi/man.cgi?geom(4) - look for "debugflags".
    You should not use ext2 on BSD partitions, but use it only on slices for 
    compatibility (which can then obviously not have BSD partitions).

BSD 内核启用了以下选项:

# 2 fibs.
options         ROUTETABLES=2

device          ichgpio

options         GEOM_BSD
options         GEOM_LABEL              # Provides labelization
options     GEOM_ELI
# The following breaks DIOCGDINFO
options         GEOM_PART_GPT           # GUID Partition Tables.
options         GEOM_MBR

更多日志:

pod0226-wsa115:rtestuser 15] gpart show -l 
=>        63  2339839937  mfid0  MBR  (1.1T)
          63  2339839908      1  (null)  [active]  (1.1T)
  2339839971          29         - free -  (15K)

=>         0  2339839908  mfid0s1c  BSD  (1.1T)
           0     4194304         1  (null)  (2.0G)
     4194304    16777216         2  (null)  (8.0G)
    20971520     4194304         4  (null)  (2.0G)
    25165824      819200         5  (null)  (400M)
    25985024   629145600         6  (null)  (300G)
   655130624  1680514980         7  (null)  (801G)
  2335645604     4194304         8  (null)  (2.0G)

pod0226-wsa115:rtestuser 16] 



pod0226-wsa115:rtestuser 14] disklabel /dev/mfid0s1d -----------> ufs partition
disklabel: /dev/mfid0s1d: no valid label found
pod0226-wsa115:rtestuser 15] 

pod0226-wsa115:rtestuser 8] mkfs.ext2 /dev/mfid0s1a ------> UFs partition unmounted and reformated as ext2 
mke2fs 1.42.10 (18-May-2014)
Creating filesystem with 524288 4k blocks and 131072 inodes
Filesystem UUID: c086c5ca-d2d4-4634-84b0-1c2d638feb28
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done                            
Warning: could not erase sector 0: Attempt to write block to filesystem resulted in short write
Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done 


pod0226-wsa115:rtestuser 9] dumpfs /dev/mfid0s1a
dumpfs: /dev/mfid0s1a: could not read superblock to fill out disk ------------------->


pod0226-wsa115:rtestuser 10] dumpfs /dev/mfid0s1d -------------------->UFS partition
magic   19540119 (UFS2) time    Thu Sep  7 16:30:02 2017
superblock location     65536   id      [ 59b1531e d697a7fb ]
ncg     4       size    262144  blocks  253839
bsize   65536   shift   16      mask    0xffff0000
fsize   8192    shift   13      mask    0xffffe000
frag    8       shift   3       fsbtodb 4
minfree 8%      optim   time    symlinklen 120
maxbsize 65536  maxbpg  8192    maxcontig 2     contigsumsize 2
nbfree  19937   ndir    1562    nifree  244191  nffree  142
bpg     8193    fpg     65544   ipg     65792   unrefs  0
nindir  8192    inopb   256     maxfilesize     36033195603132415
sbsize  8192    cgsize  24576   csaddr  2088    cssize  8192
sblkno  16      cblkno  24      iblkno  32      dblkno  2088
cgrotor 0       fmod    0       ronly   0       clean   0
metaspace 0     avgfpdir 64     avgfilesize 16384
flags   none
fsmnt   /nextroot
volname         swuid   0       providersize    0

cs[].cs_(nbfree,ndir,nifree,nffree):
        (6340,516,61381,25) (7154,24,65425,13) (3289,230,62198,21) (3154,792,55187,83) 
blocks in last group 8189


cg 0:
magic   90255   tell    30000   time    Thu Sep  7 16:29:32 2017
cgx     0       ndblk   65544   niblk   65792   initiblk 4864   unrefs 0
nbfree  6340    ndir    516     nifree  61381   nffree  25
rotor   14816   irotor  4333    frotor  14512
frsum   4       3       0       1       1       1       0
sum of frsum: 25
clusters 1-1:   1
clusters size 2 and over: 2
clusters free:  1816, 1853-1865, 1867-8192
inodes used:    0-4332, 4334-4352, 4355-4366, 4368-4375, 4378, 4380-4412,
        4421-4422, 4424-4426
blks free:      14518-14519, 14528-14535, 14560-14565, 14747-14751, 14758, 14798-14800,
        14804, 14807, 14814-14819, 14824-14927, 14936-65543

cg 1:
magic   90255   tell    20040000        time    Thu Sep  7 16:30:01 2017
cgx     1       ndblk   65544   niblk   65792   initiblk 768    unrefs 0
nbfree  7154    ndir    24      nifree  65425   nffree  13
rotor   8224    irotor  262     frotor  8088
frsum   2       2       1       1       0       0       0
sum of frsum: 13
clusters 1-1:   1
clusters size 2 and over: 1
clusters free:  0, 1040-8192
inodes used:    0-261, 263-367
blks free:      0-7, 7718, 8111, 8125-8127, 8140-8143, 8222-8223,
        8302-8303, 8320-65543

cg 2:
magic   90255   tell    40050000        time    Thu Sep  7 16:28:52 2017
cgx     2       ndblk   65544   niblk   65792   initiblk 4096   unrefs 0
nbfree  3289    ndir    230     nifree  62198   nffree  21
rotor   39256   irotor  3576    frotor  39224
frsum   2       1       0       1       0       1       1
sum of frsum: 21
clusters 1-1:   1
clusters size 2 and over: 2
clusters free:  0, 4870-4876, 4912-8192
inodes used:    0-3575, 3580-3597
blks free:      0-7, 38864-38867, 38952-38958, 38960-39021, 39223, 39231,
        39294-65543

cg 3:
magic   90255   tell    60060000        time    Thu Sep  7 16:29:32 2017
cgx     3       ndblk   65512   niblk   65792   initiblk 11008  unrefs 0
nbfree  3154    ndir    792     nifree  55187   nffree  83
rotor   40280   irotor  10485   frotor  33472
frsum   5       1       7       11      1       1       0
sum of frsum: 83
clusters 1-1:   1
clusters size 2 and over: 1
clusters free:  0, 5036-8188
inodes used:    0-10484, 10489-10491, 10493-10497, 10500-10502, 10504-10513, 10517-10582,
        10587-10619
blks free:      0-7, 32848-32850, 32856-32861, 32883, 32905-32907, 40109-40111,
        40127, 40135, 40143, 40151, 40157-40159, 40164-40167,
        40172-40175, 40180-40183, 40188-40191, 40196-40199, 40205-40207, 40212-40215,
        40220-40223, 40227-40231, 40237-40239, 40244-40247, 40252-40255, 40261-40263,
        40268-40271, 40278-40279, 40284-65511
pod0226-wsa115:rtestuser 11] 

答案1

首先 - 用支持 ext2 的内核替换内核并不是真正需要的;内核模块工作得很好。您可以在不加载模块的情况下执行“mount -t ext2fs”;它会自动加载。

其次 - 问题是你的 bsdlabel 分区表......很奇怪。那些“(null)”条目不应该在那里。 “无效磁盘标签”消息也表明了这一点。用于比较:

[trasz@v2:~]% gpart show
=>       63  314572737  ada0  MBR  (150G)
         63          1        - free -  (512B)
         64  314572736     1  freebsd  [active]  (150G)

=>        0  314572736  ada0s1  BSD  (150G)
          0  314572736       1  freebsd-ufs  (150G)

您可以销毁 BSD 磁盘标签并重新创建它吗?

相关内容