Sunday, February 18, 2007

Gentoo: Mounting UFS2

The other day I have problem when mounting my USB pendrive and I have no time to check and fix it. Then I decide to take a look today. I plug in my new USB pendrive, and run dmesg -

usb 1-3: new high speed USB device using ehci_hcd and address 4
usb 1-3: configuration #1 chosen from 1 choice
scsi2 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 4
usb-storage: waiting for device to settle before scanning
scsi 2:0:0:0: Direct-Access USB DISK Pro PMAP PQ: 0 ANSI: 0 CCS
SCSI device sdb: 4012032 512-byte hdwr sectors (2054 MB)
sdb: Write Protect is off
sdb: Mode Sense: 23 00 00 00
sdb: assuming drive cache: write through
SCSI device sdb: 4012032 512-byte hdwr sectors (2054 MB)
sdb: Write Protect is off
sdb: Mode Sense: 23 00 00 00
sdb: assuming drive cache: write through
sdb: sdb1
sd 2:0:0:0: Attached scsi removable disk sdb
sd 2:0:0:0: Attached scsi generic sg1 type 0
usb-storage: device scan complete

Since I have formatted it to UFS2 file system, I need to mount it with the command line below -

shell>mount -t ufs /dev/sdb1 /mnt/usbmini


It seems unlikely that I can mount it properly, checking the dmesg again, I got this -

ufs was compiled with read-only support, can't be mounted as read-write
You didn't specify the type of your ufs filesystem

mount -t ufs -o ufstype=sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...

>>>WARNING<<< ufstype="old" style="font-weight: bold;">shell>mount -t ufs -o ufstype=ufs2 /dev/sdb1 /mnt/usbmini

It fails again and I got the dmesg below -

ufs_read_super: bad magic number
ufs was compiled with read-only support, can't be mounted as read-write

Thus I tried with -

shell>mount -t ufs -o ufstype=ufs2,ro /dev/sdb1 /mnt/usbmini


Now it can be mounted successfully with read-only capability, however I want it to be able to read and write the file system. It is reported that ufs is compiled with read-only support in kernel, so what I can do now is checking my kernel config

shell>egrep -i 'ufs' /usr/src/linux-2.6.19-gentoo-r5/.config
CONFIG_UFS_FS=y
# CONFIG_UFS_FS_WRITE is not set
# CONFIG_UFS_DEBUG is not set


There it goes, I just need to modify the value for CONFIG_UFS_FS_WRITE

CONFIG_UFS_FS_WRITE=y

Recompiling kernel can be done in a glance -

shell>make && make modules_install && make modules_install install

Reboot the Operating System and try again -

shell>mount -t ufs -o ufstype=ufs2 /dev/sdb1 /mnt/usbmini


Checking the mount status -

shell>mount | grep sdb1
/dev/sdb1 on /home/geek00l/mnt/usb-mini type ufs (rw,ufstype=ufs2)

Hopefully you have fun, actually I'm testing this in case if I need to perform forensic on BSD operating system.

Enjoy (;])

2 comments:

Anonymous said...

hi,
did you ever tried to write to the fs?
i did build the module with write-support, and mount tells me 'rw'.
but when i want to write, i get 'Read-only file system'

what kernel-version are you using?
thanx in advance

Anonymous said...

You can use qtparted to format the drive.