Other Memory disk info

The handbook shows a way to create a memory disk:

Code:
# mdconfig -a -t swap -s 5m -u 1
# newfs -U md1
/dev/md1: 5.0MB (10240 sectors) block size 16384, fragment size 2048
        using 4 cylinder groups of 1.27MB, 81 blks, 192 inodes.
        with soft updates
super-block backups (for fsck -b #) at:
 160, 2752, 5344, 7936
# mount /dev/md1 /mnt
# df /mnt
Filesystem 1K-blocks Used Avail Capacity  Mounted on
/dev/md1        4718    4  4338     0%    /mnt

Which works just fine, but I don't see any way to determine if a memory disk has had newfs run on it (and therefore is mountable). I usually use gpart to create memory disks, but occasionally run into one that I'm not sure if I can mount or not.
 
There is a command for finding out what type of file system is on a device: fstyp.
Code:
# mdconfig -a -t swap -s 10m -u 1
# fstyp /dev/md1
fstyp: /dev/md1: filesystem not recognized
# newfs -U /dev/md1
/dev/md1: 10.0MB (20480 sectors) block size 32768, fragment size 4096
    using 4 cylinder groups of 2.53MB, 81 blks, 384 inodes.
    with soft updates
super-block backups (for fsck_ffs -b #) at:
192, 5376, 10560, 15744
# fstyp /dev/md1
ufs
See the two different answers from fstyp?
 
You've mixed md0 and md1, did you actually cut and paste that? Anyway, fstyp doesnt seem to be native on older systems, so that would be a problem for me. Still have a bunch of 9.x in service.

I've found that

Code:
file -s /dev/md0
/dev/md1: Unix Fast File system [v2] (little-endian) last mounted on , last written at Sat Oct 24 05:04:55 2020, clean flag 1, readonly flag 0, number of blocks 524288, number of data blocks 507783, 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

has been around and seems to give me the info I need. A little more verbose than necessary, but it will do.
 
Sorry about the mixing of md0 and md1; I forgot to use the "-u 1" switch to make it consistent with what you typed, and hand-edited the cut-and-paste output, and didn't do a good job. Did you notice that I also got the size wrong? I just fixed the confusion and edited it.

I didn't know that fstyp is a new thing. The file command will probably work too, it's just sloppier (have you ever looked how it works? it's magic!). And I probably don't need to remind you that 9.x systems really ought to be upgraded.
 
Back
Top