Checking How many hdd and cd between hdd

How on earth do you check how many hdd you have? I mean on a Mac it is pretty easy
Code:
$ diskutil list
/dev/disk0 (internal, physical):
    #:                               TYPE NAME            SIZE          IDENTIFIER
    0:    FDisk_partition_chneme                     *500.1GB   disk0
    1:              Windows_NTFS    500GB            500.1GB.  disk0s1

/dev/disk1 (internal, physical):
    #:                               TYPE NAME            SIZE          IDENTIFIER
    0:    GUID_partition_scheme                     *500.1GB   disk1
    1:                                  EFI EFI.                209.7MB  disk1s1
    2:          Microsoft Basic Data WDDATA        499.8GB   disk2s2
.
.
.

Then to move/cd between them:

Code:
cd /Volume/<disk name>/

That's it.

Is there anything like this for freebsd? Instead of going through
Code:
/var/run/dmesg.boot
file?

I still do not know how to change/cd to another hdd on my laptop. How do you change to another hdd?
 
sysctl kern.disks

But this doesn't tell you how many partitions there are or if they're mounted or not.

I still do not know how to change/cd to another hdd on my laptop. How do you change to another hdd?
Simple, you don't. Because it's irrelevant. A filesystem can be mounted anywhere. You don't change directory to a disk, you change directory. And that directory may be a filesystem on a partition on a disk. A different directory can be a different filesystem on a different disk. Or a different filesystem on the same disk.

One disk can have one or more partitions, each partition can have a filesystem. And it's the filesystem that's mounted, not the disk. MacOS just treats each disk as a filesystem and mounts that filesystem on a specific spot.

In order to know what directory is on what disk you'll have to look at the output from gpart(8) (this tells you which partitions exist) and mount(8) (this tells you which filesystem is mounted where).

For example:
Code:
> mount
/dev/mfid0p2 on / (ufs, local, journaled soft-updates)
devfs on /dev (devfs, local, multilabel)
/dev/mfid1p1 on /var/db/mysql (ufs, local)
This tells me the disk mfid0 has at least 2 partitions and the second partition (p2) is mounted on /. The second disk, mfid1, has one partition (p1) mounted on /var/db/mysql.
 
In today's world (see footnote), there isn't a 1-to-1 correspondence between physical disks and file systems. We can easily have file systems that use multiple disks (for example, on my shoebox-sized server at home the /home/ file system is on two disks). Extreme examples of that happen in supercomputers, where a single file system can span tens of thousands of disks. Conversely, we can have disks that are in use but don't hold a file system; a ZFS log or cache disk is an example (those are a little more rare than multi-disk file systems, but by no means non-existing). And with partitions/slices/... we often have physical disks that contain multiple logical file systems.

On the other hand, with removable devices there is nearly always a 1-to-1 correspondence between disks and file systems. This goes back to the days of cp/m and MS-DOS, where each floppy was its own file system, and the concept of "current working directory" contained the hardware identity of the floppy (the A: and C: prompt of early MS-DOS systems, which still exists in Windows today, is an example of that). Today USB sticks and SD cards are the prime example of a "disk" piece of hardware that is identical to a single file system. And that even makes sense: with easily movable devices (there are about 3 USB sticks on the desk next to me, and I too often find SD cards in my pockets, after a trip through the washing machine) each individually portable device needs to be its own file system. This is where the "/Volumes/<diskname>" convention on the Mac comes from: a convenient way of accessing removable media.

To use Unix systems, one has to understand that sometimes disks are file systems, and sometimes they are not, but instead part of a larger file system, or the contained for multiple smaller file systems.

(Footnote: When I say "today's world" above, this has been the case since about the 1970s, with the first RAID implementations and multi-disk file systems on mainframes, so it has been a long time.)
 
When I say "today's world" above... since about the 1970s, with the first RAID implementations and multi-disk file systems on mainframes, so it has been a long time.)
Maybe. Depends on perspective.

For people with no access to mainframes and workstations, this was different. The OSes private people like me and small companies used in the 1970s still were drive-based. A: B:, D1 D2, or even directly via IEEE-488 (or similiar) hardware address, bus number, id.
With the advent of Linux and finally FreeBSD this finally changed in the early 1990s even for the poor.
And a quarter of century later the major commercial PC OSes still train the users in "drive thinking"...

