Professional Web Applications Themes

mounting vfat and umask woes - Linux / Unix Administration

I've just got a hold of an external hard-drive and thought I'd use it to backup onto. It connects via USB. I partitioned the disk and decided to use vfat (FAT32 LBA) as the filesystem so I could also plug the device into my WinXP machine if needed[1]. I can mount the thing successfully and read and write from/to it. [troyarmadillo:troy]$ cat /etc/fstab [snip] /dev/sda1 /mnt/backup vfat gid=500,umask=002,exec,nosuid,rw 0 0 Question is - all files I write to it are executable. [troyarmadillo:troy]$ touch /mnt/backup/test [troyarmadillo:troy]$ ls -l /mnt/backup -rwxrwxr-x 1 root troy 0 Oct 19 10:35 /mnt/backup/test* So how do ...

  1. #1

    Default mounting vfat and umask woes

    I've just got a hold of an external hard-drive and thought I'd use it to
    backup onto. It connects via USB. I partitioned the disk and decided
    to use vfat (FAT32 LBA) as the filesystem so I could also plug the
    device into my WinXP machine if needed[1].

    I can mount the thing successfully and read and write from/to it.

    [troyarmadillo:troy]$ cat /etc/fstab
    [snip]
    /dev/sda1 /mnt/backup vfat gid=500,umask=002,exec,nosuid,rw 0 0

    Question is - all files I write to it are executable.

    [troyarmadillo:troy]$ touch /mnt/backup/test
    [troyarmadillo:troy]$ ls -l /mnt/backup
    -rwxrwxr-x 1 root troy 0 Oct 19 10:35 /mnt/backup/test*

    So how do I set up /etc/fstab so that the normal permissions apply? And
    if I copy files there etc, the permissions stay same?

    Is it because it's vfat? I just had a thought that I don't *really*
    need it to be vfat, because I could just run a linux livecd on any
    machine, mount the ext hdd if it was ext3 fs, copy, then reboot. Not
    sure what's best. That'd be only rare occasions it's needed anyway.

    [1] My linux box is RH9 Kernel 2.4x so NTFS is read-only etc - too
    scared to upgrade to 2.6 kernel - maybe this Christmas when I have some
    spare time I'll make a change to Ubuntu.

    --
    Troy Piggins
    Where I live: 27 27 44 S 153 02 28 E
    http://earth.google.com
    Troy Guest

  2. #2

    Default Re: mounting vfat and umask woes

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Troy Piggins wrote: 

    You don't.
     

    Yes. vfat (MSDOS, actually) doesn't support Unix permission bits. So, the
    Linux vfs (virtual file system) layer fakes up permission bits for you. You
    get the defaults that vfat mounts with (see the mount options for vfat,
    doented in mount(8) ). FWIW, you can modify the default permissions (take
    away bits) by varying the *mask= values on the mount options. You use
    umask=002, so you won't get the o+w bit set. To disable the o+x bit as well,
    change that umask to umask=003. But remember, these are global changes; they
    affect all files on the vfat fs.
     

    FWIW, I'd just allocate a big file on the vfat filesystem, and mount it as a
    'loop' minix or ext2 filesystem. Linux will store everything (directories,
    files, metadata, etc) in the vfat file, but each individual file and setting
    will be preserved as it was in Linux. I'd use minix rather than ext2 because
    minix fs is simpler and won't take up as much space. It's also less capable,
    so if you need the extra capabilities of ext2, use the ext2 fs.

    Here's an example:
    /msWin98/c maps to one of my VFAT partitions

    # show contents of C: drive
    /msWin98/c $ ls
    Kodak Pictures avg6db_f.dat epusbdrv sbpci user
    Lotus avg6db_r.dat io.sys scandisk.log videorom.bin
    My Music avg7db_f.dat liprefs.js suhdlog.dat windows
    Program Files avg7qt.dat logo.sys system.1st
    ati config.sys msdos.sys temp
    autoexec.bat epsonreg recycled tlcwin

    # create a file on C drive, format file as a minix fs
    /msWin98/c $ touch Minix.FS
    /msWin98/c $ /sbin/mkfs -t minix ./Minix.FS 100
    64 inodes
    100 blocks
    Firstdatazone=6 (6)
    Zonesize=1024
    Maxsize=268966912

    # mount the file as a new fs using the loop mount
    /msWin98/c $ sudo mount ./Minix.FS /mnt/hd -t minix -o loop
    Password:

    # show that the file is mounted to /mnt/hd
    /msWin98/c $ mount
    [snip]
    /dev/hda1 on /msWin98/c type vfat (rw,umask=0,uid=99,gid=99)
    /dev/hdc1 on /msWin98/d type vfat (rw,umask=0,uid=99,gid=99)
    /dev/hda5 on /msWin98/e type vfat (rw,umask=0,uid=99,gid=99)
    /dev/hda6 on /msWin98/f type vfat (rw,umask=0,uid=99,gid=99)
    /dev/hda7 on /msWin98/g type vfat (rw,umask=0,uid=99,gid=99)
    [snip]
    /msWin98/c/Minix.FS on /mnt/hd type minix (rw,loop=/dev/loop0)

    # show that the file is empty of anything
    /msWin98/c $ ls /mnt/hd

    # create a file in the file
    /msWin98/c $ touch /mnt/hd/abc.def
    /msWin98/c $ ls -l /mnt/hd/abc.def
    -rw-rw---- 1 lpitcher users 0 2005-10-18 23:17 /mnt/hd/abc.def

    # change the permissions on the file in the file, show that they stick
    /msWin98/c $ chmod g+x /mnt/hd/abc.def
    /msWin98/c $ ls -l /mnt/hd/abc.def
    -rw-rwx--- 1 lpitcher users 0 2005-10-18 23:17 /mnt/hd/abc.def

    # more changes that stick
    /msWin98/c $ chmod o+w /mnt/hd/abc.def
    /msWin98/c $ ls -l /mnt/hd/abc.def
    -rw-rwx-w- 1 lpitcher users 0 2005-10-18 23:17 /mnt/hd/abc.def

    # show that the file in the file doesnt show in MSDOS partition at all
    /msWin98/c $ ls
    Kodak Pictures Program Files avg6db_r.dat epsonreg logo.sys
    scandisk.log tlcwin
    Lotus ati avg7db_f.dat epusbdrv msdos.sys
    suhdlog.dat user
    Minix.FS autoexec.bat avg7qt.dat io.sys recycled
    system.1st videorom.bin
    My Music avg6db_f.dat config.sys liprefs.js sbpci temp

    windows
    /msWin98/c $

     


    - --
    Lew Pitcher

    Master Codewright & JOAT-in-training | GPG public key available on request
    Registered Linux User #112576 (http://counter.li.org/)
    Slackware - Because I know what I'm doing.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.7 (GNU/Linux)

    iD8DBQFDVbwmagVFX4UWr64RAuT2AKC5VAArkro79jbRFg6s+E E6vRJVAwCeO9ej
    lH4U/o+kTKHP98/IRJlPelk=
    =ToCW
    -----END PGP SIGNATURE-----
    Lew Guest

  3. #3

    Default Re: mounting vfat and umask woes

    On 19 Oct 2005 00:39:40 GMT, Troy Piggins
    <com> wrote: 
    Change the umask to 111 or 113, and none of the files will be
    executable. Unless you are using Wine, you don't need to execute files
    on a vfat partition. Directories have to be executable, so you might
    use fmask and dmask instead of umask.

    If you store Linux files on a vfat partition there are ways to preserve
    the permissions:
    (1) set up a umsdos file system
    (2) Instead of copying files, use an archiving program such as tar, zip
    or cpio.


    --
    <joeyh> netgod: er, are these 2.2.0 packages 2.0.0pre9 or do you have a
    direct line with the gods?
    <netgod> joeyh: i have the direct line
    Bill Guest

  4. #4

    Default Re: mounting vfat and umask woes

    * Lew Pitcher wrote: 
    >
    > You don't.

    >
    > Yes. vfat (MSDOS, actually) doesn't support Unix permission bits. So, the
    > Linux vfs (virtual file system) layer fakes up permission bits for you. You
    > get the defaults that vfat mounts with (see the mount options for vfat,
    > doented in mount(8) ). FWIW, you can modify the default permissions (take
    > away bits) by varying the *mask= values on the mount options. You use
    > umask=002, so you won't get the o+w bit set. To disable the o+x bit as well,
    > change that umask to umask=003. But remember, these are global changes; they
    > affect all files on the vfat fs.[/ref]

    I suspected as much. Thanks.
     
    >
    > FWIW, I'd just allocate a big file on the vfat filesystem, and mount it as a
    > 'loop' minix or ext2 filesystem. Linux will store everything (directories,
    > files, metadata, etc) in the vfat file, but each individual file and setting
    > will be preserved as it was in Linux. I'd use minix rather than ext2 because
    > minix fs is simpler and won't take up as much space. It's also less capable,
    > so if you need the extra capabilities of ext2, use the ext2 fs.
    >
    > Here's an example:[/ref]
    [snip]

    Wow - thanks for that huge example. I will need some time to absorb it.

    --
    Troy Piggins
    Where I live: 27 27 44 S 153 02 28 E
    http://earth.google.com
    Troy Guest

  5. #5

    Default Re: mounting vfat and umask woes

    on 19 Oct 2005 00:39:40 GMT, Troy Piggins <com> wrote this
    wisdom:
     

    Try changing exec to noexec

    vfat does not have all permissions possible uid,gid etc since M$ doesn't know
    how to do things properly :-)
     

    Yep
     

    --
    Simon.

    'Be Seeing You.
    Who is number one?
    I will not be pushed, filed, stamped, indexed, briefed, de-briefed or numbered.
    Registered Linux User #300464 Machine Id #188886
    Linux Counter - http://counter.li.org/
    Remove the s.p.a.m to reply
    Simon. Guest

  6. #6

    Default Re: mounting vfat and umask woes

    * Simon wrote: 
    >
    > Try changing exec to noexec[/ref]

    Tried it, same problem.
     
    >
    > Yep[/ref]

    No worries - thanks for your input. I've decided to change the
    filesystem to ext3 for one partition and use that to backup the linux
    box directly. I'll mount it as a samba share to backup my WinXP box to.
    If I want to plug directly into a Win machine, I'll use another FAT32
    partition.
     
    >[/ref]


    --
    Troy Piggins
    Where I live: 27 27 44 S 153 02 28 E
    http://earth.google.com
    Troy Guest

Similar Threads

  1. vfat and sbackup
    By mike in forum Ubuntu
    Replies: 2
    Last Post: October 8th, 03:04 AM
  2. contribute dav put umask
    By fletch00 in forum Macromedia Contribute Connection Administrtion
    Replies: 0
    Last Post: May 6th, 07:16 PM
  3. umask
    By koen de wijs in forum FreeBSD
    Replies: 1
    Last Post: February 16th, 04:06 PM
  4. Red Hat9 can not recognise vfat partition in 2nd disk
    By James in forum Linux Setup, Configuration & Administration
    Replies: 2
    Last Post: December 5th, 02:17 AM
  5. ftp umask question
    By Bert Moos in forum Linux / Unix Administration
    Replies: 4
    Last Post: October 25th, 05:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139