PDA

View Full Version : [Solved] mounting Linux FS


hirohitosan
December 9th, 2008, 14:45
Hi there.
I completed the installation of FreeBSD on my comp.

My computer has 2 HDD. On the first HDD I have Ubuntu and I think but not sure that has ext3 FS.

I created the mount point an try some:
# fdisk -l
fdisk: illegal option -- l
usage: fdisk [-BIaipstu] [-b bootcode] [-1234] [disk]
fdisk -f configfile [-itv] [disk]

and
# # ls /dev/
acd0 cuad0.init kbdmux0 stdout ttyvb
acpi cuad0.lock klog sysmouse ttyvc
ad6 cuad1 kmem ttyd0 ttyvd
ad6s1 cuad1.init log ttyd0.init ttyve
ad6s2 cuad1.lock mdctl ttyd0.lock ttyvf
ad6s5 dcons mem ttyd1 ukbd0
ad8 devctl net ttyd1.init ums0
ad8s1 devstat net1 ttyd1.lock urandom
ad8s1a dgdb net2 ttyp0 usb
ad8s1b dumpdev net3 ttyp1 usb0
ad8s1c fd net4 ttyv0 usb1
ad8s1d fido network ttyv1 usb2
ad8s1e fw0 nfs4 ttyv2 usb3
ad8s1f fw0.0 nfslock ttyv3 usb4
ata fwmem0 null ttyv4 usb5
atkbd0 fwmem0.0 pci ttyv5 usb6
audit geom.ctl ptyp0 ttyv6 usb7
console io ptyp1 ttyv7 xpt0
consolectl kbd0 random ttyv8 zero
ctty kbd1 stderr ttyv9
cuad0 kbd2 stdin ttyva

How can I mount the Linux HDD and where is in /dev?
it is ad6, ad6s1, ad6s2, ad6s5?

thanks

Ole
December 9th, 2008, 14:55
for view slices and partition type:

fdisk -p /dev/ad6
and then

mount -o ro -t ext2fs /dev/ad6s1 /mnt
or
mount -o ro -t ext2fs /dev/ad6s2 /mnt

SirDice
December 9th, 2008, 14:56
Try fdisk ad6 and fdisk ad8. That should show you the ext3 partition. If it's on the first disk it's probably ad6s1.

hirohitosan
December 9th, 2008, 15:29
# fdisk -p /dev/ad6
# /dev/ad6
g c969021 h16 s63
p 1 0x83 63 953409492
a 1
p 2 0x05 953409555 23358510

