Topic: Filesystem for Multi-OS Use

I'd like to have a single filesystem that enjoys good support from all the BSDs, OS X and Linux for my external hard drive that I use for backing up.  I'm thinking HFS+ or Ext2 (apparently supported in OS X with an third-party application).  I share my data between many computers and operating systems and am looking for a file system that is well supported on all them.  I'm leaning toward ext2 but am curious as to what board members like to use for a situation like this.

P.S: Windows support isn't necessary but would be very nice.

Thanks.

Re: Filesystem for Multi-OS Use

If you want to be sure for ALL OSes, then you will have to use (dump) FAT32 fs (pendirve for example), but EXT2 seems best alternative if you know that your OSes support it.

I also wanted use UDF for the same purpose, but its rarely implemented on most OSes.

About windows support, there are drivers for EXT2 for windows also: http://www.fs-driver.org/

"religions, worst damnation of mankind"
[color=Blue]Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for

Re: Filesystem for Multi-OS Use

UDF support is required for an OS to read data DVDs.

While data DVDs can be formatted with iso9660, they are more commonly formatted with UDF, which has far fewer restrictions (like enabling files over 2 GB) compared to iso9660.

FreeBSD, Linux, and MacOS X should all have UDF support (I know for a fact that the first two do).

Re: Filesystem for Multi-OS Use

It looks like for a USB pendrive I'm pretty much stuck with using FAT32 because I bounce around between Linux and Windows machines at school.  For my own laptop at home I'm planning on sharing a single /home partition on an external hard drive between BSD, OS X and Linux.  For that situation I think EXT2 will probably be the way to go since UDF lacks write support with the BSDs, at least according to wikipedia.

Re: Filesystem for Multi-OS Use

So I got my install on but I am having problems getting the ext2 partition up and running.  I decided my laptop had enough room on it's hard drive so I created a ext2fs partition at /dev/ad4s2.  I then installed the ext2fsprogs and used mkfs.ext2 to build a filesystem at /dev/ad4s2.  I can mount it but it says that it's not a directory.

thinkpad# mount
/dev/ad4s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad4s1e on /tmp (ufs, local, soft-updates)
/dev/ad4s1f on /usr (ufs, local, soft-updates)
/dev/ad4s1d on /var (ufs, local, soft-updates)
fdescfs on /dev/fd (fdescfs)
/dev/ad4s2 on /mnt/stuff (ext2fs, local)
thinkpad# cd /mnt/stuff
/mnt/stuff: Not a directory.

I'm still a bit unclear on BSD's whole disk slice vs partition deal.  Do I need to partition the slice with disklablel so I have a /dev/ad4s2a and then build a filesystem there?

Re: Filesystem for Multi-OS Use

kce wrote:

I'm still a bit unclear on BSD's whole disk slice vs partition deal.  Do I need to partition the slice with disklablel so I have a /dev/ad4s2a and then build a filesystem there?

slices:
1-4 primary partitions [/dev/ad0s1 - /dev/ad0s4] in MBR, or 1-3 primary partitions [/dev/ad0s1 - /dev/ad0s3] + 1 extended partition [/dev/ad0s5]+ 1-16 logical partitions in extended partition [/dev/ad0s5s1 - /dev/ad0s5s16].

Now, about partitions, only UFS filesystem supports them, so in one slice, for example /dev/ad0s1 you create partitions, /dev/ad0s1a /dev/ad0s1b /dev/ad0s1d ...

So for ext2/fat/xfs/ext3/jfs it will be only /dev/ad0s1 but /dev/ad0s1a or /dev/ad0s1d for UFS.

"religions, worst damnation of mankind"
[color=Blue]Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for

Re: Filesystem for Multi-OS Use

Sorry, I'm coming from Linux where "slices" are referred to as partitions.  I still can not seem to get my ext2 slice mounted. I used sysinstall's version of fdisk to create a 60GB slice at /dev/ad4s2.  I then used mkfs.ext2 from the ext2fsprogs port to create a filesystem there.  Next I use 'mkdir /mnt/stuff' to create a mount point and finally executed a 'mount -t ext2fs /dev/ad4s2 /mnt/stuff' as root.  If I try to cd into mnt/stuff as root I get the 'not a directory' error, as a normal user I get a 'cd: can't cd to /mnt/stuff'.  I'm pretty confused, did I miss a step somewhere?

Re: Filesystem for Multi-OS Use

