Mount FreeBSD partition in Linux
If you need to copy a file from the second hard disk and format it as a UFS 2 file system, how can you mount the UFS 2 file system created by FreeBSD to the Ubuntu system?
UFS file systems are widely used in different operating systems (such as HP-UX, Sun Solaris), including FreeBSD. The following syntax is used to mount the mount UFS 2 file system:
Mount-t ufs-o ufstype = ufs2, ro/dev/sdXY/path/to/mnt/point
Each partition contains a file system in FreeBSD, which is called a Slice. Slice is a term in FreeBSD and is usually called a partition. This is because FreeBSD has a UNIX background, and Slice is numbered from 1 to 4. Therefore, you need to use the same Linux partition name.
Verify UFS partition support
To check whether your Linux kernel supports the UFS file system, run the following command:
$ Cat/proc/filesystems
Output example:
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
The keyword nodev In the first line indicates that the file system does not need to mount a block device, which is also called a virtual file system. It can also be compiled into the kernel or used as a separate module.
To check whether the ufs driver is installed:
Method 1: # cat/proc/filesystems | grep ufs
Method 2: ls-l/lib/modules/'uname-R'/kernel/fs/ufs. ko
If method 1st has no output and the 2nd method file does not exist, the UFS driver is not compiled to the kernel or installed as a module.
Install UFS driver
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. 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. 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-cd | openstep...
Attach UFS Hard Disk
It depends on whether the partition type of FreeBSD is UFS1 or UFS2. You need to reference different mount options. UFS1 uses ufstype = 44bsd, and UFS2 uses ufstype = ufs2.
To find the device corresponding to the FFS partition, run:
# 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,254, 15, 63) found (, 63)
/Dev/hda2 34536 + 134767-100231-50516392 + f W95 Ext 'd (LBA)
Start: (c, h, s) expected (1023,255, 15, 63) found (, 63)
End: (c, h, s) expected (1023,254, 15, 63) found (, 63)
/Dev/hda3 134767 + 144935-10169-5124735 a5 FreeBSD
Start :( c, h, s) expected (1023,255, 15, 63) found (, 63)
End: (c, h, s) expected (1023,254, 15, 63) found (, 63)
/Dev/hda4 144935 + 155060 10126-5103189 a9 NetBSD
Start: (c, h, s) expected (1023,255, 15, 63) found (, 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)
End: (c, h, s) expected (1023,254, 15, 63) found (, 63)
/Dev/hda6 102366 + 104294 1929-971901 82 Linux swap/Solaris
Start: (c, h, s) expected (1023,15, 63) found (0, 1)
End: (c, h, s) expected (120,254, 15, 63) found (, 63)
/Dev/hda7 104295 + 134767-30473-15358108 + 83 Linux
Start: (c, h, s) expected (1023,15, 63) found (0, 1)
End: (c, h, s) expected (1023,254, 15, 63) found (, 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 +
Therefore, for FreeBSD (FFSv2),/dev/hda3 is equivalent to/dev/ad0s3.
NetBSD (FFSv1),/dev/hda4 is equivalent to/dev/wd0c.
However, these devices are the Slice (BOIS partition) of the entire BSD, not the BSD partition.
By carefully checking the output results of sfdisk, we found that/dev/hda3 contains/dev/hda8 and/dev/hda9,/dev/hda4 contains/dev/hda10 and/dev/hda11.
We can introduce that FreeBSD/dev/hda8 is equivalent to/dev/ad0s3a (root partition of FreeBSD) And/dev/hda9 is equivalent to/dev/ad0s3b (Swap partition of FreeBSD ).
For NetBSD,/dev/had10 is equivalent to/dev/wd0a (NetBSD root partition) And/dev/hda11 is equivalent to/dev/wd0b (NetBSD Swap partition ).
Therefore, the root partition of FreeBSD is located at/dev/hda8. First, create a directory for the mountFFS partition and then mount it.
# Mkdir/mnt/freebsd
# Mount-t ufs-o ro, ufstype = ufs2/dev/hda8/mnt/freebsd/
The root partition of NetBSD is located on/dev/hda10. First, create a directory for mounting the FFS partition and then mount it.
# Mkdir/mnt/netbsd
# Mount-t ufs-o ro, ufstype = 44bsd/dev/hda10/mnt/netbsd/
Let's browse the mounted directory:
# 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
For more details, please continue to read the highlights on the next page: