DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 5th September 2017
handy handy is offline
Port Guard
 
Join Date: Aug 2017
Posts: 17
Default How-to display the filesystems your storage media are using?

Hi all,

I have searched & read, & searched & read, & I just haven't been able to stumble on a command that I can use to display which file systems my storage media are using.

I have drives formatted to use: FFS; NTFS; exFAT & fat32 at this stage.

I'd really like to have a command that I can use to identify which filesystem is being used by a particular drive (particularly for the NTFS & the exFAT partitions).

Surely there is a command (or a GUI application if I must), something, anything, that includes this data when used would be very helpful to me? If its in alphanumeric code I can cope! lol

Thanks in advance for your time.
Reply With Quote
  #2   (View Single Post)  
Old 5th September 2017
Maxnix's Avatar
Maxnix Maxnix is offline
Port Guard
 
Join Date: Feb 2016
Posts: 23
Default

You can use
Code:
file -s /dev/<your_drive>
to identify the filesystem type of a device.

HTH
__________________
The world doesn't live off jam and fancy perfumes - it lives off bread and meat and potatoes. Nothing changes. All the big fancy stuff is sloppy stuff that crashes. I don't need dancing baloney - I need stuff that works. -- Theo de Raadt
Reply With Quote
  #3   (View Single Post)  
Old 5th September 2017
jb_daefo jb_daefo is offline
Spam Deminer
 
Join Date: May 2008
Posts: 286
Default

disktype /dev/ada0 [that is the FreeBSD way I just found, adjust for OpenBSD? ]
.............
the post above bested me by three minutes...
__________________
FreeBSD 12.0-CURRENT
Reply With Quote
  #4   (View Single Post)  
Old 5th September 2017
handy handy is offline
Port Guard
 
Join Date: Aug 2017
Posts: 17
Default

Thanks for your replies.

@Maxnix I got a response from using the command that you offered, but it unfortunately isn't very helpful to me:

Code:
handy ~ $ doas file -s /dev/sd2c
/dev/sd2c: x86 boot sector; partition 1: ID=0xee, starthead 0, startsector 1, 4294967295 sectors
It tells me that it is GPT (ID=0xee) & the sector info', but unfortunately not the filesystem that the drive was formatted with.

@jb_daefo Unfortunately the disktype command is not on my system & isn't available in the binary repo. Must not be a goody in the OpenBSD bag...

Thanks anyway guys.
Reply With Quote
  #5   (View Single Post)  
Old 5th September 2017
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,884
Default

/dev/sd2c is not a filesystem. It is the physical drive sd2. Try again with a disklabel partition rather than the synthetic "c" partition.
Reply With Quote
  #6   (View Single Post)  
Old 5th September 2017
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,884
Default

If file(1) doesn't help, try mount(8). If you issue it as $ mount without options, all mounted filesystems are listed, along with filesystem types.
Reply With Quote
  #7   (View Single Post)  
Old 5th September 2017
handy handy is offline
Port Guard
 
Join Date: Aug 2017
Posts: 17
Default

@jggimi I tried file in every variation - sd2 sd2c sd2i it didn't spit out anything useful to me I'm sorry to say.

I'd already previously tried mount, & also installed facter, the best I can get out of them is that it is fusefs or fuse. As this drive is formatted to exFAT.

It looks like there may be something in Perl that "may" do the job. I just have to learn how to get it to run, its called p5-filesys-diskSpace.

by the way, thanks for your input.
Reply With Quote
  #8   (View Single Post)  
Old 5th September 2017
gustaf gustaf is offline
Port Guard
 
Join Date: Dec 2016
Posts: 31
Default

To find the names of all the devices attached to your computer (mounted or not), run:

Code:
$ sysctl hw.disknames

hw.disknames=sd0:[duid],sd1:
The output shows that there are two attached drives: sd0 and sd1.

Several commands are available for identifying the file systems on the drives.


1. You can run disklabel(8) with or without mounting the drive:

Code:
$ disklabel sd0

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  a:          2097152               64  4.2BSD   2048 16384     1 # /
  b:          8641784          2097216    swap                    # none
  c:        976773168                0  unused                    
  d:          8388576         10739008  4.2BSD   2048 16384     1 # /tmp
  e:         24623584         19127584  4.2BSD   2048 16384     1 # /var
  f:          4194304         43751168  4.2BSD   2048 16384     1 # /usr
  g:          2097152         47945472  4.2BSD   2048 16384     1 # /usr/X11R6
  h:         20971520         50042624  4.2BSD   2048 16384     1 # /usr/local
  i:          4194304         71014144  4.2BSD   2048 16384     1 # /usr/src
  j:          4194304         75208448  4.2BSD   2048 16384     1 # /usr/obj
  k:        629145600         79402752  4.2BSD   4096 32768     1 # /home
Code:
$ disklabel sd1

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:           249856                0  unused                    
  i:           249823               32   MSDOS
The lower section of the output lists the file systems on the drive.


2. mount(8) will produce a list of the file systems on all mounted partitions:

Code:
$ mount

/dev/sd0a on / type ffs (local)
/dev/sd0k on /home type ffs (local...)
/dev/sd0d on /tmp type ffs (local...
/dev/sd0f on /usr type ffs (local...
/dev/sd0g on /usr/X11R6 type ffs (local...)
/dev/sd0h on /usr/local type ffs (local...)
/dev/sd0j on /usr/obj type ffs (local...)
/dev/sd0i on /usr/src type ffs (local...)
/dev/sd0e on /var type ffs (local...)
/dev/sd1i on /home/gustaf/mount type msdos (local...)
"4.2BSD" is FFS and "MSDOS" refers to a FAT file system.


3. fdisk(8) may give some further information about the file system:

Code:
$ fdisk sd1

Disk: sd1       geometry: 15/255/63 [249856 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
*0: 06      0   0  33 -     15 140  60 [          32:      249823 ] FAT16B      
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
The MSDOS partition on /dev/sd1 is a FAT16B file system.

None of these commands requires doas(1).
See http://www.daemonforums.org//showthread.php?p=62295.

If you can post the output of: sysctl hw.disknames, disklabel, mount, and fdisk, we might be able to provide some more insight.

Last edited by gustaf; 6th September 2017 at 03:19 AM. Reason: Noted correction re doas.
Reply With Quote
  #9   (View Single Post)  
Old 6th September 2017
LeFrettchen's Avatar
LeFrettchen LeFrettchen is offline
Marveled user
 
Join Date: Aug 2012
Location: Bronvaux, France
Posts: 245
Default

Quote:
Originally Posted by gustaf View Post
3. fdisk(8) may give some further information about the file system (...)
Yep, since fdisk(8) indicates the partition identifiers, it's the best tool IMO.
__________________
The secret of wisdom is not wisdom itself, it's the road that leads us there.
Reply With Quote
Old 6th September 2017
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,884
Default

Quote:
Originally Posted by gustaf View Post
None of these commands requires doas(1).
Not quite. This is true only if the user is a member of the operator group
Code:
$ ls -l /dev/rsd0c
crw-r-----  1 root  operator   13,   2 Sep  2 06:45 /dev/rsd0c
Adding a user to operator has security implications - such as the ability to read any disk sector.
Reply With Quote
Old 6th September 2017
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 756
Default

Though it may not normally be the case, one should keep in mind that the filesystem info in a disklabel, as well as the in a partition table, can be wrong. You can edit these yourself and change them to anything you like.
Reply With Quote
Old 6th September 2017
handy handy is offline
Port Guard
 
Join Date: Aug 2017
Posts: 17
Default

@gustaf Thanks for your reply. I'll post a section out of my ~/.bashrc so you can see what commands I have been using:

Code:
#==============================================================================
## This section is all to do with (u)mounting external media (including exFAT):
#==============================================================================

## Check names (sd0, cd0, sd1, etc) of existing storage disks on system:

alias dnames="sysctl hw.disknames"

## Identify the exact name of a particular storage media:

alias pnames1="doas disklabel sd1"
alias pnames2="doas disklabel sd2"
alias pnames3="doas disklabel sd3"

## Mount USB exFAT storage media (sd1?) learned from the above disklabel command
## & choosing the correct mount point alias(s) below.

alias mexfat1="doas mount.exfat /dev/sd1c /mnt/lil.1"
alias mexfat2="doas mount.exfat /dev/sd2c /mnt/lil.2"
alias mexfat3="doas mount.exfat /dev/sd3c /mnt/lil.3"

## Mount USB exFAT sd?i storage media:

alias big1="doas mount.exfat /dev/sd1i /mnt/big.1"
alias big2="doas mount.exfat /dev/sd2i /mnt/big.2"
alias big3="doas mount.exfat /dev/sd3i /mnt/big.3"

## Unmount the flash filesystem using the following command:
## (The "umount" command works for all supported filesystems I believe.)

alias ubig1="doas umount /mnt/big.1"
alias ubig2="doas umount /mnt/big.2"
alias ubig3="doas umount /mnt/big.3"

alias ulil1="doas umount /mnt/lil.1"
alias ulil2="doas umount /mnt/lil.2"
alias ulil3="doas umount /mnt/lil.3"

#========================================================
You will notice that it is somewhat cumbersome, as I am testing with three different exFAT USB drives at the moment & have aliases to help me use them in a variety of combinations. Two are notebook drives (lil.1 & lil.2) & one is a 3.5" drive (big.1).

I'll eventually get this stuff refined to the point that I'll likely make a bash script that has a menu of choices for me to easily make the appropriate selection from.

Handling these three drives this way in my skinny Openbox/Worker file manager based system is somewhat more cumbersome than it was/is when I use Linux. Though, as I said, I will refine it as I learn more about OpenBSD, & I'm satisfied enough at this point to continue wanting to learn how to make said refinements & use OpenBSD as my day to day desktop OS.

@gustaf re. your questions, at this point, it is likely important to note that these three drives are all USB external using the exFAT filesystem.

It seems to me that using fuse is making it even harder than usual to identify filesystems.

Code:
handy ~ $ sysctl hw.disknames
hw.disknames=sd0:3c8d8d122bd84300,cd0:,sd1:
Code:
handy ~ $ doas disklabel sd1c
# /dev/rsd1c:
type: SCSI
disk: SCSI disk
label: Elements 10B8   
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 121597
total sectors: 1953458176
boundstart: 0
boundend: 1953458176
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize   cpg]
  c:       1953458176                0  unused
Code:
handy ~ $ mount
/dev/sd0a on / type ffs (local, noatime, softdep)
/dev/sd0k on /home type ffs (local, noatime, nodev, nosuid, softdep)
/dev/sd0d on /tmp type ffs (local, noatime, nodev, nosuid, softdep)
/dev/sd0f on /usr type ffs (local, noatime, nodev, softdep)
/dev/sd0g on /usr/X11R6 type ffs (local, noatime, nodev, softdep)
/dev/sd0h on /usr/local type ffs (local, noatime, nodev, wxallowed, softdep)
/dev/sd0j on /usr/obj type ffs (local, noatime, nodev, nosuid, softdep)
/dev/sd0i on /usr/src type ffs (local, noatime, nodev, nosuid, softdep)
/dev/sd0e on /var type ffs (local, noatime, nodev, nosuid, softdep)
fusefs on /mnt/lil.1 type fuse (local)
Code:
handy ~ $ doas fdisk sd1 
Disk: sd1       geometry: 121597/255/63 [1953458176 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused      
 3: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
I'm not particularly confident that there is a much in the way of useful info' in the above. But, thanks for your time anyway.

[edit:] I just checked my mail & pulled the following section from it:

Code:
Checking subsystem status:

disks:
Filesystem  1K-blocks      Used     Avail Capacity iused   ifree  %iused  Mounted on
/dev/sd0a     1028878     57564    919872     6%    1897  154005     1%   /
/dev/sd0k   312080952  50953216 245523692    17%   44746 19695924     0%   /home
/dev/sd0d     4125390        58   3919064     0%      20  545642     0%   /tmp
/dev/sd0f     2061054    358610   1599392    18%   12758  273064     4%   /usr
/dev/sd0g     1028878    180874    796562    19%    9235  146667     6%   /usr/X11R6
/dev/sd0h    10318462   2738918   7063622    28%   78180 1247002     6%   /usr/local
/dev/sd0j     2061054         2   1958000     0%       1  285821     0%   /usr/obj
/dev/sd0i     2061054         4   1957998     0%       2  285820     0%   /usr/src
/dev/sd0e    61623770     19526  58523056     0%    1699 7871451     0%   /var
fusefs      976762496 900492544  76269952    92% 7034864  595859    92%   /mnt/lil.1
fusefs      976729088 962271616  14457472    99% 7517513  112949    99%   /mnt/lil.2
fusefs      2930265088 2366961280 563303808    81% 18491185 4400811    81%   /mnt/big.3
fusefs      2930265088 2366961280 563303808    81% 18491185 4400811    81%   /mnt/big.3

Last edited by handy; 6th September 2017 at 11:28 AM. Reason: create more clarity (hopefully)
Reply With Quote
Old 7th September 2017
gustaf gustaf is offline
Port Guard
 
Join Date: Dec 2016
Posts: 31
Default

Quote:
It seems to me that using fuse is making it even harder than usual to identify filesystems.
I don't use fuse, but it's been on my (very long) list of things to learn, so I installed sysutils/exfat-fuse and did some research.

I don't think fuse is the root cause of your file system identification problem.

Here is what I see:
  • Partition "i" didn't show up when you ran disklabel sd1c.
  • All partitions were reported as unused when you ran fdisk sd1.

This suggests to me that the real reason these drives are not being identified is that the exFAT file system is not natively supported in OpenBSD. The currently-supported file systems are given in mount(2).

disklabel(8) and fdisk(8) should reveal the file system types even if the disks are not mounted.

I ran disklabel(8) and fdisk(8) on an HFS+ drive, with the same result: partition "i" didn't show up, and all partitions were reported as unused. HFS+ is another unsupported format.

The commands which I suggested are all standard tools for identifying file systems. I can confirm from experience that they will correctly identify FFS, NTFS, and FAT32 disks if the drives are partitioned and formatted properly. These three file systems are natively supported on OpenBSD.

With regard to the exFAT disks, it seems like you already have a way to identify these disks, and that is mounting them with the mount.exfat command.

Is there something else you are trying to accomplish?

Last edited by gustaf; 9th September 2017 at 05:59 AM. Reason: typo
Reply With Quote
Old 7th September 2017
handy handy is offline
Port Guard
 
Join Date: Aug 2017
Posts: 17
Default

@gustaf Thanks very much for your reply (& the time that you have spent investigating this problem).

Overall, it looks like you have correctly summarized the situation re. exFAT & OpenBSD.

Re. the missing "i": As I've previously mentioned I have 3 external USB drives, 2 are notebook drives (without the "i") & one is a (so called) 3.5" drive - the 3.5" drive does have the "i". I don't know why this difference exists? I may have formatted the 3.5" drive to exFAT using Win7. The other two drives were definitely formatted to exFAT via a Linux distro.

Re. your question "is there something else that I'm trying to accomplish?"

I think that I've been looking for a simple, OpenBSD, one step filesystem ID process. The reason being, that from time to time I have various externally mounted filesystems that I want to access (one way or another). So, being still in the very early days of my OpenBSD experience, I'm trying to discover what is & is not possible - create new procedures & refine my use of this OS, so that it becomes my Linux, general purpose, desktop replacement. This is an ongoing process that I'm sure you understand (one way, or another).

The only reason that I'm using exFAT, is that I need a read/write filesystem that can be accessed via OpenBSD; Linux & Win7. exFAT (at this early stage) seems to do this reasonably well, with little fuss - time will tell...

Last edited by handy; 7th September 2017 at 11:39 PM. Reason: attempt to bring more clarity
Reply With Quote
Old 8th September 2017
sacerdos_daemonis's Avatar
sacerdos_daemonis sacerdos_daemonis is offline
Real Name: Will forever be a secret.
Package Pilot
 
Join Date: Sep 2014
Location: Currently residing in China.
Posts: 181
Default

Quote:
Originally Posted by handy View Post
The only reason that I'm using exFAT, is that I need a read/write filesystem that can be accessed via OpenBSD; Linux & Win7. exFAT (at this early stage) seems to do this reasonably well, with little fuss - time will tell...
Why not use FAT32? The only drawback is files are limited to 4GB. Otherwise, it is supported by every operating system, which is what you want.
__________________
I am always right.
I thought I was wrong once, but I was mistaken.
Reply With Quote
Old 8th September 2017
handy handy is offline
Port Guard
 
Join Date: Aug 2017
Posts: 17
Default

@sacerdos_daemonis Thanks for your reply.

Unfortunately I do need to be able to access files larger than 4GB, so unless there is a way that I don't know about yet, it looks like exFAT is it.

Thank you Microsoft... lol! It isn't too often that I've said that in my computing life.
Reply With Quote
Old 8th September 2017
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,884
Default

exFAT "universality" is a little odd, because Windows -- at least on Windows 7, where I just tested it -- does not require an MBR/GPT, but it does require one for FAT.

If you insert a flash drive with zeroes in the opening sectors, and format it exFAT, Windows 7 does not place an MBR on the drive. (Mounting that filesystem on OpenBSD requires using partition "c", since there is no partition table on the drive.)

If an MBR/GPT is on the drive, Windows will use an NTFS partition type for an exFAT partition. Drives with an MBR/GPT partition table and no on-disk disklabel will be scanned by the OpenBSD kernel on attachment. This NTFS partition type will be recognized as a foreign file system and assigned a virtual disklabel, starting with "i". However a mount attempt with mount_ntfs(8) will fail, as it is not an NTFS filesystem.
Reply With Quote
Old 8th September 2017
handy handy is offline
Port Guard
 
Join Date: Aug 2017
Posts: 17
Default

@jiggimi It certainly looks like 2 of my exFAT drives were made differently than the other one - 2x i ; 1x c... ? As I mentioned earlier, I think that the odd man out was formatted on Win7.

Thanks for your post, I found it to be very interesting.
Reply With Quote
Old 8th September 2017
jggimi's Avatar
jggimi jggimi is online now
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 5,884
Default

I'm wrong, having done a little more experimenting with a flash drive and with a USB attached hard drive. Whether an MBR/GPT is created when formatting a zeroed drive will depend on whether the drive is recognized as removable. A zeroed removable drive will not be given an MBR during formatting, whether FAT32 or exFAT. And, a removable drive with an MBR will only have the the first partition assigned to a volume (drive letter), other partitions are ignored.

At least, that's what I've seen in half an hour of experimenting.

Last edited by jggimi; 8th September 2017 at 11:32 AM. Reason: clarity
Reply With Quote
Old 9th September 2017
gustaf gustaf is offline
Port Guard
 
Join Date: Dec 2016
Posts: 31
Default

Quote:
Originally Posted by handy View Post
I think that I've been looking for a simple, OpenBSD, one step filesystem ID process...
This is a hard problem to solve. There simply isn't a single, easy-to-use command for identifying unsupported file systems in OpenBSD. The Perl module you refered to in a previous post (sysutils/p5-Filesys-DiskSpace) might help, but if that doesn't work, and you still want a one-step OpenBSD solution, the options probably involve writing your own command.

Earlier today, I realized that there is a relatively simple alternative that makes use of ready-made tools: disklabel(8), fdisk(8), mount.exfat, and a label maker or peel-and-stick labels.

Could you put printed or handwritten labels on your external drives (after confirming the file system with the tools listed above, if necessary)?

You would only have to do this once. After that, you could readily identify the file system by looking at the drive.
Reply With Quote
Reply

Tags
filesystems, identify

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
non-journaled filesystems on liveusb media daemonfowl OpenBSD Security 11 25th February 2012 04:30 AM
Sterilization of downloaded/mounted media/drives/filesystems jackthechemist OpenBSD Security 5 27th December 2010 07:05 PM
Large MFS filesystems jggimi Guides 2 26th October 2008 05:17 PM
Need help with mounting filesystems Mr-Biscuit FreeBSD General 2 11th September 2008 08:29 AM
webmin filesystems error smooth187 FreeBSD General 1 29th July 2008 05:29 PM


All times are GMT. The time now is 09:37 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick