File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_mount_ffs_partition_under_linux.mdwn
Revision 1.3: download - view: text, annotated - select for diffs
Mon Apr 8 21:20:09 2019 UTC (14 months, 4 weeks ago) by sevan
Branches: MAIN
CVS tags: HEAD
markup

    1: **Contents**
    2: 
    3: [[!toc]]
    4: 
    5: #  Verify UFS support 
    6: 
    7: To check whether your Linux kernel supports the [UFS filesystem](http://en.wikipedia.org/wiki/Unix_File_System) you may execute the following command: 
    8:     
    9: 
   10: $ cat /proc/filesystems
   11:     nodev   sysfs
   12:     nodev   rootfs
   13:     nodev   proc
   14:             .
   15:             .
   16:             .
   17:             ext3
   18:     nodev   usbfs
   19:             vfat
   20:             **ufs**
   21:     
   22: 
   23: 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](http://en.wikipedia.org/wiki/Virtual_file_system). The support is either compiled inside the kernel or as a module: 
   24: 
   25: $ ls -l /lib/modules/2.6.21-ARCH/kernel/fs/ufs/ufs.ko 
   26:     -rw-r--r-- 1 root root 84828 2007-05-25 20:11 /lib/modules/2.6.21-ARCH/kernel/fs/ufs/ufs.ko
   27:     
   28: 
   29: #  Mount 
   30: 
   31: In order to find the device that corresponds to your FFS partition, run: 
   32: 
   33:   1. sfdisk -l 
   34: <pre><code>    
   35: Disk /dev/hda: 155061 cylinders, 16 heads, 63 sectors/track
   36: Warning: extended partition does not start at a cylinder boundary.
   37: DOS and Linux will interpret the contents differently.
   38: Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0
   39:   Device Boot Start     End   #cyls    #blocks   Id  System
   40: /dev/hda1   *      0+  34536-  34537-  17406396    7  HPFS/NTFS
   41: 			   end: (c,h,s) expected (1023,15,63) found (1023,254,63)
   42: /dev/hda2      34536+ 134767- 100231-  50516392+   f  W95 Ext'd (LBA)
   43: 			   start: (c,h,s) expected (1023,15,63) found (1023,255,63)
   44: 			   end: (c,h,s) expected (1023,15,63) found (1023,254,63)
   45: /dev/hda3     134767+ 144935-  10169-   5124735   a5  FreeBSD
   46: 			   start: (c,h,s) expected (1023,15,63) found (1023,255,63)
   47: 			   end: (c,h,s) expected (1023,15,63) found (1023,254,63)
   48: /dev/hda4     144935+ 155060   10126-   5103189   a9  NetBSD
   49: 			   start: (c,h,s) expected (1023,15,63) found (1023,255,63)
   50: 			   end: (c,h,s) expected (1023,15,63) found (1023,80,63)
   51: /dev/hda5      34536+ 102366-  67830-  34186288+  83  Linux
   52: 			   start: (c,h,s) expected (1023,15,63) found (0,1,1)
   53: 			   end: (c,h,s) expected (1023,15,63) found (1023,254,63)
   54: /dev/hda6     102366+ 104294    1929-    971901   82  Linux swap / Solaris
   55: 			   start: (c,h,s) expected (1023,15,63) found (0,1,1)
   56: 			   end: (c,h,s) expected (1023,15,63) found (120,254,63)
   57: /dev/hda7     104295+ 134767-  30473-  15358108+  83  Linux
   58: 			   start: (c,h,s) expected (1023,15,63) found (0,1,1)
   59: 			   end: (c,h,s) expected (1023,15,63) found (1023,254,63)
   60: /dev/hda8     134767+ 143910-   9143-   4608000
   61: /dev/hda9     143910+ 144935-   1026-    516735
   62: /dev/hda10    144935+ 154078-   9143    4608072
   63: /dev/hda11    154078+ 155060     983-    495117
   64: /dev/hda12         0+  34536-  34537-  17406396
   65: /dev/hda13     34536+ 102366-  67830-  34186288+
   66: /dev/hda14    102366+ 104294    1929-    971901
   67: /dev/hda15    104295+ 144935-  40641-  20482843+
   68: </code></pre>    
   69: 
   70: So for FreeBSD (FFSv2), we have `/dev/hda3` which is equivalent to `/dev/ad0s3` 
   71: 
   72: And for NetBSD (FFSv1), we have `/dev/hda4` which is equivalent to `/dev/wd0c`
   73: 
   74: But these devices are whole BSD slices (BIOS partitions), not BSD partitions. 
   75: 
   76: 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) 
   77: 
   78: 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) 
   79: 
   80: And for NetBSD: `/dev/hda10` is equivalent to `/dev/wd0a` (NetBSD root partition) `/dev/hda11` is equivalent to `/dev/wd0b` (NetBSD swap) 
   81: 
   82: Thus FreeBSD root partition lies at /dev/hda8. First create a directory to mount FFS partition and then mount it: 
   83:     
   84:     # mkdir /mnt/freebsd
   85:     # mount -t ufs -o ro,ufstype=ufs2 /dev/hda8 /mnt/freebsd/
   86:     
   87: 
   88: And NetBSD root partition lies at `/dev/hda10`. First create a directory to mount FFS partition and then mount it: 
   89:     
   90:     # mkdir /mnt/netbsd
   91:     # mount -t ufs -o ro,ufstype=44bsd /dev/hda10 /mnt/netbsd/
   92:     
   93: 
   94: Let's browse it: 
   95:     
   96:     # ls /mnt/*bsd
   97:     /mnt/freebsd:
   98:     bin   cdrom   COPYRIGHT  dist     etc   lib      media  proc    root  sys  usr
   99:     boot  compat  dev        entropy  home  libexec  mnt    rescue  sbin  tmp  var
  100:     /mnt/netbsd:
  101:     altroot  etc                 gnome-screensave.core  mnt      root   var
  102:     bin      GENERIC             kern                   netbsd   sbin
  103:     boot     GENERIC-DIAGNOSTIC  lib                    onetbsd  stand
  104:     CUSTOM   GENERIC-LAPTOP      libdata                proc     tmp
  105:     dev      GENERIC-NOACPI      libexec                rescue   usr
  106:     
  107: 
  108: #  Edit /etc/fstab 
  109: 
  110: Add the following line to your `/etc/fstab` file: 
  111:     
  112:     /dev/hda8       /mnt/freebsd     ufs     ufstype=ufs2,ro        0       2
  113:     /dev/hda10      /mnt/netbsd      ufs     ufstype=44bsd,ro       0       2
  114:     
  115: 
  116: Now you can mount the FFS partitions by typing: 
  117:     
  118:     # mount /mnt/freebsd
  119:     # mount /mnt/netbsd
  120:     
  121: 
  122: and verify with: 
  123:     
  124:     $ mount
  125:     [...]
  126:     /dev/hda8 on /mnt/freebsd type ufs (ro,ufstype=ufs2)
  127:     /dev/hda10 on /mnt/netbsd type ufs (ro,ufstype=44bsd)
  128:     [...]
  129:     
  130: 
  131: #  Write support 
  132: 
  133: 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) 
  134: 
  135: 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. 
  136: 
  137: #  Remarks 
  138: 
  139:   * If you forget the `ro` option, you will get the following message at dmesg: 
  140:     
  141:     $ dmesg | grep ufs
  142:     ufs was compiled with read-only support, can't be mounted as read-write
  143:     
  144: 
  145:   * If you forget to set the `ufstype` option, you will get the following message at dmesg: 
  146:     
  147:     $ dmesg | grep ufstype
  148:     mount -t ufs -o ufstype=sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...
  149:     >>>WARNING<<< Wrong ufstype may corrupt your filesystem, default is ufstype=old
  150:     
  151: 
  152: So, extra care should be taken. 
  153: 
  154: People have reported crashes using FFS partitions access under GNU/Linux (even in read-only mode, that is very strange). I am half convinced that has been caused by accessing a whole BSD slice (BSD dedicated BIOS partition) instead of a BSD partition. 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb