Why is swap device reported with wrong name?

Oliver Fromme olli at secnetix.de
Sat May 3 16:31:55 PDT 2003


Geoffrey T. Falk <gtf at cirp.org> wrote:
 > I just added an old drive to use as a swap disk on ad1 on my 4.8-STABLE
 > system. Why is the name reported as "/dev/rad1s1b"? /dev has both
 > devices.
 > 
 > bork% swapinfo
 > /dev/rad1s1b       130944     5304   125640     4%    Interleaved
 > 
 > /etc/fstab has:
 > /dev/ad1s1b             none            swap    sw              0       0

The kernel doesn't store the path names of the swap devices,
but only the device number (major/minor).  So, the swapinfo
command goes through /dev and looks for a device with that
major and minor number.  If you look carefully, you see that
ad1s1b and rad1s1b are really the same device (hardlinked):

crw-r-----  2 root  operator  116, 0x00020009 Apr 11 23:43 /dev/ad1s1b
crw-r-----  2 root  operator  116, 0x00020009 Apr 11 23:43 /dev/rad1s1b

The swapinfo command displays the first one which it finds,
which may be either of the two.  (Directory entries are not
sorted on disk.  Only ls sorts them for output.)

The devices starting with r* (formerly known as raw devices)
exist for compatibility only.

Regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

Man had always assumed that he was more intelligent than dolphins
because he had achieved so much... the wheel, New York, wars, and so
on, whilst all the dolphins had ever done was muck about in the water
having a good time. But conversely the dolphins believed themselves
to be more intelligent than man for precisely the same reasons.
                -- Douglas Adams, "The Hitchhikers Guide To The Galaxy"


More information about the freebsd-stable mailing list