Well, is /mnt/stuff a directory to begin with?

Re: Filesystem for Multi-OS Use

It should be but apparently it's not.  Check out the weirdness.

$ pwd
/usr/home/kevine
$ mkdir storage
$ ls -l
total 2
drwxr-xr-x  2 kevine  kevine  512 Aug  3 16:06 storage
$ su root
Password:
thinkpad# mount -t ext2fs /dev/ad4s2 storage/
thinkpad# mount
/dev/ad4s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad4s1e on /tmp (ufs, local, soft-updates)
/dev/ad4s1f on /usr (ufs, local, soft-updates)
/dev/ad4s1d on /var (ufs, local, soft-updates)
fdescfs on /dev/fd (fdescfs)
/dev/md0 on /tmp (ufs, local)
/dev/ad4s2 on /usr/home/kevine/storage (ext2fs, local)
thinkpad# exit
exit
$ ls
storage
$ cd storage
cd: can't cd to storage
$ ls -la
ls: storage: Bad file descriptor
total 32
drwxr-xr-x  6 kevine  kevine   512 Aug  3 16:06 .
drwxr-xr-x  3 root    wheel    512 Aug  2 11:49 ..
-rw-------  1 kevine  kevine    74 Aug  3 15:34 .Xauthority
-rw-r--r--  1 kevine  kevine   751 Aug  2 11:49 .cshrc
drwxr-xr-x  2 kevine  kevine  1024 Aug  2 19:35 .fontconfig
-rw-r--r--  1 kevine  kevine   248 Aug  2 11:49 .login
-rw-r--r--  1 kevine  kevine   158 Aug  2 11:49 .login_conf
-rw-------  1 kevine  kevine   373 Aug  2 11:49 .mail_aliases
-rw-r--r--  1 kevine  kevine   331 Aug  2 11:49 .mailrc
drwx------  3 kevine  kevine   512 Aug  2 19:35 .mozilla
-rw-r--r--  1 kevine  kevine   766 Aug  2 11:49 .profile
-rw-------  1 kevine  kevine   276 Aug  2 11:49 .rhosts
-rw-------  1 kevine  kevine    74 Aug  3 15:34 .serverauth.995
-rw-r--r--  1 kevine  kevine   975 Aug  2 11:49 .shrc
drwxr-xr-x  2 kevine  kevine   512 Aug  2 19:27 .wmii-3.5
-rw-r--r--  1 kevine  kevine    34 Aug  2 19:27 .xinitrc
$ su root
Password:
thinkpad# cd storage
storage: Not a directory.
thinkpad# ??????
??????: No match.

Do I have to do something special to create a moint point under FreeBSD?

Re: Filesystem for Multi-OS Use

What does:
# stat -x /usr/home/kevine/storage
have to say?

And what happens after you unmount /usr/home/kevine/storage?

Last edited by Carpetsmoker (2008-08-04 00:31:55)

Trust me, I know what I'm doing.

11

Re: Filesystem for Multi-OS Use

thinkpad# stat -x storage/
  File: "storage/"
  Size: 512          FileType: Directory
  Mode: (0755/drwxr-xr-x)         Uid: ( 1001/  kevine)  Gid: ( 1001/  kevine)
Device: 0,94   Inode: 635946    Links: 2
Access: Sun Aug  3 16:06:01 2008
Modify: Sun Aug  3 16:06:01 2008
Change: Sun Aug  3 16:06:01 2008
thinkpad# mount -t ext2fs /dev/ad4s2 storage/
thinkpad# stat -x storage
stat: storage: stat: Bad file descriptor
thinkpad# umount /dev/ad4s2
thinkpad# cd storage/
thinkpad# pwd
/usr/home/kevine/storage
thinkpad#

The storage directory seems to work fine when the filesystem isn't mounted.

Re: Filesystem for Multi-OS Use

What's the output of:
# fdisk /dev/ad4

Trust me, I know what I'm doing.

13

Re: Filesystem for Multi-OS Use

