Linux下mount FreeBSD分区
假設須要從第二塊硬盤復制文件。該硬盤格式化為UFS 2文件系統(tǒng)。怎樣mount 由FreeBSD創(chuàng)建的UFS 2文件系統(tǒng)到Ubuntu系統(tǒng)上呢?
UFS文件系統(tǒng)廣泛的使用在不同的操作系統(tǒng)(比如:HP-UX,Sun Solaris)中。包含FreeBSD。以下的語法用于掛載mount UFS 2文件系統(tǒng):
mount -t ufs -o ufstype=ufs2,ro /dev/sdXY/path/to/mnt/point
每一個分區(qū)包括一個文件系統(tǒng)存在FreeBSD中,稱為一個Slice。
Slice是FreeBSD中的一個術語,通常稱為分區(qū)。這是由于FreeBSD具有UNIX的背景,Slice是編號的,從1開始到4。
因此你須要使用等同的Linux分區(qū)名稱。
驗證UFS分區(qū)支持
?????? 為了檢查你的Linux內核是否支持UFS文件系統(tǒng)。你能夠運行以下的命令:
$ cat /proc/filesystems
輸出演示樣例:
nodev??sysfs
nodev??rootfs
nodev??bdev
nodev??proc
nodev??cpuset
nodev??binfmt_misc
nodev??debugfs
nodev??securityfs
nodev??sockfs
nodev??usbfs
nodev??pipefs
nodev??anon_inodefs
nodev??futexfs
nodev??tmpfs
nodev??inotifyfs
nodev??eventpollfs
nodev??devpts
???????ext2
nodev??ramfs
nodev??hugetlbfs
???????iso9660
nodev??mqueue
???????ext3
nodev??rpc_pipefs
nodev??autofs
?????? 第一行的keywordnodev含義是文件系統(tǒng)不須要掛載一個塊設備,這是為什么也稱為虛擬文件系統(tǒng)的原因。支持也被編譯到內核中或者作為一個單獨的模塊。
?????? 檢查是否安裝ufs驅動的方法:
方法1:# cat /proc/filesystems | grep ufs
方法2:ls -l /lib/modules/`uname -r`/kernel/fs/ufs/ufs.ko
?????? 第1中方法無輸出且第2種方法文件不存在表示UFS驅動沒有編譯到內核或作為模塊安裝。
安裝UFS驅動
root@ubuntu:~# modprobe ufs
root@ubuntu:~# cat /proc/filesystems| grep ufs
?????? ufs
# modinfo ufs
filename:??????/lib/modules/3.11.0-14-generic/kernel/fs/ufs/ufs.ko
license:??????? GPL
alias:????????? fs-ufs
srcversion:???? 961388D4E5A5AA94C372D19
depends:???????
intree:???????? Y
vermagic:?????? 3.11.0-14-generic SMP mod_unloadmodversions
root@ubuntu:~# uname -r
3.11.0-14-generic
root@ubuntu:~# ll/lib/modules/3.11.0-14-generic/kernel/fs/ufs/ufs.ko
# lsmod | grep ufs
# grep BSD_DISKLABEL /boot/config-`uname -r`
CONFIG_BSD_DISKLABEL=y
# grep UFS /boot/config-`uname-r`
CONFIG_UFS_FS=m
# dmesg |grep bsd
mount -t ufs -oufstype=sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...
掛載UFS硬盤
?????? 依賴于你的FreeBSD的分區(qū)類型是UFS1還是UFS2,你須要引用不同的掛載選項。
UFS1使用ufstype=44bsd。UFS2使用ufstype=ufs2.
?
?????? 為了發(fā)現FFS分區(qū)所相應的設備,執(zhí)行:
# fdisk -l
# sfdisk -l
???
Disk /dev/hda: 155061 cylinders, 16 heads,63 sectors/track
Warning: extended partition does not startat a cylinder boundary.
DOS and Linux will interpret the contentsdifferently.
Units = cylinders of 516096 bytes, blocksof 1024 bytes, counting from 0
?Device Boot Start???? End?? #cyls???#blocks?? Id? System
/dev/hda1??*????? 0+? 34536-?34537-? 17406396??? 7?HPFS/NTFS
?????????????? end: (c,h,s) expected(1023,15,63) found (1023,254,63)
/dev/hda2????? 34536+ 134767- 100231-? 50516392+??f? W95 Ext'd (LBA)
?????????????? start: (c,h,s) expected(1023,15,63) found (1023,255,63)
?????????????? end: (c,h,s) expected(1023,15,63) found (1023,254,63)
/dev/hda3???? 134767+144935-? 10169-?? 5124735??a5? FreeBSD
?????????????? start:(c,h,s) expected (1023,15,63) found (1023,255,63)
?? ????????????end: (c,h,s) expected (1023,15,63)found (1023,254,63)
/dev/hda4????144935+ 155060?? 10126-?? 5103189??a9? NetBSD
??????????????start: (c,h,s) expected (1023,15,63) found (1023,255,63)
?????????????? end:(c,h,s) expected (1023,15,63) found (1023,80,63)
/dev/hda5????? 34536+ 102366-? 67830-?34186288+? 83? Linux
?????????????? start: (c,h,s) expected(1023,15,63) found (0,1,1)
?????????????? end: (c,h,s) expected(1023,15,63) found (1023,254,63)
/dev/hda6???? 102366+ 104294??? 1929-???971901?? 82? Linux swap / Solaris
?????????????? start: (c,h,s) expected(1023,15,63) found (0,1,1)
?????????????? end: (c,h,s) expected(1023,15,63) found (120,254,63)
/dev/hda7???? 104295+ 134767-? 30473-?15358108+? 83? Linux
?????????????? start: (c,h,s) expected(1023,15,63) found (0,1,1)
?????????????? end: (c,h,s) expected(1023,15,63) found (1023,254,63)
/dev/hda8???? 134767+143910-?? 9143-?? 4608000
/dev/hda9???? 143910+144935-?? 1026-??? 516735
/dev/hda10???144935+ 154078-?? 9143??? 4608072
/dev/hda11???154078+ 155060???? 983-??? 495117
/dev/hda12???????? 0+?34536-? 34537-? 17406396
/dev/hda13???? 34536+ 102366-? 67830-?34186288+
/dev/hda14??? 102366+ 104294??? 1929-???971901
/dev/hda15??? 104295+ 144935-? 40641-?20482843+
?????? 因此,對于FreeBSD(FFSv2),/dev/hda3等價于/dev/ad0s3
?????? NetBSD(FFSv1),/dev/hda4等價于/dev/wd0c。
?????? 可是這些設備是整個BSD的Slice(BOIS分區(qū)),不是BSD分區(qū)。
?????? 通過細致檢查sfdisk的輸出結果,我們發(fā)現/dev/hda3包括/dev/hda8和/dev/hda9,/dev/hda4包括/dev/hda10和/dev/hda11。
?????? 我們能夠推出。對于FreeBSD/dev/hda8等價于/dev/ad0s3a(FreeBSD的根分區(qū)),/dev/hda9等價于/dev/ad0s3b(FreeBSD的Swap分區(qū))。
?????? 對于NetBSD。/dev/had10等價于/dev/wd0a(NetBSD根分區(qū))。/dev/hda11等價于/dev/wd0b(NetBSD的Swap分區(qū))。
?????? 因此FreeBSD的根分區(qū)位于/dev/hda8。首先創(chuàng)建一個文件夾用于mountFFS分區(qū),然后掛載它。
# mkdir/mnt/freebsd
# mount -t ufs-o ro,ufstype=ufs2 /dev/hda8 /mnt/freebsd/
NetBSD的根分區(qū)位于/dev/hda10上,首先創(chuàng)建一個掛載FFS分區(qū)的文件夾,然后掛載它。
# mkdir/mnt/netbsd
# mount -t ufs-o ro,ufstype=44bsd /dev/hda10 /mnt/netbsd/
讓我們?yōu)g覽掛載的文件夾:
# ls /mnt/*bsd
/mnt/freebsd:
bin??cdrom?? COPYRIGHT? dist????etc?? lib????? media?proc??? root? sys?usr
boot?compat? dev????? ??entropy?home? libexec? mnt???rescue? sbin? tmp?var
/mnt/netbsd:
altroot?etc????????????????gnome-screensave.core? mnt????? root??var
bin?????GENERIC???????????? kern?????????????????? netbsd?? sbin
boot????GENERIC-DIAGNOSTIC? lib???????????????? ???onetbsd?stand
CUSTOM??GENERIC-LAPTOP????? libdata??????????????? proc???? tmp
dev?????GENERIC-NOACPI????? libexec??????????????? rescue?? usr
編輯/etc/fstab
為了開機自己主動掛載。須要加入以下兩行到/etc/fstab文件里:
/dev/hda8?????? /mnt/freebsd???? ufs????ufstype=ufs2,ro??????? 0?????? 2
/dev/hda10????? /mnt/netbsd????? ufs????ufstype=44bsd,ro?????? 0?????? 2
如今你能掛載FFS分區(qū),輸入:
# mount/mnt/freebsd
# mount/mnt/netbsd
而且使用以下命令驗證:
$ mount
[...]
/dev/hda8 on/mnt/freebsd type ufs (ro,ufstype=ufs2)
/dev/hda10 on/mnt/netbsd type ufs (ro,ufstype=44bsd)
[...]
寫入支持
?????? 滿足幾個條件下能夠支持寫:
-?????????在Linux內核中編譯選項支持寫入,缺省禁用的(CONFIG_UFS_FS_WRITE=y)
-?????????FFSV1文件系統(tǒng)(FFSv1)(FFSV2不支持)
請注意:普通情況下你不須要在NetBSD分區(qū)上寫入。因此不要又一次編譯內核和測試該特性。
附注
?????? 1.假設你忘記ro選項。你可能在dmesg中獲得例如以下消息:
$ dmesg | grep ufs
ufs was compiled with read-only support,can't be mounted as read-write
?????? 2.假設你忘記設置ufstype選項,你可能在dmesg中獲得以下的消息:
$ dmesg | grep ufstype
mount -t ufs -oufstype=sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...
WARNING<<< Wrong ufstype maycorrupt your filesystem, default is ufstype=old
?????? 3.卸載分區(qū)的命令:umount /mnt
# mount -t ufs-r -o ufstype=ufs2 /dev/sdb3 /mnt/sdb3
mount: wrong fstype, bad option, bad superblock on /dev/sdb3,
?????? missing codepage or helper program, orother error
?????? In some cases useful info is found insyslog - try
?????? dmesg | tail? or so
?????? #dmesg | tail
?????? [1279.960537] ufs_read_super: bad magic number
?????? #mount -t ufs -r -o ufstype=44bsd /dev/sdb2 /mnt/sdb3
4. 查看各個磁盤的分區(qū)信息:
root@ubuntu:~# file -Ls /dev/sdb1
/dev/sdb1: x86 boot sector; partition 4:ID=0xa5, active, starthead 0, startsector 0, 50000 sectors, code offset 0x3c,BSD disklabel? ?無法掛載
root@ubuntu:~# file -Ls /dev/sdb2
/dev/sdb2: x86 bootsector; partition 4: ID=0xa5, active, starthead 0,startsector 0, 50000 sectors, code offset 0x3c, BSD disklabel? ?無法掛載
root@ubuntu:~# file -Ls /dev/sdb3?????????????? mount -o ufstype=44bsd -r -t ufs
/dev/sdb3: Unix Fast File system [v1](little-endian), last mounted on /cf, last written at Tue Nov 18 19:16:31 2014,clean flag 1, number of blocks 2104515, number of data blocks 2069056, numberof cylinder groups 82, block size 4096, fragment size 512, minimum percentageof free blocks 8, rotational delay 0ms, disk rotational speed 60rps, TIMEoptimization
root@ubuntu:~# file -Ls /dev/sdb4???? ?????mount-o ufstype=ufs2 -r -t ufs
/dev/sdb4: Unix Fast File system [v2](little-endian) last mounted on /var/log, last written at Tue Nov 18 11:16:432014, clean flag 1, readonly flag 0, number of blocks 4909865, number of datablocks 4753848, number of cylinder groups 31, block size 32768, fragment size4096, average file size 16384, average number of files in dir 64, pendingblocks to free 0, pending inodes to free 0, system-wide uuid 0, minimumpercentage of free blocks 8, TIME optimization
轉載于:https://www.cnblogs.com/jhcelue/p/6858159.html
總結
以上是生活随笔為你收集整理的Linux下mount FreeBSD分区的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FineReport连接多维数据库示例及
- 下一篇: jquery源码 DOM加载