magic mismatch when creating ext2 filesystem on a ram disk
Brought to you by:
tytso
e2fsprogs-1.40
The ram disk is set to 100mb, so that's not it.
I used the command:
/sbin/mke2fs -m 0 -i 1024 -q /dev/ram1
The -i size is 1024 like it should be.
The problem can be fixed by reverting back to mk2fs from e2fsprogs-1.39.
If you need any more info let me know.
Patrick Verner
exodusrobot@yahoo.com
www.partedmagic.com
Logged In: NO
This works just fine for me. What does "mke2fs -V" report? Did you remember to install the 1.40 shared libraries? It shouldn't have made a difference, but that's the only thing I can think of.
How did you compile e2fsprogs 1.40?
Logged In: YES
user_id=1408711
Originator: YES
I did create a work-a-round a few hours ago and the livecd creates the ram disk correctly now. I took the mke2fs from 1.39 and put it in /sbin/mke2fs_fix/mke2fs and called it from there to make the ram disk. I left the mke2fs from 1.40 in /sbin. On the livecd both use library version 1.40.
/sbin/mke2fs -V
mke2fs 1.40 (29-Jun-2007)
Using EXT2FS Library version 1.40
/sbin/mke2fs_fix/mke2fs -V
mke2fs 1.39 (29-May-2006)
Using EXT2FS Library version 1.40
Build commands:
mkdir build
cd build
../configure --prefix=/usr --with-root-prefix="" --enable-elf-shlibs --disable-evms --disable-nls
make
make install DESTDIR=/sources/E2fsprogs
make install-libs DESTDIR=/sources/E2fsprogs
mke2fs is one of the first programs being called after I pivot_root into the squashfs to make the cd live. It's not like it's a fully functional system at this point. Something simple probably changed in mke2fs. It just seems strange the old one works and the new one doesn't. They were both compiled on Slackware-11.0 by me with the same exact commands, same glibc, and same version of gcc.
I messed around with GParted and Parted once the livecd booted and did some tests on my test drive. Every function I tried with 1.40 worked perfect. mk*, grow, shrink, check... They all work without issue.
Patrick Verner
exodusrobot@yahoo.com
www.partedmagic.com
Logged In: YES
user_id=628
Originator: NO
Hmm... can you give me the exact error message which is being printed?
And can you run mke2fs under strace and ltrace and show me what they show? Thanks!!
Logged In: YES
user_id=1408711
Originator: YES
Magic mismatch ,very weird!
Is the only error I get from mke2fs.
I don't have ltrace only strace.
root@darkstar:~# mke2fs -V
mke2fs 1.40 (29-Jun-2007)
Using EXT2FS Library version 1.40
root@darkstar:~# strace mke2fs
execve("/sbin/mke2fs", ["mke2fs"], [/* 44 vars */]) = 0
uname({sys="Linux", node="darkstar", ...}) = 0
brk(0) = 0x8052000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=112131, ...}) = 0
mmap2(NULL, 112131, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7edb000
close(3) = 0
open("/lib/libext2fs.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360[\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=560429, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7eda000
mmap2(NULL, 133288, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7eb9000
mmap2(0xb7ed9000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x20) = 0xb7ed9000
close(3) = 0
open("/lib/libcom_err.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240\v\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=22215, ...}) = 0
mmap2(NULL, 10108, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7eb6000
mmap2(0xb7eb8000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb7eb8000
close(3) = 0
open("/lib/libblkid.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\37"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=98211, ...}) = 0
mmap2(NULL, 31064, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7eae000
mmap2(0xb7eb5000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7) = 0xb7eb5000
close(3) = 0
open("/lib/libuuid.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260\v\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=28894, ...}) = 0
mmap2(NULL, 12108, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7eab000
mmap2(0xb7ead000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1) = 0xb7ead000
close(3) = 0
open("/lib/libe2p.so.2", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20\23\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=65111, ...}) = 0
mmap2(NULL, 18032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7ea6000
mmap2(0xb7eaa000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4) = 0xb7eaa000
close(3) = 0
open("/lib/tls/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20O\1\000"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1441201, ...}) = 0
mmap2(NULL, 1240284, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7d77000
mmap2(0xb7ea0000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x128) = 0xb7ea0000
mmap2(0xb7ea4000, 7388, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7ea4000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d76000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7d75000
mprotect(0xb7ea0000, 4096, PROT_READ) = 0
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7d756c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
munmap(0xb7edb000, 112131) = 0
brk(0) = 0x8052000
brk(0x8073000) = 0x8073000
open("/etc/mke2fs.conf", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOTDIR (Not a directory)
open("/etc/mke2fs.conf", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=330, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ef6000
read(3, "[defaults]\n\tbase_features = spar"..., 4096) = 330
read(3, "", 4096) = 0
close(3) = 0
munmap(0xb7ef6000, 4096) = 0
getuid32() = 0
geteuid32() = 0
getgid32() = 0
getegid32() = 0
prctl(0x3, 0, 0, 0, 0) = 1
open("/dev/tty", O_WRONLY|O_APPEND|O_CREAT, 0666) = 3
fstat64(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 0), ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7ef6000
fstat64(3, {st_mode=S_IFCHR|0666, st_rdev=makedev(5, 0), ...}) = 0
_llseek(3, 0, 0xbfbbd498, SEEK_END) = -1 ESPIPE (Illegal seek)
uname({sys="Linux", node="darkstar", ...}) = 0
write(2, "Usage: mke2fs [-c|-t|-l filename"..., 354Usage: mke2fs [-c|-t|-l filename] [-b block-size] [-f fragment-size]
[-i bytes-per-inode] [-I inode-size] [-j] [-J journal-options]
[-N number-of-inodes] [-m reserved-blocks-percentage] [-o creator-os]
[-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
[-O feature[,...]] [-r fs-revision] [-R options] [-qvSV]
device [blocks-count]
) = 354
exit_group(1) = ?
Process 12635 detached
Patrick Verner
exodusrobot@yahoo.com
www.partedmagic.com
Logged In: YES
user_id=628
Originator: NO
OK, I'm guessing the error message "Magic mismatch, very wierd" appeared when you tried to mount /dev/ram1? You didn't make that clear in your initial bug report.
So let's ask some more questions. What version of the kernel are you using, and what architecture are you trying this on?
Also what happens if you run dumpe2fs -h /dev/ram1 after running the "/sbin/mke2fs -m 0 -i 1024 -q /dev/ram1" command? Can you send me the output of the dumpe2fs command?
Logged In: YES
user_id=1408711
Originator: YES
Yes, you are exactly right when you said "...when you tried to mount /dev/ram1?"
It does fail when I tried to mount it. I did however figure out what is going on and why it failed. I can get to fail on any system with any kernel with version 1.40.
mkdir /root/test
/sbin/mke2fs -m 0 -i 1024 -q /dev/ram1
mount -n /dev/ram1 /root/test -t ext2
Works just fine. Now:
mv /etc/mke2fs.conf /etc/mke2fs.conf.test
mkdir /root/test
/sbin/mke2fs -m 0 -i 1024 -q /dev/ram1
mount -n /dev/ram1 /root/test -t ext2
And then this happens:
mount: wrong fs type, bad option, bad superblock on /dev/ram1,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
So, this is what I did wrong. I had only the bare minimum files in the directory /ramdisk/etc before it gets mounted by the ram disk and all of the real /etc files get copied there.
All I had to do is add the file mke2fs.conf to the bare minimum /ramdisk/etc. I couldn't find a problem later on because the file mke2fs.conf was there after the ramdisk mounted and copied all the files to /ramdisk/etc.
So to make a long story sort. mke2fs from 1.39 doesn't absolutely need this file, but mke2fs from 1.40 does.
Patch to compile in a default version of mke2fs.conf into mke2fs
Logged In: YES
user_id=628
Originator: NO
I figured it out. What's going on is you're getting bitten by a very old ramdisk bug, where it doesn't support filesystem sizes other than 1k. Furthermore, you're using mke2fs in an environment where /etc/mke2fs.conf is not present, and mke2fs in e2fsprogs 1.40 changed the default blocksize if /etc/mke2fs.conf is not present from 1k to 4k, because too many people were screwing up and creating 1k blocksize filesystem with terrible performance when distro installer environments failed to install /etc/mke2fs.conf. Unfortunately, this is biting you.
So here are a couple of workarounds.
1) Explicitly specify a blocksize of 1k by passing the option "-b 1024" to mke2fs
2) Installing /etc/mke2fs.conf (this is done by "make install", but apparently you're not using it)
3) Apply the attached patch, which will be in the next maintenance release of e2fsprogs
File Added: patch
Logged In: YES
user_id=1408711
Originator: YES
The patch worked as advertised. Your decision to compile in the default values if this file is missing is a very good idea. I could see some embedded system creators making the same mistake I did. I ended up using options 1) and 2) because it's actually the proper way to do it. So, with your patch I have option 3) as well.
Thanks for your time and effort.
Patrick Verner
exodusrobot@yahoo.com
www.partedmagic.com