# Solved: Mount a ext2fs(linux) in freebsd...



## Gibble (Oct 10, 2001)

I had a slackware machine crash, and refuse to boot. But I need information of that harddrive. I've got a freebsd box that I'm trying to mount the drive in...with little success.


```
[[email protected]:~] #  mount_ext2fs /dev/ad1s1a /old-drive
mount_ext2fs: /dev/ad1s1a: Invalid argument
```
What do I need to do to mount this drive?


----------



## gotrootdude (Feb 19, 2003)

I see nothing wrong with your syntax.
Do you have the option for ext2fs compiled in your kernal? Does the old_drive directory exist? Why not place the mount point in the mnt directory?


----------



## Gibble (Oct 10, 2001)

gotrootdude said:


> I see nothing wrong with your syntax.
> Do you have the option for ext2fs compiled in your kernal?


I did that yesterday...or so I thought...

is there a way to check to make sure it did compile into the kernel?


----------



## gotrootdude (Feb 19, 2003)

Check the kernal configuration file for 

options "EXT2FS"


Also your mount point has to be created in an existing directory.


----------



## Gibble (Oct 10, 2001)

Well, I checked the kernel config, and it was there, but I wanted to add a couple options for my firewall, so I'm recompiling it again now.

And yes, the mounting directory DOES exist.


----------



## gotrootdude (Feb 19, 2003)

You could try editing the fstab and adding 
/dev/ad1s1a /old-drive auto rw,noauto,user,exec,sync 0 0


----------



## Gibble (Oct 10, 2001)

how would that be any different than just using mount?


----------



## gotrootdude (Feb 19, 2003)

When you use the mount command your getting default options, by specifying the options in fstab your 1st: allowing autodetection of the filesystem, 2: getting past the default nouser option allowing a standard user to mount the drive. 3: getting past the async default when mounting.

I figured the auto option may help if there's a question of the filesystem on the disk.


----------



## gotrootdude (Feb 19, 2003)

BRB smoke break.


----------



## Gibble (Oct 10, 2001)

Tried it, still a no go...


----------



## gotrootdude (Feb 19, 2003)

Other people are having the same problem with mounting ext2fs partitions in freebsd. Seems it's not able to mount the filesystem in rw mode, only read only mode. Check this thread out.. http://www.linuxquestions.org/questions/archive/17/2004/02/2/39660


----------



## Gibble (Oct 10, 2001)

I actually attempted it with ro, not rw...as I only need to read some data from it.


----------



## Gibble (Oct 10, 2001)

I've made a little inroads...
I tried several of the slices(?) and 'mount -t ext2fs /dev/ad1s*3* /old-drive' mounted successfully...but while it appears to contain the entire file system

```
[[email protected]:/old-drive] # ls
bin             command         fat-c           lib             opt             root            usr
boot            dev             home            lost+found      package         sbin            var
cdrom           etc             install         mnt             proc            service         vmlinuz
```
Only some of the dirs contain data...

Is there a way to find out what the other slices (is that what the s stands for?) should be mounted as? I currently have no clue


----------



## Gibble (Oct 10, 2001)

oh, wait, with that bit mounted I can read the old fstab 


```
/dev/hda1       swap        swap        defaults   0   0
/dev/hda3       /        ext2        defaults   1   1
/dev/hda5       /usr      ext2        defaults   1   1
/dev/hda6       /usr/local      ext2        defaults   1   1
/dev/hda7       /opt      ext2        defaults   1   1
/dev/hda8       /var      ext2        defaults   1   1
/dev/hda9       /home      ext2        defaults   1   1
```
This should be helpful  I just need to figure out how those match up with these...


```
[[email protected]:/old-drive] # ls /dev/ad1*
/dev/ad1        /dev/ad1c       /dev/ad1f       /dev/ad1s1      /dev/ad1s1c     /dev/ad1s1f     /dev/ad1s2
/dev/ad1a       /dev/ad1d       /dev/ad1g       /dev/ad1s1a     /dev/ad1s1d     /dev/ad1s1g     /dev/ad1s3
/dev/ad1b       /dev/ad1e       /dev/ad1h       /dev/ad1s1b     /dev/ad1s1e     /dev/ad1s1h     /dev/ad1s4
```


----------



## gotrootdude (Feb 19, 2003)

Can you try configuring the disk in bios as PIO mode? One person on that link I gave you said he finally got the disk mounted useing PIO.


----------



## Gibble (Oct 10, 2001)

I tried mounting everything...the only one that would mount is ad1s3...


----------



## gotrootdude (Feb 19, 2003)

Try useing mount -t ext2 /dev/ad1s1a /old-drive

does that still give an invalid argument?

Is the directory old_drive chmod 777? 

I'm kinda grasping at straws with this one..


----------



## Gibble (Oct 10, 2001)

I made it 777...it was 755 before.