and
# fdisk ad6
******* Working on device /dev/ad6 *******
parameters extracted from in-core disklabel are:
cylinders=969021 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=969021 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 131 (0x83),(Linux native)
start 63, size 953409492 (465531 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 2 is:
sysid 5 (0x05),(Extended DOS)
start 953409555, size 23358510 (11405 Meg), flag 0
beg: cyl 1023/ head 254/ sector 63;
end: cyl 1023/ head 254/ sector 63
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>


I suppose that the disk ad6 has 2 partitions, one is ext2fs and the other is swap
So I suppose
ad6s1 is the root / partition with ext2fs
ad6s2 is the swap partition
ad6s5 .... I don't know

hirohitosan
December 9th, 2008, 16:05
well I tried:
# mount -o ro -t ext2fs /dev/ad6s1 /disc01/
# ls /disc01
ls: /disc01: Bad file descriptor
# mount -o ro -t ext2fs /dev/ad6s2 /disc01/
mount: /disc01: Bad file descriptor


where is the problem?

adamk
December 9th, 2008, 16:10
You need to apply this patch to your kernel sources and rebuild at least the ext2fs kernel module:

http://pastebin.ca/raw/1280738

The ext2fs kernel module currently available in -STABLE (and maybe -CURRENT) does not support inode sizes higher than 128, and many distributions now use 256.

Adam

hirohitosan
December 9th, 2008, 16:12
well after this I could not read the /disc01 directory (I created for mount point) so I restarted the system. A lot of numbers appear on the screen and finally "Giving up on 27 buffers". What does it means?

hirohitosan
December 9th, 2008, 16:16
You need to apply this patch to your kernel sources and rebuild at least the ext2fs kernel module:

http://pastebin.ca/raw/1280738

I never apply apatch to the kernel and I don't know how to do it. Can you give my some hints?

Thanks

brd@
December 9th, 2008, 16:52
You need to apply this patch to your kernel sources and rebuild at least the ext2fs kernel module:

http://pastebin.ca/raw/1280738

The ext2fs kernel module currently available in -STABLE (and maybe -CURRENT) does not support inode sizes higher than 128, and many distributions now use 256.

Adam

Is there a PR that references this patch?

gnemmi
December 9th, 2008, 17:28
Yes there is brd@ you can find it in here:

http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/124621

Here you can find the patch that I used:

http://pflog.net/~floyd/ext2fs.diff

More on this topic:

mounting linux partitions
Fri May 9 18:05:26 UTC 2008
http://lists.freebsd.org/pipermail/freebsd-questions/2008-May/174588.html

bad file descriptor when mounting an ext2fs.
Tue Jun 10 11:08:46 UTC 2008
http://lists.freebsd.org/pipermail/freebsd-questions/2008-June/176506.html

mounting ext2fs partitions on FBSD7 ( third time a charm?)
Fri Jul 4 23:33:53 UTC 2008
http://lists.freebsd.org/pipermail/freebsd-questions/2008-July/178219.html

256-byte inode support
Sat Sep 6 23:46:33 UTC 2008
http://lists.freebsd.org/pipermail/freebsd-hackers/2008-September/025912.html

ext2 inode size patch - RE: PR kern/124621
Mon Nov 24 11:29:59 PST 2008
http://lists.freebsd.org/pipermail/freebsd-stable/2008-November/046758.html

ext2 inode size patch - RE: PR kern/124621
Wed Dec 3 14:53:46 PST 2008
http://lists.freebsd.org/pipermail/freebsd-stable/2008-December/046916.html

I´ve had a conversation with Josh (email) and he kindly explained me how to apply the patch and test it. So far, so _good_ to me ... not a single problem on daily usage.

Hope you find that info usefull :)

Regards

hirohitosan
December 12th, 2008, 17:49
Reading the above links I don't understand if it's possible or not to mount Linux volumes.

All my information are in Linux volume and I don't know how to transfer them in FreeBSD.

I tried to mount the FreeBSD volume in Linux but no chance ... :(

gnemmi
December 13th, 2008, 05:44
You can mount ext2/3fs as long as they have an "Inode size" equal to 128.

Otherwise (if "Inode size" equals 256), you won't be able to mount those ext2/3 partitions unless you apply Josh's patch. Or to be more spesific ... you will be able to mount them but you won't be able to acces the data on them .. and you'll get a "Bad file descriptor" every time you try to acces said mounted partition.

In order to find out whether your ext2/3 partitions have a 128 or a 256 "Inode size", issue the following command as root:


root@inferna:~ # tune2fs -l /dev/ad4s6 | grep "Inode size"
Inode size: 256


of course .. you will have to change "/dev/ad4s6" to the correct ext2/3 linux partition in your drive ...

At leas that was my experience ..

Hope that helps :)

hirohitosan
December 13th, 2008, 10:29
In order to find out whether your ext2/3 partitions have a 128 or a 256 "Inode size", issue the following command as root:


root@inferna:~ # tune2fs -l /dev/ad4s6 | grep "Inode size"
Inode size: 256


well I tried
# tune2fs -l /dev/ad6s1 | grep "Inode size"
tune2fs: Command not found.
# whatis tune2fs
tune2fs: nothing appropriate

maybe I have to install something?

gnemmi
December 13th, 2008, 10:33
[gonzalo@inferna ~]% which tune2fs
/usr/local/sbin/tune2fs
[gonzalo@inferna ~]% pkg_info -W /usr/local/sbin/tune2fs
/usr/local/sbin/tune2fs was installed by package e2fsprogs-1.41.3
[gonzalo@inferna ~]% pkg_info -xqo e2fsprogs
sysutils/e2fsprogs
[gonzalo@inferna ~]%


Hope it helps :)

hirohitosan
December 13th, 2008, 12:06
Hope it helps :)

