freebsd和linux分区一样吗,linux下对FreeBSD分区读写操作

通常默认的,如果linux内核更新到 kernel 2.6.29, 就已经支持 UFS文件系统的 写操作了。但是考虑到 危险性操作,一般不会直接就支持写操作。

所以,linux 系统 通常只可以 "只读 " 来挂载 UFS文件系统。

$ sudo mount -t ufs -o ufstype=ufs2 /dev/sdb5 /mnt/

mount: wrong fs type, bad option, bad superblock on /dev/sdb5,

missing codepage or helper program, or other error

In some cases useful info is found in syslog - try

dmesg | tail or so

$ dmesg | tail -n 1

[ 871.777769] ufs was compiled with read-only support, can't be mounted as read-write

为了实现挂载上它,需要专门的 只读 标识:

$ sudo mount -t ufs -o ro,ufstype=ufs2 /dev/sdb2 /mnt/

首先,需要下载当前系统的内核源码,然后复制当前的内核为 .config

$ sudo -s

# apt-get install linux-source-2.6.27

# cd /usr/src

# bzip2 -dc linux-source-2.6.27.tar.bz2 | tar xf -

# cp /boot/config-2.6.27-2-686 .config

为了增加UFS 写支持到内核,去掉/增加 CONFIG_UFS_WRITE 标识在内核config ,然后从新编译它。

$ grep CONFIG_UFS_FS_WRITE /usr/src/linux-source-2.6.27/.config

CONFIG_UFS_FS_WRITE=y

To compile my kernel, I followed the instruction here_  . I just added CONCURRENCY_LEVEL=2 to use the 2 cores of my CPU.

编译内核时,可是查看介绍 (followed the instruction here_) ,这里 只是添加 CONCURRENCY_LEVEL=2 来使用 双核 cpu

$ sudo -s

# CONCURRENCY_LEVEL=2 make-kpkg --initrd --append-to-version=-2-686-ufs kernel-image kernel-headers

一旦编译完成,安装刚刚建立的 内核.(可以在 /usr/src 找到 .deb 文件),然后重启。

$ sudo dpkg -i /usr/src/linux-image-2.6.27-1-686-ufs_2.6.27-1-686-ufs-10.00.Custom_i386.deb

注意到一些用户:当booting 时有错误,可能时因为忘记了把 initrd  结合到内核中。这时,如果使用的时内核 kernel-package-12.009 (或者更高),确保  来使得 initrd 也同时安装(如果卸载它,删除就可) :

cp /usr/share/kernel-package/examples/etc/kernel/postinst.d/initramfs /etc/kernel/postinst.d/

cp /usr/share/kernel-package/examples/etc/kernel/postrm.d/initramfs /etc/kernel/postrm.d/

一旦启动了 “UFS-writable”内核,

$ sudo fdisk -l /dev/sdb

Disk /dev/sdb: 500.1 GB, 500107862016 bytes

255 heads, 63 sectors/track, 60801 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk identifier: 0x8f8000b1

Device Boot Start End Blocks Id System

/dev/sdb1 1 1958 15727603+ 83 Linux

/dev/sdb2 * 1959 4569 20972857+ a5 FreeBSD

/dev/sdb3 4570 4830 2096482+ 82 Linux swap / Solaris

/dev/sdb4 4831 60801 449587057+ 83 Linux

这里,/dev/sdb2 包含了 UFS 文件系统。

如果详细的查看 /dev ,就可以看到所有的信息(当然这里已经执行了"可写")

$ ls -l /dev/sdb*

brw-rw---- 1 root disk 8, 16 2009-04-04 16:20 /dev/sdb

brw-rw---- 1 root disk 8, 17 2009-04-04 14:20 /dev/sdb1

brw-rw---- 1 root disk 8, 18 2009-04-04 16:20 /dev/sdb2

Then, I mounted the slices in the right order and to the right mount

points (in /mnt/) to have my FreeBSD exact filesystem environment. Then I

copied back all the data using the old and nice tar technique, as root:

# ( cd /path/to/backup && tar cpf - . ) | ( cd /mnt/ && tar xvfp - )

Once the "un"-tar was done, I rebooted on my FreeBSD system (from

which I am writing this post), forced the fsck of all my slices: everything seems to be OK!

Conclusion

The CONFIG_UFS_FS_WRITE kernel flag is still set as experimental, but it did work like charm for me (using kernel 2.6.27).

If you do use it, and you find a bug, please report it :)

Hope this was helpful.

Cheers,

Ignace M -ghantoos-

Sources

http://www.quietearth.us/articles/2006/09/15/Ubuntu-Compiling-a-custom-kernel

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值