[[email protected]:/mnt] # mount -t ext2 /dev/ad1s1a /mnt/olddrive
mount: exec mount_ext2 not found in /sbin, /usr/sbin: No such file or directory
[[email protected]:/mnt] # mount -t ext2fs /dev/ad1s1a /mnt/olddrive
ext2fs: /dev/ad1s1a: Invalid argument


----------



## gotrootdude (Feb 19, 2003)

Digging a little deeper on the read only support stuff, I found this page. Could be helpful, don't really know.. If anything it may add BSD/linux ext2fs compatability. http://www.onlamp.com/pub/a/bsd/2000/11/16/Big_Scary_Daemons.html


----------



## Gibble (Oct 10, 2001)

Part of the problem is, I can't boot this drive as a linux drive anymore...I don't know why...it just won't.


----------



## gotrootdude (Feb 19, 2003)

Sure you got the right partition and logical slice? Do you know anyone with linux installed who might be able to mount it on thier machine?


----------



## gotrootdude (Feb 19, 2003)

If you have a windoz machine, you might try accessing it with Paragon ext2fs anywhere. It's available as a free trial. At least to save the files off the drive. http://www.partition-manager.com/n_ext2fs_main.htm


----------



## Gibble (Oct 10, 2001)

gotrootdude said:


> Sure you got the right partition and logical slice? Do you know anyone with linux installed who might be able to mount it on thier machine?


well, i tried every partition and slice, the only one that would mount was the ad1s3 slice...but it doesn't contain all the data, actually it contains none of the areas I need (usr, and home)



I could try this in my windows machine...but I can't do that until tomorrow evening.


----------



## Gibble (Oct 10, 2001)

Does this look right?

```
ls -l /dev/ad1*
crw-r-----  2 root  operator  116, 0x0001000a May 25  2004 /dev/ad1
crw-r-----  2 root  operator  116,   8 May 25  2004 /dev/ad1a
crw-r-----  2 root  operator  116,   9 May 25  2004 /dev/ad1b
crw-r-----  2 root  operator  116,  10 May 25  2004 /dev/ad1c
crw-r-----  2 root  operator  116,  11 May 25  2004 /dev/ad1d
crw-r-----  2 root  operator  116,  12 May 25  2004 /dev/ad1e
crw-r-----  2 root  operator  116,  13 May 25  2004 /dev/ad1f
crw-r-----  2 root  operator  116,  14 May 25  2004 /dev/ad1g
crw-r-----  2 root  operator  116,  15 May 25  2004 /dev/ad1h
crw-r-----  2 root  operator  116, 0x0002000a May 25  2004 /dev/ad1s1
crw-r-----  2 root  operator  116, 0x00020008 May 25  2004 /dev/ad1s1a
crw-r-----  2 root  operator  116, 0x00020009 May 25  2004 /dev/ad1s1b
crw-r-----  2 root  operator  116, 0x0002000a May 25  2004 /dev/ad1s1c
crw-r-----  2 root  operator  116, 0x0002000b May 25  2004 /dev/ad1s1d
crw-r-----  2 root  operator  116, 0x0002000c May 25  2004 /dev/ad1s1e
crw-r-----  2 root  operator  116, 0x0002000d May 25  2004 /dev/ad1s1f
crw-r-----  2 root  operator  116, 0x0002000e May 25  2004 /dev/ad1s1g
crw-r-----  2 root  operator  116, 0x0002000f May 25  2004 /dev/ad1s1h
crw-r-----  2 root  operator  116, 0x0003000a May 25  2004 /dev/ad1s2
crw-r-----  2 root  operator  116, 0x0004000a May 25  2004 /dev/ad1s3
crw-r-----  2 root  operator  116, 0x0005000a May 25  2004 /dev/ad1s4
```


----------



## Gibble (Oct 10, 2001)

I ask, because if ad1 has three slices

```
[[email protected]:/mnt] # fdisk -s ad1
/dev/ad1: 5005 cyl 255 hd 63 sec
Part        Start        Size Type Flags
   1:          63      273042 0x82 0x00
   2:      787185    79618140 0x0f 0x00
   3:      273168      514017 0x83 0x80
```
Am I missing some devices like ad1s3a...ad1s3h?


----------



## Gibble (Oct 10, 2001)

Gibble said:


