[ previous ] [ next ] [ threads ]
 
 From:  "Frans King" <frans dot king at f333 dot net>
 To:  <m0n0wall at lists dot m0n0 dot ch>
 Subject:  RE: [m0n0wall] Self-healing file system?
 Date:  Sun, 27 Feb 2005 17:12:45 -0000
The only way to edit a running m0n0wall is to download files from exec.php,
modify them and the upload them again via exec.php. There is no ftp
subsystem. 

 

I haven't seen a non-resetting version of m0n0wall.

 

The m0n0wall image format in FreeBSD looks a bit like this:

 

/cf

Mfsroot.gz

Kernel.gz

 

The /cf part is where the config file gets stored. It's mounted as a normal
partition but is read-only. When you make config changes its remounted
read-write and a new config.xml is written. Then its set back to read only.

 

Kernel.gz is a compressed kernel binary.

 

Mfsroot.gz is a compressed disk image that contains the root filesystem.
This is unpacked into memory and mounted as "/" during the boot. Think of it
as a bit like an ISO image that under linux you can mount with "mount -o
loop /mnt/iso my_image.iso".

 

Under FreeBSD I do the following to make changes:

 

Download latest image (latest.img)

 

mv latest.img latest.img.gz

gzip -d latest.img.gz                                    (uncompress the
image - renamed to .gz otherwise gzip gets upset)

 

vnconfig -s labels -c vn0 latest.img                (latest.img is now
"mapped" to the vn0 virtual disk node)

mount /dev/vn0a /mnt

 

cd /mnt

cp mfsroot.gz /var/tmp

cd /var/tmp

umount /mnt

vnconfig -u vn0 (release vn0)

 

gzip -d mfsroot.gz                                      (uncompress the root
file system image)

vnconfig -s labels -c vn0 mfsroot

mount /dev/vn0c /mnt

 

Now you can edit files in the /mnt directory which will be written back to
the mfsroot image

 

umount /mnt

vnconfig -u vn0

 

(recompress the modified root image copy it back to the m0n0wall image)

 

gzip -9 /var/tmp/mfsroot

vnconfig -s labels -c vn0 latest.img

mount /dev/vn0a /mnt

mv /var/tmp/mfsroot /mnt/mfsroot.gz

umount /mnt

vnconfig -u vn0

 

gzip -9 latest.img

mv latest.img latest-modified.img (now upgrade m0n0wall with this image)

 

Done!

 

I think someone has written some bash scripts to do all of this work for you
but I'm not sure who.

 

Regards,

 

Frans

 

P.S. If you start with a working image (as above) then you don't need to
bother about compiling kernels / creating disk images / installing the boot
loader etc.