yes, it helps but unfortunately in my case:
tune2fs -l /dev/ad6s1 | grep "Inode size" Inode size: 256


at this time as my system works I'm afraid to apply Josh's patch. I never apply a patch to my kernel sources and rebuild ... it's complicated?

Djn
December 13th, 2008, 13:56
It's not too hard, really.
If you

# cd /usr/src/sys/gnu/fs
# patch < ~djn/ext2fs.diff (change to where you stored the patch, obviously)
# cd /usr/src/sys/modules/ext2fs
# make install clean

This will compile and install the patched version of the ext2fs module. If it's already loaded you need to kldunload ext2fs; kldload ext2fs, otherwise you should just be able to kldload it and try.

If you have ext2fs compiled into the kernel (options EXT2FS) you would need to cd /usr/src ; make buildkernel installkernel to compile a new kernel. I doubt you have, though - it's not the default.

hirohitosan
December 13th, 2008, 19:37
I don't have nothing in /usr/src
# ls -al /usr/src/
total 4
drwxr-xr-x 2 root wheel 512 Feb 24 2008 .
drwxr-xr-x 17 root wheel 512 Dec 9 10:02 ..

do I need something to install? the kernel sources or something like that?

gnemmi
December 14th, 2008, 23:34
You need to install the sources first ..
You can do so using "sysinstall" ...


root@inferna:~ # sysinstall


Then go to "Configure" -> "Distributions", select (at least) "base" and "kernels" or go for "All" if you want to .. then hit "OK" and that should pretty much do it :)

You should check the Handbook first though ... it's been a while since I don't use "sysinstall" so I might be wrong :s

hirohitosan
December 15th, 2008, 13:38
This will compile and install the patched version of the ext2fs module. If it's already loaded you need to kldunload ext2fs; kldload ext2fs, otherwise you should just be able to kldload it and try.

If you have ext2fs compiled into the kernel (options EXT2FS) you would need to cd /usr/src ; make buildkernel installkernel to compile a new kernel. I doubt you have, though - it's not the default.
I installed kernel sources and I downloaded ext2fs.diff and then:

# cd /usr/src/sys/gnu/fs/
# patch < ~/ext2fs.diff
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -ud ext2fs.orig/ext2_fs.h ext2fs/ext2_fs.h
|--- ext2fs.orig/ext2_fs.h 2005-06-16 06:51:38.000000000 +0000
|+++ ext2fs/ext2_fs.h 2008-09-03 14:10:27.000000000 +0000
--------------------------
Patching file ext2fs/ext2_fs.h using Plan A...
Hunk #1 succeeded at 150.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -ud ext2fs.orig/ext2_inode.c ext2fs/ext2_inode.c
|--- ext2fs.orig/ext2_inode.c 2006-09-26 04:15:58.000000000 +0000
|+++ ext2fs/ext2_inode.c 2008-09-03 13:54:49.000000000 +0000
--------------------------
Patching file ext2fs/ext2_inode.c using Plan A...
Hunk #1 succeeded at 91.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff -ud ext2fs.orig/ext2_vfsops.c ext2fs/ext2_vfsops.c
|--- ext2fs.orig/ext2_vfsops.c 2008-04-03 18:51:13.000000000 +0000
|+++ ext2fs/ext2_vfsops.c 2008-09-03 13:55:37.000000000 +0000
--------------------------
Patching file ext2fs/ext2_vfsops.c using Plan A...
Hunk #1 succeeded at 424.
Hunk #2 succeeded at 578.
Hunk #3 succeeded at 1013.
done
# cd /usr/src/sys/modules/ext2fs/
# make install clean
install -o root -g wheel -m 555 ext2fs.ko /boot/kernel
install: ext2fs.ko: No such file or directory
*** Error code 71


something is missing? what went wrong?

gnemmi
December 15th, 2008, 16:20
Try a:


root@inferna:/usr/src/sys/modules/ext2fs # make clean && make


a past the output in here.

hirohitosan
December 15th, 2008, 21:36
I didn't understand the command so I paste it like this:
# /usr/src/sys/modules/ext2fs # make clean && make
/usr/src/sys/modules/ext2fs: Permission denied.

