从Linux下的逻辑分区挂载FreeBSD UFS

如何在此设置中在Ubuntu下安装FreeBSD UFS启动分区:

>一个包含的单个硬盘
>包含的MBR分区表
>一些主要的Linux分区和一个包含的扩展分区
>一个Linux逻辑分区和一个包含的FreeBSD逻辑分区
> FreeBSD disklabel(所以逻辑分区是“slice”)包含
> FreeBSD启动(UFS)和交换分区

这是MBR分区:

ubuntu$sudo fdisk -l /dev/sda

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 cylinders, total 83886080 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: 0x0005d5af

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1953791      975872   83  Linux
/dev/sda2         1953792    11718655     4882432   83  Linux
/dev/sda3        11718656    13672447      976896   82  Linux swap /     Solaris
/dev/sda4        13674494    83884031    35104769    5  Extended
/dev/sda5        13674496    33204223     9764864   83  Linux
/dev/sda6        33206272    83884031    25338880   a5  FreeBSD

这是disklabel:

freebsd$disklabel /dev/ada0s6
# /dev/ada0s6:
8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:   48580592         16    4.2BSD        0     0     0
  b:    2097152   48580608      swap                    
  c:   50677760          0    unused        0     0     # "raw" part, don't edit

我可以使用以下/etc/grub.d/40_custom启动FreeBSD:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "FreeBSD" {
    insmod part_bsd
    insmod ufs2
    set root="(hd0,msdos6,bsd1)"
    kfreebsd /boot/kernel/kernel
    set kFreeBSD.acpi_load=YES
    set kFreeBSD.hint.acpi.0.disabled=0
    set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada0s6a
    kfreebsd_loadenv /boot/device.hints
}

这样我就可以毫无问题地从grub2访问FreeBSD分区.但是Linux没有检测到任何BSD分区:

ubuntu$ls /dev/sda*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3  /dev/sda4  /dev/sda5  /dev/sda6

版本:Ubuntu 14.04,内核4.2.0-27-通用x86_64,FreeBSD 10.3 RELEASE amd64,两个全新安装.

解决方法:

解决方法是计算逻辑分区中BSD分区的偏移量,并使用带偏移量的循环设备:

mount -t ufs -o loop,offset=8192,ro,ufstype=ufs2 /dev/sda6 /mnt
上一篇:FreeBSD上的Java


下一篇:FreeBSD vs Linux:内核调用约定的性能