Subject: For the FAQ: Making a new ext2fs filesystem on NetBSD-Cobalt
To: NetBSD-Cobalt <port-cobalt@netbsd.org>
From: None <rthille@gte.net>
List: port-cobalt
Date: 05/22/2001 22:36:38
 I found the e2fsprogs package (e2fsprogs-1.19.tar.gz) for linux and
built it (with one change, it was looking for the 'umount' system call,
and I had to change it to 'unmount' in journal.c).


If mke2fs runs pretty much without error, but it warns at the end about
not being able to write 'superblocks.done', that means that your
disklabel isn't setup quite right... 

<nofill>
Here's an unsuccessful run:

bsdqube# /usr/local/sbin/mke2fs -L "Linux Root" -v /dev/wd0e
mke2fs 1.19, 13-Jul-2000 for EXT2 FS 0.5b, 95/08/09
Filesystem label=Linux Root
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
16384 inodes, 65519 blocks
3275 blocks (5.00%) reserved for the super user
First data block=1
8 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
        8193, 24577, 40961, 57345

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: 
Warning, had trouble writing out superblocks.done
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The disk would mount, but the filesystem was bad:

bsdqube# mount_ext2fs /dev/wd0e /mnt
bsdqube# cd mnt
mnt: Not a directory.
bsdqube# cd /mnt
/mnt: Not a directory.

fsck_ext2fs would also complain:

bsdqube# fsck_ext2fs /dev/wd0e
** /dev/rwd0e
** Phase 1 - Check Blocks and Sizes

CANNOT READ: BLK 131084
CONTINUE? [yn] y
</nofill>

Note that the block it cannot read should be outside of the filesystem,
but fsck_ext2fs is still trying to read it, and if you answer 'y' to it's
questions, you'll see it continues to attempt to read blocks outside of
the filesystem.

<nofill>
Here's the disklabel that resulted in that error:

5 partitions:
#        size   offset     fstype   [fsize bsize   cpg]
  a: 33306730   394128     4.2BSD     1024  8192    16   # (Cyl.  391 - 33433*)
  b:   263088   131040       swap                        # (Cyl.  130 - 390)
  c: 33700864        0     unused        0     0         # (Cyl.    0 - 33433*)
  e:   131039        1 Linux Ext2        0     0         # (Cyl.    0*- 129)
</nofill>

Note that there is no partition 'd' (which corresponds to the whole disk
under NetBSD), and that partition 'c' is the size of the whole disk.  I
now believe that partition 'c' should just match the 'a' partition (the
only 4.2BSD partition), and/or partition 'd' must be present (not sure
which, since I changed both at the same time and it started working after
that.

<nofill>
Here's the new, _working_ disklabel:

5 partitions:
#        size   offset     fstype   [fsize bsize   cpg]
  a: 33306730   394128     4.2BSD     1024  8192    16   # (Cyl.  391 - 33433*)
  b:   263088   131040       swap                        # (Cyl.  130 - 390)
  c: 33306730   394128     unused        0     0         # (Cyl.  391 - 33433*)
  d: 33700864        0     unused        0     0         # (Cyl.    0 - 33433*)
  e:   131039        1 Linux Ext2        0     0         # (Cyl.    0*- 129)
  
The successful run of mke2fs:

bsdqube# /usr/local/sbin/mke2fs -L "linux boot" -v /dev/wd0e
mke2fs 1.19, 13-Jul-2000 for EXT2 FS 0.5b, 95/08/09
Filesystem label=linux boot
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
16384 inodes, 65519 blocks
3275 blocks (5.00%) reserved for the super user
First data block=1
8 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
        8193, 24577, 40961, 57345

Writing inode tables: done                            
Writing superblocks and filesystem accounting information: done
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A successful fsck_ext2fs:

bsdqube#  fsck_ext2fs /dev/wd0e
** /dev/rwd0e
** File system is clean; not checking

And a successful mount and cd into the directory:

bsdqube# mount -t ext2fs /dev/wd0e /mnt 
bsdqube# cd /mnt


Robert

--
Robert Thille  N-34*26.064' W-119*48.352' Santa Barbara CA 93111-2533
rthille@earthling.net     http://home1.gte.net/rthille/HomePage.htmld
Cyclist, Mtn. Biker, Diver, Kayaker, Climber, Hiker, Programmer, Geek
</nofill>