Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I am pretty new to linux and have been asked to write a script that will check all filesystems to see if they are read-only. I have come up ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    3

    Help with script to check if a filesystem is read-only

    Hi,

    I am pretty new to linux and have been asked to write a script that will check all filesystems to see if they are read-only.

    I have come up with ...

    df -h > /tmp/mount.lst
    awk '{print $6}' /tmp/mount.lst > /tmp/mounted_systems.lst

    This gives me ..

    Mounted
    /
    /boot
    /dev/shm
    /proc

    So now I have ..

    How do I automatically get rid of the 'Mounted' header in my /tmp/mounted_systems.lst file ?

    Also, I don't want to check the /proc filesystem, so how do I remove that within the script too.

    Then I will run ...

    while read dir
    do
    touch $dir/read_only_test
    done < /tmp/mounted_systems.lst

    If the filesystem is read only, I want that filesystem name to be listed into another file.

    Apologies if I am asking too much !

    Cheers

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    instead of creating a test file, the information you are looking for would be found in just mount command

  3. #3
    Just Joined!
    Join Date
    Jul 2010
    Posts
    3
    Ahh, better !
    What error would the mount command give if a file system was read only ?

    Cheers

  4. #4
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    mount command shouldn't throw error, it should only list information about mounted filesystems, I believe the keys you would be looking for would be rw, for writeable, and ro for readonly

Posting Permissions

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