# mfsroot



## balanga (Jul 25, 2018)

Within mfsBSD there is a file called mfsroot, which according to `file -s mfsroot` is Unix Fast File. 
Is there any way of extracting the files from it?


----------



## ShelLuser (Jul 25, 2018)

You probably mean it's Unix Fast File system, aka: UFS.

That's very easy to mount, it works the same as mounting an ISO image. Use mdconfig(8) to gain access to the file, then use mount to actually mount it.


----------



## balanga (Jul 25, 2018)

ShelLuser said:


> You probably mean it's Unix Fast File system, aka: UFS.


It did confuse me since I thought it might be something else such as ffs(7)()...  Is this just an old name for UFS?


> That's very easy to mount, it works the same as mounting an ISO image. Use mdconfig(8) to gain access to the file, then use mount to actually mount it.



Many thanks for that. This opens up a whole range of possibilities, if I can manage to pack in some of my own preferred tools... Having mfsBSD booting up with access to my Samba server would be very handy.  Now, how do I do that, and repackage mfsroot?...


----------



## ShelLuser (Jul 25, 2018)

As I hinted at above: gain access to the file using mdconfig(8), it will create a blockdevice. For example md0. Then access the file using that block device. For example: `# mount /dev/md0 /mnt`.
It's all in the manualpage.


----------



## balanga (Jul 26, 2018)

I've never really used memory disks, but from my reading of the manual page do I simply create an empty file call abcd with a size of x then mount it as memory disk and copy files to it?


----------



## ShelLuser (Jul 26, 2018)

I thought you wanted to access mfsroot?  You might even be able to simply add files to the existing image.

Anyway, all mdconfig does is provide a block device which points to an actual file instead of physical media. You'd need to 'format' a disk (basically set up a file system) before you can use it, that requirement hasn't changed here.

Sure, you can make an empty file, access it using mdconfig but then you'd need to set up a filesystem before you can actually use it as storage.


----------



## balanga (Jul 26, 2018)

ShelLuser said:


> I thought you wanted to access mfsroot?  You might even be able to simply add files to the existing image.



Yes accessing mfsroot was my initial aim, but when I saw what was in it I began to wonder what I could do with it....

I obviously want to customise it but am not sure if the size of the file is fixed. I'll try adding something, then unmounting and mounting and see if it remains...


----------



## ShelLuser (Jul 26, 2018)

A whole new lot 

Oh well.. since I'm in a weekend mood right now anyway:

```
root@zefiris:/home/peter/temp # dd if=/dev/zero of=filedisk bs=1024k count=128
128+0 records in
128+0 records out
134217728 bytes transferred in 0.397892 secs (337322320 bytes/sec)
root@zefiris:/home/peter/temp # mdconfig -f ./filedisk
md0
root@zefiris:/home/peter/temp # file filedisk
filedisk: data
root@zefiris:/home/peter/temp # newfs /dev/md0
/dev/md0: 128.0MB (262144 sectors) block size 32768, fragment size 4096
        using 4 cylinder groups of 32.03MB, 1025 blks, 4224 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 65792, 131392, 196992
root@zefiris:/home/peter/temp # file filedisk
filedisk: Unix Fast File system [v2] (little-endian) last mounted on , last written at Thu Jul 26 19:23:36 2018, clean flag 1, readonly flag 0, number of blocks 32768, number of data blocks 31623, number of cylinder groups 4, block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64, pending blocks to free 0, pending inodes to free 0, system-wide uuid 0, minimum percentage of free blocks 8, TIME optimization
```
And now I could easily mount it if I wanted to: `# mount /dev/md0 /mnt` and then do all sorts of stuff with it 

That's the power of the memory disk


----------