> I ask, because if ad1 has three slices
> 
> ```
> [[email protected]:/mnt] # fdisk -s ad1
> ...


Ok, I am pretty sure I"m missing these devices...I know I can use mknod to make them...the problem is...hwo do I know the bitmask to use?
http://www.freebsddiary.org/mknod.php


----------



## Gibble (Oct 10, 2001)

Ok, I went into /dev and used ./MAKEDEV ad1s3

That gave me the /dev/ad1s3a-h that I wanted...but only /dev/ad1s3c was mountable...and it didn't contain the home or usr contents...it was the same as what I had when I mounted /dev/ad1s3 

I had two drives in this machine, and I thought the linux install was contained to this drive, but I'm beginning to think otherwise...I'm going to check the other drive later.

I'm going to be really mad at myself if I can't find the home directory...I can do without the usr dir...but without the home dir I lose alot of stuff forever... 

I need to get a backup server built so a future problem isn't this troublesome.


----------



## gotrootdude (Feb 19, 2003)

Sorry, I was away for a bit.. Anyway, I'm glad you had a little success, and I hope you manage to find your home directory. 

Sorry I couldn't be more help, but I was grasping at staws from the beginning.


----------



## Gibble (Oct 10, 2001)

So do I...I wish there was a way to see what should be in these partitions without mounting them...I have no clue where anything is


----------



## Gibble (Oct 10, 2001)

What's confusing is, according to the fstab from the bit of the drive I could read...these should exist on this drive...shouldn't they?

/dev/hda1 swap swap defaults 0 0
*/dev/hda3 / ext2 defaults 1 1* Actually Mounted
/dev/hda5 /usr ext2 defaults 1 1
/dev/hda6 /usr/local ext2 defaults 1 1
/dev/hda7 /opt ext2 defaults 1 1
/dev/hda8 /var ext2 defaults 1 1
/dev/hda9 /home ext2 defaults 1 1
/dev/hdb1 /fat-c vfat defaults 1 0

I thought hda was one drive, hdb another, etc, etc...so shouldn't usr, opt, var and home all be on this disk?


----------



## Gibble (Oct 10, 2001)

I *may* be seeing part of the problem...if I run an fdisk on the drive ad1 I get the following:

```
[[email protected]:/mnt/olddrive/usr] # fdisk ad1
******* Working on device /dev/ad1 *******
parameters extracted from in-core disklabel are:
cylinders=5005 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=5005 heads=255 sectors/track=63 (16065 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 130,(Linux swap or Solaris x86)
    start 63, size 273042 (133 Meg), flag 0
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 16/ head 254/ sector 63
The data for partition 2 is:
sysid 15,(Extended DOS, LBA)
    start 787185, size 79618140 (38876 Meg), flag 0
        beg: cyl 49/ head 0/ sector 1;
        end: cyl 1023/ head 254/ sector 63
The data for partition 3 is:
sysid 131,(Linux filesystem)
    start 273168, size 514017 (250 Meg), flag 80 (active)
        beg: cyl 17/ head 1/ sector 1;
        end: cyl 48/ head 254/ sector 63
The data for partition 4 is:
<UNUSED>
```
Compared to my fstab...it makes sense.

Partition 1 is linux Swap...my fstab hda1 is swap.
Partition 2 is Extended DOS, LBA...it's not in my fstab.
Partition 3 is Linux filesystem...my fstab hda3 is / and I can mount this.
Partition 4 is UNUSED...it's not in my fstab.

So where are the rest of the partitions, 5 through 9, which would contain the rest of my data?


----------



## Gibble (Oct 10, 2001)

Hmm...according to dmesg, the magic number is wrong...

[[email protected]:/mnt/olddrive/usr] # dmesg
Copyright (c) 1992-2004 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD 4.10-RELEASE #1: Sun Jan 30 18:01:28 CST 2005
...
...
...
ad0: 152627MB <WDC WD1600JB-00GVA0> [310101/16/63] at ata0-master UDMA66
ad1: 39266MB <IC35L040AVER07-0> [79780/16/63] at ata0-slave UDMA66
acd0: CDROM <FX4824T> at ata1-master PIO4
Mounting root from ufs:/dev/ad0s1a
ext2fs: #ad/0x2000a: wrong magic number 0 (expected 0xef53)
ext2fs: #ad/0x3000a: wrong magic number 0x1e64 (expected 0xef53)
ext2fs: #ad/0x3000a: wrong magic number 0x1e64 (expected 0xef53)
ext2fs: ad1: wrong magic number 0 (expected 0xef53)
ext2fs: #ad/0x2000a: wrong magic number 0 (expected 0xef53)
ext2fs: #ad/0x2000a: wrong magic number 0 (expected 0xef53)
ext2fs: ad1: wrong magic number 0 (expected 0xef53)
ext2fs: #ad/0x20002: wrong magic number 0x8b6 (expected 0xef53)
ext2fs: #ad/0x3000a: wrong magic number 0x1e64 (expected 0xef53)
ext2fs: #ad/0x2000a: wrong magic number 0 (expected 0xef53)
ext2fs: #ad/0x3000a: wrong magic number 0x1e64 (expected 0xef53)


----------



## Gibble (Oct 10, 2001)

EUREKA!!!

The extended partitions were 
/dev/ad1s5-9
But I had to use MAKEDEV ad1s5-9 to make them available. Then I could easily mount them  

Finally. Thanks for the help guys.


----------