gnemmi
December 16th, 2008, 02:24
are you doing this as root?
could you please do a "ls -a" inside that directory and paste the output in here?

lme@
December 16th, 2008, 14:48
hirohitosan, you should exec this this as root:
# cd /usr/src/sys/modules/ext2fs
# make depend
# make obj
# make
# make install
# make unload
# make load

That way you build all dependencies for the module, build the module itself, install it, unload the current loaded module and load the new one.

hirohitosan
December 16th, 2008, 15:16
hirohitosan, you should exec this this as root:
# cd /usr/src/sys/modules/ext2fs
# make depend
# make obj
# make
# make install
# make unload
# make load

That way you build all dependencies for the module, build the module itself, install it, unload the current loaded module and load the new one.

Thanks everything went well. Just # make unload
/sbin/kldunload -v ext2fs.ko
kldunload: can't find file ext2fs.ko
*** Error code 1

Stop in /usr/src/sys/modules/ext2fs.
# make load
/sbin/kldload -v /usr/obj/usr/src/sys/modules/ext2fs/ext2fs.ko
Loaded /usr/obj/usr/src/sys/modules/ext2fs/ext2fs.ko, id=4

but I suppose that ext2fs was not loaded ....

hirohitosan
December 16th, 2008, 16:04
thank you guys ... now I can mount the ext2 volume ... nice tutorial :beergrin

brd@
January 19th, 2009, 08:49
The fix for this was just checked into FreeBSD -CURRENT:

http://svn.freebsd.org/viewvc/base?view=revision&revision=187395

So it should be in 8.0 and 7.2.

mohit4u1
January 25th, 2009, 15:56
thanx dude!
i got it up and running in one night!
thanx for the patch!!

woodson2
June 8th, 2009, 16:33
The fix for this was just checked into FreeBSD -CURRENT:

http://svn.freebsd.org/viewvc/base?view=revision&revision=187395

So it should be in 8.0 and 7.2.


I recently installed 7.2 and I'm having the same issue...Did the patch make it into the 7.2 release or do I need to run the patch manually?

SirDice
June 8th, 2009, 17:19
Did the patch make it into the 7.2 release or do I need to run the patch manually?
The patch should be in 7.2-RELEASE (that was released somewhere in May).

woodson2
June 8th, 2009, 17:22
The patch should be in 7.2-RELEASE (that was released somewhere in May).


Hmm...Well any idea why I might be having the problem still?
When I run tune2fs on the filesystem it reports it as "dirty"
Do I need to e2fsck the filesystem and all will be well?

uname -a
FreeBSD BSD 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May 1 08:49:13 UTC 2009 root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386

SirDice
June 8th, 2009, 17:27
Hmm...Well any idea why I might be having the problem still?
When I run tune2fs on the filesystem it reports it as "dirty"
Hehehe... You didn't shutdown the linux system that used that drive cleanly.

Do I need to e2fsck the filesystem and all will be well?
That should work.

woodson2
June 8th, 2009, 18:06
Hehehe... You didn't shutdown the linux system that used that drive cleanly.


Well, I did shut down the Linux box gracefully....I'll e2fsck, but hopefully this won't be something I have to do everytime I place one of our old ext3 data disks into out FreeBSD box...

woodson2
June 8th, 2009, 18:41
OK..So here's what's happening after shutting down the linux box and placing the disk inside the BSD box.

tune2fs -l /dev/ad6s1
tune2fs 1.41.4 (27-Jan-2009)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: fbb12204-b8fc-4f29-aab8-d2d9dd1ccbce
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 15269888
Block count: 61049000
Reserved block count: 3052450
Free blocks: 36030598
Free inodes: 15269372
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1009
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Filesystem created: Fri May 29 10:44:59 2009
Last mount time: Mon Jun 8 09:57:59 2009
Last write time: Mon Jun 8 13:33:00 2009
Mount count: 5
Maximum mount count: 21
Last checked: Fri May 29 10:44:59 2009
Check interval: 15552000 (6 months)
Next check after: Wed Nov 25 09:44:59 2009
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group wheel)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 0904fd61-260b-467c-ae33-ba484e5d9f64
Journal backup: inode blocks