thinkpad# fdisk /dev/ad4
******* Working on device /dev/ad4 *******
parameters extracted from in-core disklabel are:
cylinders=193821 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=193821 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 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 52420032 (25595 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 131 (0x83),(Linux native)
    start 52420095, size 125821080 (61436 Meg), flag 0
        beg: cyl 1023/ head 255/ sector 63;
        end: cyl 1023/ head 254/ sector 63
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>

14

Re: Filesystem for Multi-OS Use

I've tried a few variations of the above listed processes with no success.  Does the kernel need a module loaded for ext2 support?

Re: Filesystem for Multi-OS Use

You may load the module manually, but it should load automatically after you spawn mount_ext2fs command.

"religions, worst damnation of mankind"
[color=Blue]Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for

16

Re: Filesystem for Multi-OS Use

I tried loading the module manually first to see if that made a difference and it doesn't.  I am at a complete loss as to why this isn't working.  Does anyone know what step I'm missing?

Re: Filesystem for Multi-OS Use

If you create the directory as a normal user, then mount it as root, you may not be able to access it as the normal user.  Depends on the permissions for the directory, and the device node.

Try the following:

as root:
# sysctl vfs.usermount=1
# chmod 666 /dev/ad4s2

*** the first will allow normal users to run mount,
*** the second will allow normal users to read/write /dev/ad4s2

as normal user:
$ mkdir ~/test
$ ls -ld ~/test

*** make sure the permissions start with drwx

$ mount -t ext2fs /dev/ad4s2 ~/test
$ mount

*** check that ad4s2 is mounted as ext2

$ cd ~/test

If the above works, then add your user to the operator group, and add entries to /etc/devfs.conf to allow operator to read/write /dev/ad4s2 (this sets the permission at boot).  Something like:

own     ad4     root:operator
own     ad4s2   root:operator
perm    ad4     0660
perm    ad4s2   0660

Last edited by phoenix (2008-08-14 01:18:01)

18

Re: Filesystem for Multi-OS Use

So here's what I got:

thinkpad# sysctl vfs.usermount=1
vfs.usermount: 1 -> 1
thinkpad# ls -la /dev/ad4s2
crw-rw-rw-  1 root  operator    0,  91 Aug 14 16:29 /dev/ad4s2

*** and now as unprivileged user ***

$ mkdir test
$ ls -ld test
drwxr-xr-x  2 kevine  kevine  512 Aug 14 16:34 test
$ mount -t ext2fs /dev/ad4s2 test
$ mount
/dev/ad4s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/ad4s1e on /tmp (ufs, local, soft-updates)
/dev/ad4s1f on /usr (ufs, local, soft-updates)
/dev/ad4s1d on /var (ufs, local, soft-updates)
procfs on /proc (procfs, local)
/dev/ad4s2 on /usr/home/kevine/test (ext2fs, local, nosuid, mounted by kevine)
$ cd ~/test
cd: can't cd to /home/kevine/test
$ umount test
umount: test: stat: Bad file descriptor
umount: test: unknown file system

Strange huh?  I think that last line is telling, is it possible that the 7.0-amd64 kernel was not built with ext2fs support.  I tried to manually load the module right after this and I got the error that file already exists, which I'm assuming means that the ext2fs module was correctly loaded.  Anyways, thanks again for everyone's help.

19

Re: Filesystem for Multi-OS Use

SUCCESS!  Sort of...

I was finally able to properly cd and use the directory after mounting /dev/ad4s2.  For whatever reason mkfs.ext2 does not by default create filesystems with the default 128 byte inodes (I'd be quite glad to learn the reason if someone knows it).  Creating the filesystem using 'mkfs.ext2 -I 128 /dev/ad4s2' allows it to be mounted and used by FreeBSD.  You (and I) can thank google and this guy (http://const-cast.blogspot.com/2008/07/ … eebsd.html).

My problem now however is maintaining user permissions on the mount point after it's mounted.  As I noted in my last post I can with vfs.usermount set to 1 mount the filesystem as a unprivileged user.  However it reverts from my unprivileged user's permissions (drwxr-xr-x kevine kevine) to privileged permissions (drwxr-xr-x root wheel).  I can use the filesystem file as root but as you'd expect not as a normal user.  What I'd like to do is have this slice mounted on boot through fstab.  In linux you could include the user option to allow that mount point to be accessible by normal users.  I understand that option doesn't exist in FreeBSD.  I checked the FAQ and it (like phoenix) recommend devfs, however I followed phoenix's steps without write success for my normal user.  I assume that devfs is the way to allow normal users access to these mount points?  I don't particularly care if they can't mount or unmount them.  I just need the mount point to be owned by 'kevine' and have rwx privileges on it.

I suppose it's time I get to reading the devfs man files, either that or I suppose I could use hald.

Anyway, once again thanks to the forums for your help.

Re: Filesystem for Multi-OS Use

If you mount the file system as "kevine", do the permissions stay the same? If so, then the pragmatic solution imo would be to just write a script and to put it into /usr/local/etc/rc.d; it would contain something like su kevine -c /sbin/mount -t ext2fs /dev/ad4s2 /home/kevine/mnt.

An alternative solution would be to take advantage of the "suiddir" mount option.

Re: Filesystem for Multi-OS Use

I listed the correct entries for /etc/devfs.conf that will set the correct permissions on the device nodes at boot.  To have it take effect without rebooting, run /etc/rc.d/devfs restart

22

Re: Filesystem for Multi-OS Use

** in /etc/devfs.conf

# Allow members of the operator group to mount and write /dev/ad4s2
own     ad4     root:operator
own     ad4s2   root:operator
perm    ad4     0660
perm    ad4s2   0660

**  after a reboot

$ sysctl vfs.usermount && ls -la /dev/ad4s2
vfs.usermount: 1
crw-rw----  1 root  operator    0,  91 Aug 20 15:16 /dev/ad4s2


** as a normal user

drwxr-xr-x   2 kevine  kevine       512 Aug 20 14:56 storage

$ mount -t ext2fs /dev/ad4s2 storage
mount: /dev/ad4s2 : Operation not supported by device

Which is strange considering that kevine is part of the operator group.  My guess is that just having rw privileges on a device isn't sufficient for that user to mount it.  As root, there's no problem mounting the device and reading/writing to it.

I apologize for my abject lack of knowledge about what devices actually are and how their permissions are handled.  I'm coming from linux-land, where this is all covered up with things like HAL.

Thanks again for everyone's help.

Re: Filesystem for Multi-OS Use

The problem with Linux-land is that everything is covered up with hacks, band-aids, temp workarounds, and whatnot, all layered one upon the other in userland.  smile  There's udev, hal, and something else that are supposed to all "work together" to make managing devices "automatic".  Some things read device info from /proc, some from /sys, others from /dev.  But it doesn't always work, all the configs are written in XML, it's not manageable by non-programmers, and no one is really sure just what is happening.

FreeBSD has a nice, integrated, manageable, understandable setup:
*kernel detects hardware
*kernel attaches driver(s)
*kernel signals devd
*devd creates device nodes in /dev
*userland is notified and device becomes usable right away

The config file (/etc/devd.conf /etc/devfs.rules) are simple text files, easy to read, easy to understand, easy to edit.  And everything just works.  smile

Sorry, I just really, really, really dislike device management on Linux.  It's all very hokey to me, hacked-together, and unusable to me.

Back to your problem:  What are the permissions on /dev/ad4, and are there any errors shown in dmesg output?

Last edited by phoenix (2008-08-21 20:11:39)

24

Re: Filesystem for Multi-OS Use

Permissions on /dev/ad4s2 are "crw-rw----  1 root  operator" and I can't find any relevant errors in either dmesg or /var/log/messages.

25

Re: Filesystem for Multi-OS Use

I'm going to just give up on this project and certainly not for lack of help or involvement from the forums.  I was able to get the ext2fs created and mounted with root permissions so I started transferring my files to it from my external hard drive.  This lead to numerous hard-locks.  Even transferring all my .* files from my temporary home directory lead to a hard lock eventually.  Either FreeBSD's support for ext2fs write is buggy, the file system itself is poorly implemented or some combination of both.  Regardless, that's a level of unreliability that I have no interest in trusting my files to so I can say with reluctance that the "shared-FreeBSD-and-Linux-home-partition" dream is dead... I just don't see how it's possible (even with my technical ability aside) to accomplish this with any sense of file stability.  I think ext2 read/write support might work in a pinch but I would highly caution anyone from relying on it.

At this point I have enough time and effort into this install that I'm not quite ready to give up the ghost and go back to the dreaded Ubuntu.  My current slice/partition scheme looks like this:

/dev/ad4s1   - FreeBSD  -  25GB
/dev/ad4s2   - Linux - 60GB

I'd like to 1) merge the two slices together since ad4s1 is already partitioned out and full and then 2) create a home partition out of the new space.  As far as I can tell merging partitions (/dev/ad4s1a...) is possible but I couldn't find anything about slices on google.

Anyways, another thank you for everyone's help.  I have no sensitive data on this machine so at worst I'll just do a reinstall.