Apple Enterprise - NeXTanswers Support Archive

Search NeXTanswers for:

NEXTSTEP 3.3 Disk and Filesystem Q&A

Creation Date: August 13, 1998


This document pertains to the NeXTSTEP operating system, which is no longer a supported product of Apple Computer. This information is provided only as a convenience to our customers who have not yet upgraded their systems, and may not apply to OPENSTEP, WebObjects, or any other product of Apple Enterprise Software. Some questions in this Q&A document may not apply to version 3.3 or to any given specific version of NeXTSTEP.

Q: How do I put a recycler on my external hard disk?

Q: My new external disk displays a panel indicating "No recycler for device..."

A: In order to have recycler on an external disk, you must have a .NextTrash directory at the mount point for the drive. As an example, here is how you would create a recycler for an external disk mounted as /archive (issue the following commands as root in a Terminal window):

localhost# cd /archive
localhost# df .
Filesystem kbytes used avail capacity Mounted on
/dev/sd2b 216311 152584 42095 78% /archive
localhost# mkdir .NextTrash
localhost# chown root.wheel .NextTrash
localhost# chmod 1777 .NextTrash
localhost# ls -ldg .NextTrash
drwxrwxrwt 19 root wheel 1024 Sep 30 10:42 .NextTrash/

After completing these steps, you'll need to reboot the system for the new recycler to be properly recognized.

Are file system quotas supported by NeXT software?

A: No. Quotas are not supported by NEXTSTEP.

Q: Why does fcntl(fd, F_SETLK, &lockstruct) give EINVAL? What is the preferred method of file locking?

A: The current release of Sun's NFS file system has a number of problems regarding file locking. Sun has implemented a "first crack" at solving the problems associated with extending Unix's file locking to NFS. NeXT decided, upon looking at this, that there were too many hidden deadlock conditions inherent in the implementation to release. Instead, the current version of fcntl(2) will fail with EINVAL if the directives F_GETLK or F_SETLK are used. These directives will work when a new version of NFS file locking is available, in our 4.0 release.

In the mean time, if a file locking system is necessary for your application, the best system to use is to write out a file whenever your application accesses a file for writing. The easiest thing to do is to create a file of the same name with an added extension, like "LCK" for instance. Your application should check to see if this file exists before opening a file, and create the lock file, if one doesn't exist.

Here's one idea: if you open(2) a file with both CREATE and EXCLUSIVE turned on, then open(2) will return an error if the file exists, and will create the file if it doesn't. Something like

#include <sys/file.h>
int fd;

fd = open(lockfile, O_CREAT | O_EXCL, 0600);

