Mounting Minix Partitions from Linux

rev 3 May 1999


From the Minix-L archives:

Date:         Mon, 11 May 1998 21:32:44 GMT
Sender:       Minix operating system <MINIX-L@LISTSERV.NODAK.EDU>
From:         Al Woodhull <awoodhull@hampshire.edu>
Subject:      Re: Mounting minix partition from linux

On 11 May 1998 16:57:31 GMT Alister Whitford (linc0228@sable.ox.ac.uk) wrote in comp.os.minix:

: I've recently installed RHS Linux 5 on my second hard drive, and I'd quite : like to be able to see my minix partition (the first partition on my first : hard drive) from linux. This is what happens:

: lester# mount -t minix /dev/hda1 /mnt/minix : VFS: Can't find a minix or minix V2 filesystem on dev 03:01. : mount: wrong fs type, bad option, bad superblock on /dev/hda1, : or too many mounted file systems

If you installed Minix in the standard way, Minix will have subpartitioned the first partition into hd1a, hd1b, and hd1c (Minix notation). Linux can't handle this, it has its own incompatible way of subdividing a primary partition.

The Linux loop device can be used to handle this -- it makes a file look like a filesystem, and the file can be defined as a byte offset from the beginning of a primary partition. An example of how to do this was described by Terry McConnell in this newsgroup back in December. I thought I had posted this on my Minix hints page, but I think perhaps I didn't. Terry's article includes a script.

Following is my own adaptation of this script, incorporating Terry's explanation as comments. It includes two sets of examples, Terry's are commented out and my own are the active ones. The calculation of the offset for my system is slightly more complicated than Terry's example because my Minix partition has an alternate root subpartition, hd4b, that is not used but whose size must be accounted for in determining the offset to the usr subpartition, hd4c.

Al +----------------------------------+ | Albert S. Woodhull | | Hampshire College, Amherst, MA | | awoodhull@hampshire.edu | | http://minix1.hampshire.edu/asw/ | +----------------------------------+ ------------------------------- cut here --------------------------------- #!/bin/sh # mxmount (for carrot.hampshire.edu) # asw 21.12.97

# From mcconnel@HYDRA.SYR.EDU Tue Dec 16 23:36:34 1997 # Date: Sun, 16 Nov 1997 15:23:31 GMT # From: "Terry R. McConnell" <mcconnel@HYDRA.SYR.EDU> # To: MINIX-L@LISTSERV.NODAK.EDU # Subject: Re: Mount a 2-level Minix partition in Linux # # In article <346EBF9C.6A8776A8@cadence.com>, # Yuray Li <yuray@cadence.com> wrote: # >Hi, # > # > I tried to mount a Minix partition(/dev/hda2 in Linux, # >/dev/hd2 in Minix) as a Minix file system in Linux with command, # > # >mount -t minix /dev/hda2 /mnt # > # >but failed. My Minix is installed from Tanenbaum's 1997 book CD. # > # > Then I investigated how Minix file system is installed. I # >found that the Minix primary partition(/dev/hd2) consists of 2 # >subpartitions(/dev/hd2a and /dev/hd2c) which are separately mounted as # >/ and /usr. I guess that Linux mount cannot resolve such partition # >organization. # > # # # Well, yes and no. There was a discussion on this topic a while ago in this # newsgroup. You can set things up so linux can "see" minix logical partitions # by treating the entire minix partition as a file and mounting it on the # loop device. A loop device is a driver that allows the linux kernel to treat # a file as a filessytem -- quite handy in certain situations. Support for # the loop device must be selected during make config. It has been available # since 2.0.0. # # The following is a shell script I use to make my minix filesystem with # its two logical subpartitions available from minix. (I also have two # other minix partitions which are not sub-partitioned.) It gives the main # idea-- you will need to adapt it for your own situation of course: # # (Terry's original script begins here) # # Mounts minix directorys so that they can be accessed from linux # Based on tips from Alan M. Alpert as posted on comp.os.minix # (More on loopback under linux)

# setup loop back devices. I guess the 512 offset in the first one # gets us past the boot sector. This is for the first (minix) logical # partition in /dev/hda3 ( = minix's /dev/hd3a ). The second one is # for the second logical partition in /dev/hda3 which begins at 512 + # 1440 x 1024 = 1475072 -- since there are 1440 blocks in the first # logical partition.

# Terry's example: # /sbin/losetup /dev/loop0 /dev/hda3 -o 512 # /sbin/losetup /dev/loop1 /dev/hda3 -o 1475072

# asw system: minix root is hd4a at offset 512 # usr is hd4c at 512 + 2x1024x1440=2949632. The "2x" is needed # because there are two 1440 block subpartitions before the usr partition /sbin/losetup /dev/loop0 /dev/hda4 -o 512 /sbin/losetup /dev/loop1 /dev/hda4 -o 2949632

# mount the minix root fs on /minix /bin/mount -t minix /dev/loop0 /minix

# mount the minix usr fs on /minix/usr /bin/mount -t minix /dev/loop1 /minix/usr

# remind the usr about what is going on here. cat <<END The entire Minix tree has been mounted on /minix and should appear from there just as if booted from minix (except there is no ramdrive mounted on /tmp. )

Minix device Linux device Mounted on: /dev/hd4a /dev/loop0 /minix /dev/hd4c /dev/loop1 /minix/usr

Note that both minix logical partitions live in the linux device /dev/hda4 -- the first at offset 512 and the second at offset 2949632.

END

# display statistics. The statistics for the smaller device will look # strange, but it seems to work OK. df /dev/loop0 df /dev/loop1

exit 0


Go to the Minix1.hampshire.edu home page.