Will this change soon?
Imagine you are a normal guy and no computer guy.
If you could add disk for disk and grow your "disk" as a multi-disk filesystem, i.e. no more "drives" A: B: C: D: Etc:
And then you have maybe a 20-disk sort of RAID-0.
Of course you don't have a backup plan.
And then some day one of that bunch of disks smokes up, and you discover that this smoked the data of the whole cluster, and not "just some files that happened to land on that drive".
Won't you curse the guys who replaced the "drive-based" approach with that $#%#@ "multi-disk-filesystem"?

So I am not really sure what's good and what's bad.
Sorry for being OT.

Back to the OP's question.
Use mount without parameters.
If you need to associate that output with physical disks, use dmesg | egrep '^(ad|da|cd)' | sort.
 
Showing how many hdd but no ref.

Code:
#sysctl kern.disks
kern.disks: ada1 ada0


Not seeing any info on hdd.

Code:
#mount
zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls)
devfs on /dev (devfs, local, multilabel)
zroot/tmp on /tmp (zfs, local, noatime, nosuid, nfsv4acls)
zroot/usr/home on /usr/home (zfs, local, noatime, nosuid, nfsv4acls)
zroot/usr/ports on /usr/ports (zfs, local, noatime, nosuid, nfsv4acls)
zroot/usr/src on /usr/src (zfs, local, noatime, nosuid, nfsv4acls)
zroot/var/audit on /var/audit (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/crash on /var/crash (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/log on /var/lag (zfs, local, noatime, noexec, nosuid, nfsv4acls)
zroot/var/mail on /var/mail (zfs, local, nfsv4acls)
zroot/var/tmp on var/tmp (zfs, local, noatime, nosuid, nfsv4acls)
zroot on /zroot (zfs, local, noatime, nfsv4acls)


Showing info about the hdd but the ref to move/cd to the second hdd/ada1?

Code:
#egrep 'ad[0-9]|da[0-9]' /var/run/dmesg.boot
acpi_acad0: <AC Adapter> on acpi 0
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: <Apacer AS330 120GB AP110PD0> ACS-2 ATA SATA 3.x device
ada0: Serial Number 37F507.....
ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PI0 8192bytes)
ada0: Command Queueing enabled
ada0: 114473MB (234441648 512 byte sectors)
ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
ada1: <WDC WD10JPCX-24UE4T0 01.01A01> ACS-2 ATA SATA 3.x device
ada1: Serial Number WD-WXP1E.....
ada1: 600.000MB/s transfers (SATA 3.x, UDMA6, PI0 8192bytes)
ada1: Command Queueing enabled
ada1: 953869MB (1953525168 512 byte sectors)
ada1: quirks=0x1<4k>
#0 0xffffffff80aada97 at kob_backtrace+0x67
(repeat the above display)


To just list out hdd I found this command:-

Code:
#camcontrol devlist
<Apacer AS330 120GB AP110PD0>       at scbus0 target 0 lun 0 (pass0, ada0)
<WDC WD10JPCX-24UE4T0 01.01A01> at scbus0 target 0 lun 0 (pass1, ada1)


I am coming from end-user point of view as per what Snurg said, I am not a 'computer man'. I wanted to try out Freebsd without GUI and mouse, a reminiscence of DOS I suppose, but perhaps a better way for me, to get to know Freebsd.

However in order to do that I need to find out the commands for end-user and not for computer man, at this point in time, for me to get familiar with Freebsd. Like the following code will play the audio file on the second hdd/filesystem with vlc player installed on the first hdd(ada0s1s or whatever),....I think..lol.
Code:
$vlc /dev/<disk/file reference ada1s2>/library/music/dreamon.mp3

My information on Freebsd is fragmented. Sure I know the common command, ls, mv, cp, mkdir, rmdir, but all these commands works on the hdd or filesystem that you are on, ada0. Found lots of command here. But nothing on how to move/cd between hdds/filesyst.

How to move/cd from ada0 to ada1?
 
How on earth do you check how many hdd you have? I mean on a Mac it is pretty easy
Code:
$ diskutil list
/dev/disk0 (internal, physical):
    #:                               TYPE NAME            SIZE          IDENTIFIER
    0:    FDisk_partition_chneme                     *500.1GB   disk0
    1:              Windows_NTFS    500GB            500.1GB.  disk0s1

/dev/disk1 (internal, physical):
    #:                               TYPE NAME            SIZE          IDENTIFIER
    0:    GUID_partition_scheme                     *500.1GB   disk1
    1:                                  EFI EFI.                209.7MB  disk1s1
    2:          Microsoft Basic Data WDDATA        499.8GB   disk2s2
.
.
.

Then to move/cd between them:

Code:
cd /Volume/<disk name>/

That's it.

Is there anything like this for freebsd? Instead of going through
Code:
/var/run/dmesg.boot
file?

I still do not know how to change/cd to another hdd on my laptop. How do you change to another hdd?

On FreeBSD is equally easy. geom disk list -a . You can check GPT slices (Linux guys call those incorrectly partitions) gpart show.
If you have disks which use legacy MBR you can print their slice tables with
fdisk -p /dev/ada0 (replace ada0 with actual disk). man disklabel to learn about BSD partitions (partition of slices onto up to 16 peaces) not very commonly used these days. Finally use sysutils/disktype to probe the disk which contain foreign file systems (not UFS or ZFS).
 
Not seeing any info on hdd.
You're using ZFS, which works differently. With ZFS you certainly never change to a disk. But to see which disks contain what pool look at zpool status.
 
However in order to do that I need to find out the commands for end-user and not for computer man, at this point in time, for me to get familiar with Freebsd. Like the following code will play the audio file on the second hdd/filesystem with vlc player installed on the first hdd(ada0s1s or whatever),....I think..lol.
Code:
$vlc /dev/<disk/file reference ada1s2>/library/music/dreamon.mp3
You need to read a tutorial or introduction to Unix or to BSD or to FreeBSD. At the level you are looking at right now, those are all the same.

As an end user, you hardly ever interact with disks. You interact with file systems. There is not necessarily a 1-to-1 correspondence of disks to file systems as you ZFS output shows: You have two disks, and about a dozen file systems.

File systems are visible in a hierarchy. At the very bottom is the root file system, so called because it contains the root directory "/". That directory may contain some files, and it contains some other directories, for example "/usr". That directory in turn contains more directories, in your case for example "/usr/home" (which is probably where the home directories of users are). Sometimes a directory is not just a directory, but also a mount point: In your case, "/usr/home" is actually a place where another file system starts (look at the list of file systems returned by the mount command above). To the end user who is working with files and directories and traversing the file system, mount points are barely noticeable; they walk and talk like directories. With one exception (described below), end users logically don't need to know and won't notice where file system boundaries are. On the other hand, they can physically notice file system boundaries by observing capacity and performance of the system. The system administrator does care more, and has to manage file systems and maintain and mount them.

My information on Freebsd is fragmented. Sure I know the common command, ls, mv, cp, mkdir, rmdir, but all these commands works on the hdd or filesystem that you are on, ada0. Found lots of command here. But nothing on how to move/cd between hdds/filesyst.

How to move/cd from ada0 to ada1?
There are two concepts you have to distinguish here:

First, your current process (the shell that gives you the prompt and processes your command) has a current working directory, also known as CWD or PWD and various such abbreviations. You can move that to different directories by using the "cd" command. Once you are there, accesses to a file without a full path are relative to the current working directory.

The other concept is that every file is visible in a certain directory. You can move a file from one directory to another directory using the "mv" command (which is the same command used to rename a file). This looks easy, but there is a difficult complexity here: In Unix, you need to distinguish between a file, and its directory entry a.k.a. file name. In most cases, there is a 1-to-1 correspondence: most files have exactly one name, not zero, not multiple. But files can also have zero names (those are temporary files that will vanish once the process using them is done with them), or they can have multiple names (that process involves "hard links"), which can even be in different directories. And this is why the "mv" command is used both to rename a file within its current directory, and move it to another directory: it manipulates names of files. The only place where logically file systems make a difference: a file can not be hard linked across file system boundaries: the same file can not have two names that are in different file systems.

There are way more details here that need to be explained, but I have limited time. You really need to A: read a good tutorial or introduction, and B: explore these concepts by playing with the system.
 
What I forgot to mention: Many commands that helpful people proposed above (like "zpool status" or "geom disk list") are intended for system administration, to configure and create file systems. That is the second level, after you have mastered user concepts like file system, current directory, and file names.
 
Mmmm......it seem I am not asking my question correctly, I think....

My installation uses ZFS filesystem.

$zpool status
Code:
 pool: zroot
state: ONLINE
 scan: none requested
config:

           NAME        STATE         READ  WRITE  CKSUM
           zroot         ONLINE            0           0           0
             ada0p4    ONLINE            0           0           0



I am in root directory.

$ls -F
Code:
COPYRIGHT    dev/       home@    media/    proc/      sbin/    usr/
bin/               entropy   lib/          mnt/       rescue/   sys@    var/
boot/             etc/        libexec/    net/        root/       tmp/    zroot/

I plug in a USB drive and the system printout:-
Code:
$ugen0.5: <ScanDisk Cruzer Force> at usbus0
umass0: on uhub0
umass0: <ScanDisk Cruzer Force, class 0/0 , rev 2.10/1.00, addr 5> on usbus0
umass0: SCSI over Bulk-Only: quirks = 0x8100
umass0:2:0 Attached to scbus2
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <ScanDisk Cruzer Force 1.00> Removable Direct Access SPC-4 SCSI device
da0: Serial Number 213123233.....
da0: 40.000MB/s transfers
da0: 7632MB (15630336 512 byte sectors)
da0: quirks=0x2<No_6_BYTE>
<cursor>

I press RETURN key and cursor return to normal screen mode.

I did a ls -F again and the output is the same as the first time.

Shouldn't it show a new directory or <filename>/ for the USB?

The USB contains two folders with mp3 audio files in them. How do I access them?

And how to detach USB drive safely?
 
if the USB stick contains a partition table and a FAT filesystem, mount -t msdosfs /dev/da0s1 /mnt should make your data accessible as subdirectories of /mnt.
Detach using umount /mnt.
 
yihaa.....thank you Snurg. It works:beer::), playing playlist Two Steps From Hell collection :D

