Verify UFS support
To check whether your Linux kernel supports the UFS filesystem you may execute the following command:
$ cat /proc/filesystems nodev sysfs nodev rootfs nodev proc . . . ext3 nodev usbfs vfat ufs
The keyword nodev in the first column means that filesystem does not require a block device to be mounted, that’s why it is also called virtual filesystem. The support is either compiled inside the kernel or as a module:
$ ls -l /lib/modules/2.6.21-ARCH/kernel/fs/ufs/ufs.ko -rw-r—r— 1 root root 84828 2007-05-25 20:11 /lib/modules/2.6.21-ARCH/kernel/fs/ufs/ufs.ko
Mount
In order to find the device that corresponds to your FFS partition, run:
So for FreeBSD (FFSv2), we have /dev/hda3 which is equivalent to /dev/ad0s3
And for NetBSD (FFSv1), we have /dev/hda4 which is equivalent to /dev/wd0c
But these devices are whole BSD slices (BIOS partitions), not BSD partitions.
By examinating carefully sfdisk — l output, we find that: /dev/hda3 (134767+,144935-) includes /dev/hda8 (134767+,143910-) and /dev/hda9 (143910+,144935-) /dev/hda4 (144935+,155060) includes /dev/hda10 (144935+,154078-) and /dev/hda11 (154078+,155060)
And we may deduce that for FreeBSD: /dev/hda8 is equivalent to /dev/ad0s3a (FreeBSD root partition) /dev/hda9 is equivalent to /dev/ad0s3b (FreeBSD swap)
And for NetBSD: /dev/hda10 is equivalent to /dev/wd0a (NetBSD root partition) /dev/hda11 is equivalent to /dev/wd0b (NetBSD swap)
Thus FreeBSD root partition lies at /dev/hda8. First create a directory to mount FFS partition and then mount it:
And NetBSD root partition lies at /dev/hda10 . First create a directory to mount FFS partition and then mount it:
Edit /etc/fstab
Add the following line to your /etc/fstab file:
Now you can mount the FFS partitions by typing:
and verify with:
Write support
Write support is available given several conditions are satisfied: — ufs write support option compiled in Linux kernel ( CONFIG_UFS_FS_WRITE=y ): it is disabled by default. — FFSv1 filesystem (FFSv2 not yet supported)
Please note that as I do not really need write support on NetBSD partitions from GNU/Linux, I did not bother to rebuild my Linux kernel and hence have not tested this feature.
Remarks
If you forget the ro option, you will get the following message at dmesg:
$ dmesg | grep ufs ufs was compiled with read-only support, can’t be mounted as read-write
If you forget to set the ufstype option, you will get the following message at dmesg:
$ dmesg | grep ufstype mount -t ufs -o ufstype=sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep .
WARNING late Monday evening, April 8th, 2019 late Sunday evening, November 20th, 2011 —>
Источник
Mounting UFS2 on Linux?
Гугл нашел полно топиков на эту тему, но ответа я так нигде и не нашел.
На один из LVM-разделов установлена FreeBSD 8.2
Что делаем и что получаем.
# mount -r -t ufs -o ufstype=ufs2 /dev/vgname/lvname /mnt/
# mount -r -t auto /dev/vgname/lvname /mnt/
mount: you must specify the filesystem type
- Вопрос задан более трёх лет назад
- 6279 просмотров
# aptitude search ufs
p aufs-tools — Tools to manage aufs filesystems
p aufs-tools-dbg — Tools to manage aufs filesystems (debug)
v libufsparse-dev —
p ttf-rufscript — handwriting-based font for Latin characters
p ufsutils — UFS filesystems utilities
Поставил ufsutils. Добавился бинарник mkfs.ufs, вроде больше ничего не изменилось.
LVM-раздел нужно монтировать через псевдоустройство losetup -f -o
losetup -f -o 32256 /dev/dm-1
mount /dev/loop0 /mnt/tmp/
А как понять какой dm мне нужен?
# ls /dev/dm*
/dev/dm-0 /dev/dm-1 /dev/dm-4 /dev/dm-5
И в какой loop он будет «проецировать»? Если я выполняю команду несколько раз? Или всегда в loop0 кладет?
# ls /dev/loop*
/dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 /dev/loop4 /dev/loop5 /dev/loop6 /dev/loop7
# losetup -f -o 32256 /dev/dm-4
Проверяем.
# losetup -a
/dev/loop0: [0005]:996440 (/dev/mapper/vgname-lvname), offset 32256
Все отлично. То, что нужно.
# mount /dev/loop0 /mnt
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog — try
dmesg | tail or so
В общем, чтобы полностью ответить на этот вопрос, привожу список действий которые нужно выполнить.
Сначала выясняем опытным путем какое dm устройство нам нужно. По логике вещей, чем больше число в конце, тем позднее был создан данный logical volume. Смотрим какие dm девайсы у нас есть:
# ls /dev/dm*
/dev/dm-0 /dev/dm-1 /dev/dm-4 /dev/dm-5
Выбираем нужный нам девайс и проецируем его в loop устройство. По умолчанию спроецируется в первый свободный loop (как правило, loop0).
losetup -f -o 32256 /dev/dm-4
Проверяем командой
losetup -a
Если не то спроецировали, то освобождаем данное loop устройство.
losetup -d /dev/loop0
Если все нормально, то делаем:
# mount -r -t ufs -o ufstype=ufs2 /dev/loop0 /mnt/
# ls mnt
dm устройство можно найти так (VG — название нужной volume group):
$ ls -l /dev/VG/
итого 0
lrwxrwxrwx 1 root root 7 Июн 8 22:21 Win2003 -> ../dm-0
lrwxrwxrwx 1 root root 7 Июн 8 22:48 Win2003Backup -> ../dm-2
lrwxrwxrwx 1 root root 7 Июн 8 22:47 Win2003Data -> ../dm-1
lrwxrwxrwx 1 root root 7 Июн 8 22:48 Win2003Users -> ../dm-3
Существующие volume group:
# vgs
VG #PV #LV #SN Attr VSize VFree
VG 1 4 0 wz—n- 465,76g 185,76g
Смещение для losetup вычисляем по выводу fdisk
# fdisk -lu /dev/dm-1
Disk /dev/dm-1: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders, total 125829120 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: 0x6f8b81c9
Device Boot Start End Blocks Id System
/dev/dm-1p1 * 63 125821079 62910508+ 7 HPFS/NTFS
Источник
Marc Abramowitz
Mounting UFS partitions in Linux
My desktop machine at work is now running RHEL 4, but before that it ran FreeBSD 4.10 for a number of years and had three hard drives with UFS filesystems. When my box was converted over to Linux, I backed up the critical files on the main hard drive and then reformatted the drive with ext3. The other two hard drives with UFS filesystems sat there collecting dust, which was unfortunate, because I could use the disk space. Today, I decided to mount the UFS partitions and look through the files and see if there’s anything worth keeping, before formatting these drives for Linux and getting myself a whole lot more disk space. Here’s how I did it.
The first task was to build the UFS kernel module, as my kernel did not have UFS support built-in, nor did my install have the UFS kernel module available. Already, having installed the proper kernel-devel RPM a while back, I did the following:
At this point, I had built the UFS kernel module and loaded it. Now it was time to mount the filesystems.
That’s it! I now had read-only access to my two UFS partitions. Now I have to look through these files and see what’s worth keeping.
2 thoughts on “ Mounting UFS partitions in Linux ”
I found your post while searching net for solution to my problem and I hope you will be able to help me. I’m quite new to Linux, now working with Ubuntu 7.04, I installed it as file/print server. The problem is that I had previously FreeBSD server and I want to copy data from ufs harddrive that was in that server. I tried to mount that hdd in Ubuntu and without luck therefore I think that might be there is no support for ufs in my kernel. How to find out what modules are compiled in kernel and if there is no ufs support then how to add it?
I would apreciate your help very much!
Thank you in advance!
Rauls
I’m trying to compile the UFS module for RHEL 4, running 2.6.9-42.0.3.ELsmp, but it isn’t working. When I run ‘make modules’, I get the following output:
CHK include/linux/version.h
CHK include/asm-x86_64/offset.h
make[1]: *** No rule to make target `arch/x86_64/kernel/../../i386/kernel/microcode.s’, needed by `arch/x86_64/kernel/../../i386/kernel/microcode.o’. Stop.
make: *** [arch/x86_64/kernel] Error 2
Do you have any tips on how to get this working? I’m running from /usr/src/kernels/2.6.9-42.0.3.EL-smp-x86_64.
Источник
Mount ufs in linux
The mount utility attaches a ufs file system to the file system hierarchy at the mount_point , which is the pathname of a directory. If mount_point has any contents prior to the mount operation, these are hidden until the file system is unmounted.
The ufs file system supports direct mounting of files containing the file system as well as block devices. See mount (1M) and lofiadm (1M).
If mount is invoked with special or mount_point as the only arguments, mount will search /etc/vfstab to fill in the missing arguments, including the specific_options . See mount (1M).
If special and mount_point are specified without any specific_options , the default is rw .
If the directory on which a file system is to be mounted is a symbolic link, the file system is mounted on the directory to which the symbolic link refers, rather than on top of the symbolic link itself.
OPTIONS
See mount (1M) for the list of supported generic_options .
The following options are supported:
Specify ufs file system specific options in a comma-separated list with no intervening spaces. If invalid options are specified, a warning message is printed and the invalid options are ignored. The following options are available:
By default, writing access time updates to the disk may be deferred ( dfratime ) for the file system until the disk is accessed for a reason other than updating access times. nodfratime disables this behavior.
If power management is enabled on the system, do not set nodfratime unless noatime is also set. If you set nodfratime without setting noatime , the disk is spun up every time a file within a file system on the disk is accessed — even if the file is not modified.
If forcedirectio is specified and supported by the file system, then for the duration of the mount, forced direct I/O will be used. If the filesystem is mounted using forcedirectio , data is transferred directly between user address space and the disk. If the filesystem is mounted using noforcedirectio , data is buffered in kernel address space when data is transferred between user address space and the disk. forcedirectio is a performance option that is of benefit only in large sequential data transfers. The default behavior is noforcedirectio .
If global is specified and supported on the file system, and the system in question is part of a cluster, the file system will be globally visible on all nodes of the cluster. If noglobal is specified, the mount will not be globally visible. The default behavior is noglobal .
Allow (do not allow) keyboard interrupts to kill a process that is waiting for an operation on a locked file system. The default is intr .
If nolargefiles is specified and supported by the file system, then for the duration of the mount it is guaranteed that all regular files in the file system have a size that will fit in the smallest object of type off_t supported by the system performing the mount. The mount will fail if there are any files in the file system not meeting this criterion. If largefiles is specified, there is no such guarantee. The default behavior is largefiles .
If nolargefiles is specified, mount will fail for ufs if the file system to be mounted has contained a large file (a file whose size is greater than or equal to 2 Gbyte) since the last invocation of fsck on the file system. The large file need not be present in the file system at the time of the mount for the mount to fail; it could have been created previously and destroyed. Invoking fsck (see fsck_ufs (1M)) on the file system will reset the file system state if no large files are present. After invoking fsck , a successful mount of the file system with nolargefiles specified indicates the absence of large files in the file system; an unsuccessful mount attempt indicates the presence of at least one large file.
If logging is specified, then logging is enabled for the duration of the mounted file system. Logging is the process of storing transactions (changes that make up a complete UFS operation) in a log before the transactions are applied to the file system. Once a transaction is stored, the transaction can be applied to the file system later. This prevents file systems from becoming inconsistent, therefore reducing the possibility that fsck might run. And, if fsck is bypassed, logging generally reduces the time required to reboot a system.
The default behavior is logging for all UFS file systems.
The log is allocated from free blocks in the file system, and is sized approximately 1 Mbyte per 1 Gbyte of file system, up to a maximum of 64 Mbytes.
Logging is enabled on any UFS file system, including root ( / ), except under the following conditions: o When logging is specifically disabled. o If there is insufficient file system space for the log. In this case, the following message is displayed and file system is still mounted:
The log created by UFS logging is continually flushed as it fills up. The log is totally flushed when the file system is unmounted or as a result of the lockfs -f command.
Mount the file system without making an entry in /etc/mnttab .
By default, the file system is mounted with normal access time ( atime ) recording. If noatime is specified, the file system will ignore access time updates on files, except when they coincide with updates to the ctime or mtime . See stat (2). This option reduces disk activity on file systems where access times are unimportant (for example, a Usenet news spool).
noatime turns off access time recording regardless of dfratime or nodfratime .
The POSIX standard requires that access times be marked on files. -noatime ignores them unless the file is also modified.
By default, Access Control Lists (ACLs) are supported on a mounted UFS file system. Use this option to disallow the setting or any modification of an ACL on a file within a mounted UFS file system. See getfacl (1) for background on ACLs.
This option specifies the action that UFS should take to recover from an internal inconsistency on a file system. Specify action as panic , lock , or umount . These values cause a forced system shutdown, a file system lock to be applied to the file system, or the file system to be forcibly unmounted, respectively. The default is panic .
Quotas are turned on for the file system.
Remounts a file system with a new set of options. All options not explicitly set with remount revert to their default values.
Read-write with quotas turned on. Equivalent to rw, quota .
Overlay mount. Allow the file system to be mounted over an existing mount point, making the underlying file system inaccessible. If a mount is attempted on a pre-existing mount point without setting this flag, the mount will fail, producing the error «device busy».
EXAMPLES
Example 1 Turning Off (and On) Logging
The following command turns off logging on an already mounted file system. The subsequent command restores logging.
In the preceding commands, the -F ufs option is not necessary.
FILES
table of mounted file systems
list of default parameters for each file system
ATTRIBUTES
See attributes (5) for descriptions of the following attributes:
|
SEE ALSO
NOTES
Since the root ( / ) file system is mounted read-only by the kernel during the boot process, only the remount option (and options that can be used in conjunction with remount ) affect the root ( / ) entry in the /etc/vfstab file.
Источник