mdconfig command issues

Hello.
I've created a memory disk file named fimage.img size 1GB.
Code:
dd if=/dev/zero of=/media/fimage.img bs=2048000

mdconfig -a -t vnode -f /media/fimage.img -u 2

mount /dev/md2 /mnt
All works fine but files and folders that exists before mounting md2 are disappeared after mounting .
Is there any option to make it possible merging the initial content of folder with the content of the mounted md2 !?

Thanks
 

SirDice

Administrator
Staff member
Administrator
Moderator
You can't mount md2, there's no partitioning on it and no filesystem. For all intents and purposes, it's a disk image. Treat is as a 'normal' disk. So partition and newfs(8) it (if you want UFS).

You're trying to mount an empty disk (you wiped the whole thing with zeros).

Code:
root@molly:~/test # truncate -s 4G image.img
root@molly:~/test # ll
total 1
-rw-r--r--  1 root  wheel  4294967296 Sep 23 11:15 image.img
root@molly:~/test # mdconfig -a -f image.img
md0
root@molly:~/test # mount /dev/md0 /mnt/
mount: /dev/md0: Invalid fstype: Invalid argument
root@molly:~/test # gpart create -s gpt md0
md0 created
root@molly:~/test # gpart add -t freebsd-ufs md0
md0p1 added
root@molly:~/test # newfs /dev/md0p1
/dev/md0p1: 4096.0MB (8388528 sectors) block size 32768, fragment size 4096
        using 7 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880
root@molly:~/test # mount /dev/md0p1 /mnt/
root@molly:~/test # ll /mnt/
total 8
drwxrwxr-x  2 root  operator  512 Sep 23 11:16 .snap/
root@molly:~/test # touch /mnt/helloworld
root@molly:~/test # ll /mnt/
total 8
drwxrwxr-x  2 root  operator  512 Sep 23 11:16 .snap/
-rw-r--r--  1 root  wheel       0 Sep 23 11:16 helloworld
root@molly:~/test # umount /mnt/
root@molly:~/test # mdconfig -d -u 0
 
Eh, I just forget to write a full commands
Of course I've created a UFS fs for the md2
Code:
newfs -O2 /dev/md2
After that I've mounted it and copied into it a folders and files.
But when I mount it in folder that initially contains files and folders, it masks that and display only content of /dev/md2
 
Top