Mmmmm......please correct me if I am incorrect, this would mean that the system detected the USB but does not automount it, something to do with the fstab file?
 
If you really like the idea of automounting these sticks, you could of course use the automount flag in fstab. I guess the line could look like that:
Code:
/dev/da0s1          /mnt    msdosfs    auto              0       0
 
Shouldn't it show a new directory or <filename>/ for the USB?
No, it should not. Why would it?

The kernel messages you quoted above (the ones that start mostly with umass0 and da0) mean that the kernel discovered a new device, which is of type USB mass storage, and created a new block device called /dev/da0 for it. That is a block device.

On the other hand, your shell process is in the directory called "/" (also known as the root directory), and you are doing a directory listing there (using the "ls" command). You will not see a device by doing a directory listing on the root directory. But the concept you absolutely need to understand is the difference between devices and file systems. As I hinted at above: storage devices (also known as "block devices", commonly called "disks") often contain file systems, but not always. Some block devices don't contain file systems, some contain more than one file system, and sometimes you need multiple block devices for a single file system. With "ls", you traverse the file system, and look at things stored in it: mostly files, often directories, and occasionally other strange things (like device nodes, sockets, pipes, soft links). Go back, find a tutorial, read and understand it, until you have internalized what file systems are.

To make a block device that contains a file system visible in the file system tree, you need to mount it. A few people mentioned that above. One of the problems with doing this is: You need to understand that most block devices today are partitioned into slices or partitions. There is a big difference between /dev/da0 and /dev/da0s1 (or /dev/da0p1). Before you go any further, you should at least understand MBR and GPT partitioning from the user perspective: Block device /dev/da0 (which is one physical device) has probably been segregated contains multiple pieces, which are called partitions or slices. Sometimes, the whole block device contains just one file system. Sometimes, each of the partitions or slices contain a file system. And sometimes it's more complicated.