Now it says the filesystem is clean so I mount it with.

mount -t ext2fs /dev/ad6s1 /mnt

ls /mnt

ls: /mnt: Bad file descriptor


OK so we look at tune2fs again and the filesystem is "not clean" now.

tune2fs -l /dev/ad6s1
tune2fs 1.41.4 (27-Jan-2009)
Filesystem volume name: <none>
Last mounted on: <not available>
Filesystem UUID: fbb12204-b8fc-4f29-aab8-d2d9dd1ccbce
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: not clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 15269888
Block count: 61049000
Reserved block count: 3052450
Free blocks: 36030598
Free inodes: 15269372
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1009
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Filesystem created: Fri May 29 10:44:59 2009
Last mount time: Mon Jun 8 09:57:59 2009
Last write time: Mon Jun 8 13:37:47 2009
Mount count: 5
Maximum mount count: 21
Last checked: Fri May 29 10:44:59 2009
Check interval: 15552000 (6 months)
Next check after: Wed Nov 25 09:44:59 2009
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group wheel)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 0904fd61-260b-467c-ae33-ba484e5d9f64
Journal backup: inode blocks

So I umount the filesystem and run e2fsck with.

e2fsck /dev/ad6s1
e2fsck 1.41.4 (27-Jan-2009)
/dev/ad6s1: clean, 516/15269888 files, 25018402/61049000 blocks

The filesystem now reports as "clean" again....So this is just a vicious cycle which I can't break..aaaaaaaaaaahhhhhhhhhhhhhhhhhhh....Please help...Losing sanity..

woodson2
June 9th, 2009, 14:18
OK........So I've regained my composure again......I'm ready to field any suggestions....

woodson2
June 9th, 2009, 21:28
OK.....Can I bribe someone to help em out here??

adamk
June 9th, 2009, 22:10
It really sounds like you are using an older version of the driver. Do you have the source for 7.2 installed? If so, you should be able to compare the source code to the patch to see if it's included.

Adam

woodson2
June 10th, 2009, 01:28
Thanks for replying...Can you tell me how to verify if I have the source installed and if not how to install it?

tangram
June 11th, 2009, 01:42
Thanks for replying...Can you tell me how to verify if I have the source installed and if not how to install it?

Have a look at /usr/src/. It is populated then you have source code available. You'd have it available if you've select the appropriate option during FreeBSD installation, installed it afterward with sysinstal or just downloaded it with csup.

Have a look at FreeBSD's Handbook chapters 8 and 24.

woodson2
June 11th, 2009, 02:06
I was finally able to get this working after coming in contact with a saint of a man on the freebsd-fs mailing list. He stuck with me and worked on this for an entire day until we were able to resolve the issue..The problem was that after I had installed 7.2 I used cvsup to update my source files however in the file I specified *default tag=. instead of *default tag=RELENG_7_2..So I'm sure you can guess what happened next...So the patch wasn't working because the files under /usr/src/sys/gnu/fs/ext2fs/ were from the CURRENT release. That would explain the patch failing because ext2 is already fixed in the 8.0 Release.....So I was basically trying to patch an already patched ext2fs and recompile the 8.0 source files agianst the 7.2 Kernel.......Anyhow, this has been a cautionary tale for me in my new ventures into FreeBSD......

Djn
June 12th, 2009, 00:27
I was finally able to get this working after coming in contact with a saint of a man on the freebsd-fs mailing list. He stuck with me and worked on this for an entire day until we were able to resolve the issue..The problem was that after I had installed 7.2 I used cvsup to update my source files however in the file I specified *default tag=. instead of *default tag=RELENG_7_2..So I'm sure you can guess what happened next...So the patch wasn't working because the files under /usr/src/sys/gnu/fs/ext2fs/ were from the CURRENT release. That would explain the patch failing because ext2 is already fixed in the 8.0 Release.....So I was basically trying to patch an already patched ext2fs and recompile the 8.0 source files agianst the 7.2 Kernel.......Anyhow, this has been a cautionary tale for me in my new ventures into FreeBSD......

I have, on one memorable occasion, accidentally upgraded my system to -CURRENT. Always interesting.