Mount FreeBSD partition in Linux, mountfreebsd

Source: Internet
Author: User
Tags dmesg

Mount FreeBSD partition in Linux, mountfreebsd

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

Edit/etc/fstab

To enable automatic mounting, add the following two lines to the/etc/fstab file:

/Dev/hda8/mnt/freebsd ufs ufstype = ufs2, ro 0 2

/Dev/hda10/mnt/netbsd ufs ufstype = 44bsd, ro 0 2

Now you can mount the FFS partition and enter:

# Mount/mnt/freebsd

# Mount/mnt/netbsd

Run the following command for verification:

$ Mount

[...]

/Dev/hda8 on/mnt/freebsd type ufs (ro, ufstype = ufs2)

/Dev/hda10 on/mnt/netbsd type ufs (ro, ufstype = 44bsd)

[...]

Write support

Write is supported under the following conditions:

-Write is supported in the compiling option of Linux kernel, Which is disabled by default (CONFIG_UFS_FS_WRITE = y)

-FFSV1 File System (FFSv1) (not supported by FFSV2)

Note: Generally, you do not need to write data in the NetBSD partition, so do not recompile the kernel and test this feature.

Notes

1. If you forget the ro option, you may get the following message in dmesg:

$ Dmesg | grep ufs

Ufs was compiled with read-only support, can't be mounted as read-write

2. If you forget to set the ufstype option, you may get the following message in dmesg:

$ Dmesg | grep ufstype

Mount-t ufs-oufstype = sun | sunx86 | 44bsd | ufs2 | 5xbsd | old | hp | nextstep-cd | openstep...

WARNING <Wrong ufstype mayneed upt your filesystem, default is ufstype = old

3. Command for detaching a partition: 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

[2, 1279.960537] ufs_read_super: bad magic number

# Mount-t ufs-r-o ufstype = 44bsd/dev/sdb2/mnt/sdb3

4. view the partition information of each disk:

Root @ ubuntu :~ # File-Ls/dev/sdb1

/Dev/sdb1: x86 boot sector; partition 4: ID = 0xa5, active, startheactive 0, startsector 0, 50000 sectors, code offset 0x3c, BSD disklabelUnable to mount

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 disklabelUnable to mount

Root @ ubuntu :~ # File-Ls/dev/sdb3Mount-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 0 ms, disk rotational speed 60rps, TIMEoptimization

Root @ ubuntu :~ # File-Ls/dev/sdb4Mount-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 :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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.