PDA

View Full Version : How do I a USB flashdrive so I can use chmod?


Quaxo
06-29-2008, 05:04 PM
Hi!

I have a little problem with my USB flashdrive. This is what I have done:

1. Connect the USB flashdrive
2. Create new directory: mkdir /mnt/flash
3. Create new filesystem: newfs sd0c
4. Mount the USB flashdrive: mount /dev/sd0i /mnt/flash
5. ...do the work...
6. Leave the directory /mnt/flash (if needed)
7. Unmount the USB flashdrive: umount /mnt/flash

It works good (at step 3 I can instead type "newfs_msdos -F 32 sd0c" if I want compability with Windows).

But how do I mount the flashdrive so I can set the files permissions, user ID, group ID etc.?


Thanks in advance
/Quaxo

Quaxo
06-29-2008, 06:29 PM
Never mind, I found the problem.

In step 4 I must use "mount_ffs /dev/sd0i /mnt/flash" (I know I tryed that before and then got some errors, it must have been a different format at that time because it works great now).


Take care
/Quaxo

BSDfan666
06-29-2008, 06:44 PM
If the file system is FFS or ext2(3) you can use file permissions, but it's impossible for FAT as it has no concept of Unix permissions.

This has been said in the past, FAT was designed for a single-user operating system.. ;)

EDIT: If you want to restrict access to files on ANY portable device, a better method would be encryption.. via OpenSSL for instance.

18Googol2
06-29-2008, 06:46 PM
Never mind, I found the problem.

In step 4 I must use "mount_ffs /dev/sd0i /mnt/flash" (I know I tryed that before and then got some errors, it must have been a different format at that time because it works great now).


Take care
/Quaxo

You sure you found the problem? :D

By default the mount command attempts to mount ufs (unix fs), and the ufs is also known as ffs ;)

And yes I can confirm "mount" without ffs works fine with my usb stick. If the file is set perm 600, except the owner, nobody can read it.

BSDfan666
06-29-2008, 06:49 PM
And yes I can confirm "mount" without ffs works fine with my usb stick. If the file is set perm 600, except the owner, nobody can read it.Right, but that doesn't stop someone from gaining access to the file if they steal the drive... ;)

All they have to do is use their root account... :cool:

J65nko
06-29-2008, 07:04 PM
Compared with an Unix or Unix-like filesytem, a FAT filesystem has limited facilities to administer file access, and it is totally misses the concept of users and groups. So these things have to be emulated.

See the mount_msdos man page for the defaults and how to override these defaults.

18Googol2
06-29-2008, 07:19 PM
Right, but that doesn't stop someone from gaining access to the file if they steal the drive... ;)

All they have to do is use their root account... :cool:

It doesnt make any sense

Probably you meant to say the drive should be formatted as ffs instead of ufs to prevent the read permission from bad guy?

1. ufs and ffs are identical.

2. Once he got the drive, mounting as ufs or ffs is his choice, you have no control here.

3. Also, once the bad guy physically possesses the drive, I dont think ufs, ffs or any fs can stop him from accessing the drive, as long as it is not encrypted, corrupted.

My 2 cents

TerryP
06-29-2008, 07:52 PM
Using NTFS over FAT32 was actually the greatest reason to upgrade to Windows NT in the Microsoft world.


For whatever portion that unix like systems play in the rest of the file system world, BSD has lived happily for decades ;-)

BSDfan666
06-29-2008, 08:37 PM
It doesnt make any sense

Probably you meant to say the drive should be formatted as ffs instead of ufs to prevent the read permission from bad guy?What are you talking about? I was replying to your post.

You claimed, that setting chmod 600 would stop someone from accessing your file.. that's incorrect, if someone plugged your drive in their BSD computer they could mount the partition and use "their local root account" to read the file.

;) Encryption would be the only option.. please re-read my initial posts, I was very clear.

3. Also, once the bad guy physically possesses the drive, I dont think ufs, ffs or any fs can stop him from accessing the drive, as long as it is not encrypted, corrupted.That's exactly what I said :rolleyes:, I thought you were implying otherwise.

jggimi
06-29-2008, 08:41 PM
Quaxo's original question was on usability.

The easiest way I've found to manage USB sticks is to start with fdisk(8). This is because when you "format" sticks on Windows, you get an MBR. That MBR does not have an A6 partition.

This example dedicates a stick to OpenBSD, and mounts it at /mnt:



Insert stick. Assuming "sd0" assigned, change commands below if a different SCSI device number assigned.
# fdisk -iy sd0
# printf "a\n\n\n\n\nw\nq\n\n" | disklabel -E sd0
# newfs sd0a
# mount -o softdep,noatime /dev/sd0a /mnt

18Googol2
06-30-2008, 07:49 AM
BSDfan666: Haha it was misunderstanding here. I was referring to one local machine. It is all sorted out anyways, cheers :D

For whatever portion that unix like systems play in the rest of the file system world, BSD has lived happily for decades ;-)

This reminds me of the mini disscussion we had at uni. In term of permission control, any *nix file system is not superior at all, the NTFS, turns out to be the best. It is cumbersome to manage the file/dir permission under *nix mixing with multiple users/groups. What if I need to allow some more users to be able to read my file? Creating a new group which contains me and other users for permission attr of just one file? Now its not one file but a dozen of files and different users? What if I need to give read access to a group of users, but exclude one guy, I know he is bad guy, so no access whatsoever to my file. What should I do?

It is gonna be a huge mess!

Dont ever think to change it, it is too popular and too old

richardpl
06-30-2008, 08:19 AM
This reminds me of the mini disscussion we had at uni. In term of permission control, any *nix file system is not superior at all, the NTFS, turns out to be the best. It is cumbersome to manage the file/dir permission under *nix mixing with multiple users/groups. What if I need to allow some more users to be able to read my file? Creating a new group which contains me and other users for permission attr of just one file? Now its not one file but a dozen of files and different users? What if I need to give read access to a group of users, but exclude one guy, I know he is bad guy, so no access whatsoever to my file. What should I do?
Some of *nix have alternatives for that, but I will not spam OpenBSD subforum.
Just for the record this is not file system XYZ fault.

ephemera
06-30-2008, 11:57 AM
This reminds me of the mini disscussion we had at uni. In term of permission control, any *nix file system is not superior at all, the NTFS, turns out to be the best. It is cumbersome to manage the file/dir permission under *nix mixing with multiple users/groups. What if I need to allow some more users to be able to read my file? Creating a new group which contains me and other users for permission attr of just one file? Now its not one file but a dozen of files and different users? What if I need to give read access to a group of users, but exclude one guy, I know he is bad guy, so no access whatsoever to my file. What should I do?

It is gonna be a huge mess!

Dont ever think to change it, it is too popular and too old
http://en.wikipedia.org/wiki/Access_control_list

http://www.freebsd.org/cgi/man.cgi?query=acl&apropos=0&sektion=0&manpath=FreeBSD+7.0-RELEASE&format=html

http://opensolaris.org/os/community/zfs/