Here is another complication you need to understand. Your shell was in the "/" (or root) directory. When your USB stick's file system is mounted, it will probably not show up in "/", but probably elsewhere. I think the FreeBSD tradition for removable file systems is "/media", but I'm not 100% sure (haven't read the full documentation just to write this post). There are other traditions; I used to always mount CD-ROMs and USB sticks at "/mnt", and I think that comes from early Linux days. The tradition on MacOS is that they are mounted on "/Volumes". All these are only traditions and conventions; you can mount a device pretty much anywhere you feel like, and you can configure automounted to do the most bizarre things.

The USB contains two folders with mp3 audio files in them. How do I access them?
By "folders", you probably mean directories. That implies that the block device contains at least one file system. Find it (see above: look for partitions/slices), and mount it.

Several people above pointed you at automount. There are various automount systems available. The simplest one is adding the "automount" keyword to /etc/fstab; it is also the one most likely to go wrong. What if tomorrow you insert a different memory stick, which has its partition at /dev/da0s2, and it doesn't get automounted? What if that other thing is already plugged in and using /dev/da0 and /dev/da0s*, and you insert the original USB stick which becomes /dev/da1 (remember, you need to learn how the kernel generates block device names), and then your "automount" rule in /etc/fstab stops working?

And how to detach USB drive safely?
Unmount it before you physically remove it. There is an "umount" command for that purpose (I don't know what happened to the letter "n", but Unix commands famously lose many letters, like "rm" stands for "remove").
 
Back
Top