Other newfs on USB with the real Unix format ?

hi. a simple question. have a da2 dev mounted on freebsd 64 bit.

in the past i formated usb with msdos like this.
Code:
  newfs_msdos  da2
that works.
but i don't want to use msdos or FAT32 anymore on BSD.

but i would like to use a pure unix format to work with my usb flash drives. perhaps xfs format.

what do you recommend for a format. please write the working newfs command for that.

yes , i only use the usb stick on freebsd. no other.

hey i checked out :
Code:
  newfs  da2
with no other instructions and that works.

the usb stick is formatted. not recognised by linux system and not recognised by windows. a good thing.

it works only on BSD. but what do i have here for a file system ?


SM
 
but i would like to use a pure unix format to work with my usb flash drives
There is no "pure" UNIX format, there was/is UFS but every system put their own modifications in, to such an extent that Solaris' UFS, HP-UX UFS and FreeBSD's UFS aren't interchangeable anymore.

hey i checked out : newfs da2 with no other instructions and that works.
it works only on BSD. but what do i have here for a file system ?
FreeBSD's UFS, or more formally, UFS2.

 
Thank you. It is the fastest way. newfs da1 etc.

May i ask for a fs command to "check the usb stick" means "check partition"
Seems reasonable fs has make it and fs can check it. i assume
i found fsck.
is that ok ?
Code:
fsck da1

i checked it out. it works.
newfs ( new partition)
fsck (check in 5 phases)

the fastest formating operating system in the galaxy. orion style
 
May i ask for a fs command to "check the usb stick" means "check partition"
What do you mean "check"? What problem are you trying to solve? Your question (which also exists in a separate thread) is very much an XY problem; you're asking "how do I do X", but you need to first explain what you are trying to accomplish.

  • Are you checking that the flash hardware really works correctly? Easiest thing to do is to read all of it, with "dd if=/dev/da... of=/dev/null bs=...". This will read all the allocated bytes. But note that flash storage usually over-allocated (so a 1 GiB stick has more than 1 GiB of storage, with the excess being for log cleaning, garbage collection, unblocking, and wearout).
  • Are you checking that the hardware is capable of storing and retrieving data? Best test would be to write a known pattern to the device, then read it back. Ideally, without using a file system, since that will not write all bytes accessible over the interface, and the write pattern will be complex. Normal dd won't do it, but it's pretty easy to write a script which does that. Note that this will shorten the life of the device, perhaps drastically (modern consumer QLC has hundreds of writes cycles only).
  • Are you wanting to ask the device itself how it evaluates its health, and whether it knows that failure is imminent? In that case, use SMART to ask it. But few USB flash devices support SMART. If they don't, they may have a vendor-specific interfaces, good luck with those.
  • Are you wondering whether your file system internal metadata is corrupted? For that, fsck is the correct tool. Except it is pretty pointless, since corruption would require either hardware errors (which would be likely found by just reading the flash in the first place, test 1 above), or it would be the effect of software bugs in the file system implementation (exceedingly unlikely with UFS or ZFS).
  • Are you wondering whether your file data is corrupted? In that case, the best thing to do is to use a file system that keeps checksums and validates file data as it is read. In FreeBSD, ZFS is the natural candidate for such a file system.
 
hello Mr.R ,

i got it , all works fine. thank your for your detailed explanation. fsck is really ok for that.

newfs da1
fsck da1
ls -l da1
su root
chown senenmut da1
exit
chmod 0777 da1
ls-l da1
mkdir /media/flash
mount da1 /media/flash
cd /media/flash
mkdir testordner
ls
mkdir testordner2_hello_bsd
umount da1

grab the damn thing and coffee.

Kindly Regards
SM
 
but what do i have here for a file system ?
Well usually with MBR scheme you partition and slice. So this is not the correct way to format a usb stick or any disk.
This method is considered "Dangerously Dedicated".
 
Last edited:
The danger comes especially in face of operating systems that will try to "help" you out on what seem to be apparently-unpartitioned disks.

Windows, for example, will go ahead and write a blank MBR on a disk that doesn't seem to have any sort of partitioning on it already. It does this without even asking nor informing the user of it. Your UFS file system might become trash if it comes in proximity of, and is plugged into, a Windows machine.
 
i have a wireless alarm seeper in the flash drive case.
make an "alarm" when coming 3 Meters in front of a foreign computer system.?
 
newfs da1