if (fd < 0) { /* Something didn't work */
if (errno != EEXIST) { /* Real error occurred */
perror("Open failed");
else { /* Lock file is there */
/* await lock release */
else /* Things are OK */

This still has some problems when systems crash with files open, or the if the Workspace exits with your application still running. To deal with this, your application should erase these lock files (with the unlink(2) system call, for example) in an appDidTerminate: method. Also, when one of these lock files exist, you should display an alert panel asking if the user would like to override the lock.

For applications that run on a single machine (without any network file access) you can use flock(2)if you are concerned that your application may be run multiple times on the same machine. This scheme works for network files too, when that support is added.

Note: the fcntl(2) directives not associated with file locking:


work fine.

Q: To where is the /mach symlink resolved when netbooting (or any other sort of booting)?

A: To the path of the kernel booted; typically, this is:


though it could be rather anything, depending on what was in the server's bootptab and NetInfo databases. By default, this file is itself a symlink, to /sdmach.

Default boot devices and $BOOTFILE values are

SCSI sdmach
OD odmach
Net /private/tftpboot/mach

Note that if the user booted with a command such as


then $BOOTFILE will resolve to MyMach.

Q: I'm using rdist to do remote software distribution, or to copy files from an optical disk to my hard disk. But, rdist gives the error "permission denied." What's wrong?

A: Be sure the machine from which you're doing the rdist is in the .rhosts file of the target machine (this file contains a list of trusted remote hosts). /.rhosts is consulted if the rdist is being run as root. In other cases, the .rhosts file in the user's home directory and the hosts.equiv file are consulted, in the same manner as for rcp and rsh. (Note that hosts.equiv is NOT consulted when the rdist is being run as root.)

Q: I changed /etc/fstab, and now NEXTSTEP won't boot. If I boot the system in single-user mode, I can't edit /etc/fstab to fix it because the file system is read-only. What do I do to fix it?

A: The start-up script /etc/rc.boot makes the root filesystem read-write with the command:

mount -o remount /

The mount command looks in /etc/fstab for an entry that describes "/". It should find a line like:

/dev/sd0a / 4.3 rw,noquota,noauto 0 1

This means that the filesystem on the device sd0a should be mounted as the root ("/") filesystem. If this line in the /etc/fstab file is missing, incorrect, or damaged, the mount command fails. You are left with a read-only root filesystem.

The solution is to re-mount the root file system with the shell command:

# mount -o remount /dev/sd0a /

In this form, you are telling mount exactly which device to use, so it doesn't look in /etc/fstab and get confused. Once you have the root filesystem mounted read-write, fix it with a text editor (don't include any blank lines) or get a copy of a default /etc/fstab. You can find default copies in /usr/template/client. i.e.:

# cp /usr/template/client/etc/fstab.sd330 /etc/fstab

Then shut down and reboot your system:

# reboot

Q: Why is the ``high water mark'' in my /etc/swaptab ignored?

A: This is probably due to an extra space in /etc/swaptab. The format of this file must be exactly as in swaptab(5), without spaces after the commas. Thus

# /etc/swaptab
/private/vm/swapfile lowat=20971520,hiwat=73400320 # 20/70 MB

works as expected, but in

# /etc/swaptab
/private/vm/swapfile lowat=20971520, hiwat=73400320 # 20/70 MB

the hiwat is ignored (note the space after the first comma).

Q: My machine won't swap to my swapdisk (SCSI address 6). However, I think this used to work.

A: You may have a removable media device at a lower SCSI address than your swap disk. Devices with no media in them cannot return a disk label, causing checkswap to return FSR_NONE. The file /etc/rc.swap has a line

case $swapstatus in
# No such disk was actually connected.

This can be fixed by removing the line with break in it. You end up with:

case $swapstatus in
# No such disk was actually connected.

The downside is that the script always scans for all SCSI devices looking for a swap device.

Q: What is the size of the swapfile for NEXTSTEP?

A: The size of the swapfile depends on the parameters set up in the /etc/swaptab configuration file and the demand for paging on the system. The swapfile dynamically grows on demand; the demand for swapping depends on the memory needs of the running applications, and the size of the ``real'' memory (the more real memory the less the demand for paging space).

The swaptab file looks like this:

# /etc/swaptab
/private/vm/swapfile lowat=20971520 # 20 Meg low water mark

This tells the system to use the file /private/vm/swapfile for swapping. It also specifies the parameter lowat=20971520, the ``low water mark.'' This low water mark is the smallest size to which the file shrinks. The paging file then grows as needed to meet demand.

A hiwat=n parameter may be used in the swaptab to set a limit on how large this file grows.

Q: What size is the swapfile when a fresh copy of NEXTSTEP is installed ?

A: It starts out at 16MB out of the box. It should never get smaller, since this the default size of the lowat mark in /etc/swaptab.

Q: Will the swapfile get smaller (if above the low water mark) while the system is running, or is it reset only upon reboot?

A: The swapfile works in a stack-oriented manner--it shrinks only if the system detects that all pages above a certain address are unallocated. This rarely occurs. Consider launching a 4MB application which is completely paged out followed by one more page owned by some other application in the system. Even if the 4MB is freed the swapfile cannot be truncated until that extra page is freed. What generally happens is that long-running applications allocate a few pages at the high addresses, and swapfile apparently never shrinks.

During a reboot when paging is turned on (by the invocation of mach_swapon), the swapfile is immediately truncated to the minimum value.

Note: Despite the file being called the swapfile, NEXTSTEP uses pure demand-paged memory management. mach_swapon(8) tells the kernel to initiate paging.

Q: Why does indicate ``permission denied'' and die? Doesn't it run as root?

A: One possible cause of this situation is related to running while your system is connected to a network. tries to ensure that what it's building will fit on the target disk. To do this, it calculates the size of each directory to be loaded. If, for example, you have /NextDeveloper/Examples imported from an NFS server, and, if there's a .NextTrash directory in that directory, the root user might not be able to see what's inside in order to determine the size.

Whenever possible, run on a system that's disconnected from the network.

If you must be connected to the network (e.g., if you're running on a NeXTstation that's NetBooted), and if you get a message like the above, go to the machine that's serving the flagged directory and remove the .NextTrash directory and its subdirectories (or whatever other directory is giving you problems). If removing the directory is inappropriate, either grant everyone read permission, or export the file system (via exportfs and the /etc/exports file; see the UNIX Manual Pages or the NeXT Network and System Administration manual) to grant root access as necessary to the NetBoot client.

It's also possible that you'll run out of space on the target machine if you're importing large directories from an NFS server.

Q: I want to customize the icon displayed for a directory in the Workspace File Viewer. How can I do this?

A: The Workspace Manager looks for a file called .dir.tiff in the directory. It uses this in place of the usual icon when displaying that directory in the Viewer. You may also want to place a file called .opendir.tiff in the directory. This is used in place of the ``open folder'' icon which is displayed when you drag new files to that directory. For best results, the tiff files should be 48 x 48 pixels square. The .dir.tiff icon is also used by Digital Librarian to represent the directory if you use it as a target.

For fun, you can put a .dir.tiff and a .opendir.tiff file in your home directory and replace the little house with something more representative of your personality!

OpenStep | Alliances | Training | Tech Support | Where to Buy