0

I tried

ramfs_size_mb=2048  
mount_point=/usr/local/var/mysql  

# 1024     bytes per kibibyte
# 1024 kibibytes per mebibyte
#  512     bytes per sector
ramfs_size_sectors=$((${ramfs_size_mb}*1024*1024/512))  
ramdisk_dev=`hdid -nomount ram://${ramfs_size_sectors}`  
mkdir -p ${mount_point}

which up to this point had no errors.

then this fails (as recommended by Can I put /tmp and /var/log in a ramdisk on OS X? ):

newfs_hfs -v 'Volatile' ${ramdisk_dev}
newfs_hfs: cannot create filesystem on /dev/rdisk2                                              : No such file or directory  

this also fails (as recommended by https://apple.stackexchange.com/questions/193883/to-have-ram-based-filesystem-in-osx ):

newfs_hfs ${ramdisk_dev}
newfs_hfs: cannot create filesystem on /dev/rdisk2                                              : No such file or directory

I'm not sure where /dev/rdisk2 comes from since ${ramdisk_dev} is /dev/disk2`

echo ${ramdisk_dev}
/dev/disk2

I can see the ram disk:

hdiutil info
framework       : 595.140.1
driver          : 595.140.1
================================================
image-path      : ram://4194304
shadow-path     : <none>
icon-path       : /System/Library/PrivateFrameworks/DiskImages.framework/Resources/CDiskImage.icns
image-type      : read/write
system-image    : false
blockcount      : 4194304
blocksize       : 512
writeable       : TRUE
autodiskmount   : false
removable       : TRUE
image-encrypted : false
mounting user   : myusername
mounting mode   : <unknown>
process ID      : 17797
/dev/disk2
diskutil list
.
.
.
/dev/disk2 (disk image):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                                                   +2.1 GB     disk2

Why can't I use new_hfs with my ramdisk?

joseph
  • 151
  • 6
  • 1
    `newfs` re-formats an existing partition. You just need [copied without correction from an existing script, I'm in a rush;) `set DeviceName to do shell script "hdid -nomount ram://" & NumSectors` & `tell application "System Events" to do shell script "diskutil eraseVolume 'HFS+' '" & VolumeName & "' " & DeviceName` – Tetsujin Jan 20 '22 at 20:07
  • `diskutil erasevolume HFS+ MYSQL_IN_MEMORY ${ramdisk_dev}` results in `Unable to find disk for /dev/disk2` but diskutil list shows it's there. – joseph Jan 20 '22 at 20:12
  • I started over with `hdiutil eject /dev/disk2`. Then I did `hdid -nomount ram://4194304` returns `/dev/disk2` `diskutil erasevolume HFS+ MYSQL_IN_MEMORY /dev/disk2` and then it worked.........!!!! YES! – joseph Jan 20 '22 at 20:15
  • I think root cause was `${ramdisk_dev}` was somehow `/dev/rdisk2` even though when i echoed it, it was `/dev/disk2` because when i manually provided the param `/dev/disk2`, it worked – joseph Jan 20 '22 at 20:34

0 Answers0