With UFS: better to also enable soft updates and soft update journaling, however please be aware that fsck_ffs(8) is completely broken for background fsck (the reporter's words, not mine) in FreeBSD 13.0-RELEASE.

Code:
root@mowa219-gjp4-8570p-freebsd:~ # gpart show da4
=>      34  30375869  da4  GPT  (14G)
        34      2014       - free -  (1.0M)
      2048  30373855    1  freebsd-ufs  (14G)

root@mowa219-gjp4-8570p-freebsd:~ # newfs /dev/da4p1
/dev/da4p1: 14831.0MB (30373848 sectors) block size 32768, fragment size 4096
        using 24 cylinder groups of 625.22MB, 20007 blks, 80128 inodes.
super-block backups (for fsck_ffs -b #) at:
 192, 1280640, 2561088, 3841536, 5121984, 6402432, 7682880, 8963328, 10243776, 11524224, 12804672, 14085120, 15365568, 16646016, 17926464, 19206912, 20487360, 21767808, 23048256, 24328704, 25609152, 26889600,
 28170048, 29450496
root@mowa219-gjp4-8570p-freebsd:~ # tunefs -p /dev/da4p1
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 disabled
tunefs: soft update journaling: (-j)                       disabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         disabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: space to hold for metadata blocks: (-k)            6400
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)                              
root@mowa219-gjp4-8570p-freebsd:~ # tunefs -j enable /dev/da4p1
Using inode 4 in cg 0 for 33554432 byte journal
tunefs: soft updates journaling set
root@mowa219-gjp4-8570p-freebsd:~ # tunefs -n enable /dev/da4p1
tunefs: soft updates remains unchanged as enabled
root@mowa219-gjp4-8570p-freebsd:~ # tunefs -p /dev/da4p1
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       enabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         disabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: space to hold for metadata blocks: (-k)            6400
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)                              
root@mowa219-gjp4-8570p-freebsd:~ # mkdir -p /tmp/stress
root@mowa219-gjp4-8570p-freebsd:~ # mount /dev/da4p1 /tmp/stress
root@mowa219-gjp4-8570p-freebsd:~ # lsblk da4
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
da4              0:147  14G GPT                                               - -
  <FREE>         -:-   1.0M -                                                 - -
  da4p1          2:63   14G freebsd-ufs                             gpt/FreeBSD /tmp/stress
root@mowa219-gjp4-8570p-freebsd:~ # stressdisk run /tmp/stress
2021/10/16 02:44:52 loaded statsfile "stressdisk_stats.json"
2021/10/16 02:44:52
Bytes read:       1138476 MByte (  62.69 MByte/s)
Bytes written:     462840 MByte (  13.24 MByte/s)
Errors:                 0
Elapsed time:  399.871µs

2021/10/16 02:44:52 No check files - generating
2021/10/16 02:44:52 Writing file "/tmp/stress/TST_0000" size 1000000000
2021/10/16 02:45:52
Bytes read:       1138476 MByte (  62.69 MByte/s)
Bytes written:     463432 MByte (  13.23 MByte/s)
Errors:                 0
Elapsed time:  1m0.001338897s

2021/10/16 02:46:29 Writing file "/tmp/stress/TST_0001" size 1000000000
2021/10/16 02:46:52
Bytes read:       1138476 MByte (  62.69 MByte/s)
Bytes written:     463988 MByte (  13.22 MByte/s)
Errors:                 0
Elapsed time:  2m0.002278775s

2021/10/16 02:47:52
Bytes read:       1138476 MByte (  62.69 MByte/s)
Bytes written:     464562 MByte (  13.22 MByte/s)
Errors:                 0
Elapsed time:  3m0.015306996s

2021/10/16 02:48:13 Writing file "/tmp/stress/TST_0002" size 1000000000
…
 
Last edited:
… Windows, for example, will go ahead and write a blank MBR on a disk that doesn't seem to have any sort of partitioning on it already. It does this without even asking …

Please, are you certain that this occurs with recent releases of Windows? (I have not encountered the behaviour.)
 
Please, are you certain that this occurs with recent releases of Windows? (I have not encountered the behaviour.)
I know it happens at least up to Windows XP. I've not been brave enough to risk any foreign-to-Windows storage devices to it after that; (plus I haven't even been near a bare-metal Windows install after Windows 7...)
 
yeah the same thing with "portable programming languages"
many claim to be "fully portable" between some OS.
Things aren't so easy. Every OS has its own rules.
I prefer system connected compiling and not cross-compiling.
It is better for the nerves.
 
I still consult Warrens page for disk setup from time to time.
He has samples of all three disk styles which can be useful.

For USB MBR Data disk I use this:
Code:
gpart create -s mbr da0
gpart add -t freebsd da0
gpart create -s bsd da0s1
gpart add -t freebsd-ufs -a 4k da0s1
newfs -U /dev/da0s1a
 
With the GPT partition scheme it only takes three commands to format a flash disk for data.
Code:
gpart create -s gpt da0
gpart add -t freebsd-ufs da0
newfs -U /dev/da0p1
 
Back
Top