Author Topic: Set all media to -noatime?  (Read 4086 times)

Offline mikkl

  • Hero Member
  • *****
  • Posts: 872
Set all media to -noatime?
« on: May 02, 2010, 05:04:59 AM »
Is there a way to set all media to -noatime?

I have used fstab to do this for / and ~ and would like to do the same for file systems automagically mounted to /media.  Is this something I could set at the /media level that would propagate down to the mounted devices, for example?

TIA,

mikkl

Offline marian

  • Hero Member
  • *****
  • Posts: 608
  • Hi
Re: Set all media to -noatime?
« Reply #1 on: May 02, 2010, 12:14:04 PM »
Probably KDE is responsible for mounting usb drives but I don't have a clue where to set noatime and similar settings for them.

Have you tried fstab?
Freedom is the only way!

Offline PcPrisoner

  • Full Member
  • ***
  • Posts: 215
Re: Set all media to -noatime?
« Reply #2 on: May 05, 2010, 12:54:32 AM »
Can an "fstab" kernel parameter (cheet code) in grub/lilo do it?

Found this, FWIW
http://bb.linuxsampler.org/viewtopic.php?f=7&t=61

Offline marian

  • Hero Member
  • *****
  • Posts: 608
  • Hi
Re: Set all media to -noatime?
« Reply #3 on: May 05, 2010, 02:50:55 AM »
Maybe relatime is a better option than noatime. At least for /.   (http://kerneltrap.org/node/14148)
I've tried to add my external usb drive to fstab but KDE (hal) was unable to mount it. But with mount command it worked.
Freedom is the only way!

Offline mikkl

  • Hero Member
  • *****
  • Posts: 872
Re: Set all media to -noatime?
« Reply #4 on: May 05, 2010, 05:29:33 AM »
Maybe relatime is a better option than noatime. At least for /.   (http://kerneltrap.org/node/14148)
I've tried to add my external usb drive to fstab but KDE (hal) was unable to mount it. But with mount command it worked.


One of the reasons I want to set -noatime is that I want to minimize file system writes on the SSD of my eeepc900.  Since there is no software that I use which requires this feature, I figure it is not worth trying to harm my SSD.

mikkl

Offline Roc4fun

  • Hero Member
  • *****
  • Posts: 620
  • The life so short, the craft so long to learn
Re: Set all media to -noatime?
« Reply #5 on: May 05, 2010, 08:38:09 AM »
Hi mikkl,  Maybe I'm missing the boat...

I have set -noatime for my SSD in fstab, it sounds like you've seen the same guides I have ;-)

Is your concern that devices mounted in /media will cause writes to the /root drive as well as to the mounted device?

I guess it's something I hadn't thought of.

Dave

Offline mikkl

  • Hero Member
  • *****
  • Posts: 872
Re: Set all media to -noatime?
« Reply #6 on: May 05, 2010, 05:52:42 PM »
No, I was just thinking that if -noatime is the large performance benefit reported by the various tests (>20% in most of the tests I have seen), I would like to extend this benefit to all of the drives that I mount.  For example, I have several partitions that are mounted via HAL (...I think it's HAL...) to /media and do not use fstab.  This is the same approach as kde3 and I am comfortable with this, particularly as I stumbled across a setting that has my mp3 partition always mounted without me having to do anything special.  I would like to have these partitions also see the benefits of -noatime, if they do not have them already.

Hopefully that makes sense,

mikkl

Online Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11549
  • ----IOFLU----
Re: Set all media to -noatime?
« Reply #7 on: May 05, 2010, 05:59:51 PM »
Maybe relatime is a better option than noatime. At least for /.   (http://kerneltrap.org/node/14148)
I've tried to add my external usb drive to fstab but KDE (hal) was unable to mount it. But with mount command it worked.


What does your fstab line look like for the partitions on this drive? I have 15 partitions on one external drive, and 11 on another, and I can mount any of the ones I want, automatically with HAL, or user mountable for those I don't use that often.
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline mikkl

  • Hero Member
  • *****
  • Posts: 872
Re: Set all media to -noatime?
« Reply #8 on: May 05, 2010, 08:03:55 PM »
fstab is silent on these partitions:

# Entry for /dev/sdb5 :
UUID=1b82960d-b6bf-4d1a-9328-99a64d68e158 / ext4 defaults,noatime 1 1
# Entry for /dev/sdb1 :
UUID=73c5c092-e2ba-48fe-9725-62db78883871 /home ext4 defaults,noatime 1 2
none /proc proc defaults 0 0
# Entry for /dev/sdb6 :
UUID=f71e5881-0961-48e4-96e4-1c88f3952b43 swap swap defaults 0 0
none /dev/pts devpts defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0


Offline marian

  • Hero Member
  • *****
  • Posts: 608
  • Hi
Re: Set all media to -noatime?
« Reply #9 on: May 06, 2010, 12:56:07 AM »
Code: [Select]
# Entry for /dev/sda1 :
UUID=0739b9d2-46f7-4c1a-a45a-32501e7fa1a6 / ext4 relatime 1 1
none /dev/pts devpts defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
# Entry for /dev/sda6 :
UUID=fa35992e-aa06-435f-a0f4-e2ef04b5f288 /mnt/data ext4 defaults,noatime,nodiratime 1 2
# Entry for /dev/sda7 :
UUID=0e8bc027-6620-4dc6-bbcc-10826057af33 /mnt/media ext4 defaults,noatime,nodiratime 1 2
# Entry for /dev/sda5 :
UUID=b15b0970-0d86-49af-a53d-d48b4047c697 /mnt/system2 ext4 defaults,noatime 1 2
none /proc proc defaults 0 0
# Entry for /dev/sda8 :
UUID=949b880c-ed9a-487e-bd01-56fb6e9d8c2c swap swap defaults 0 0

UUID=2511420c-b60e-4ede-91b7-c2a2cb487b79 /media/Data ext4 defaults,noatime 1 2

The last line is for my external partition named Data. This line was added manually by me.
When I click to mount it by "Devices recently plugged in:" it only tells that was unable to mount it.

mount -a mounts this partition with noatime.
If I delete that line the mount is just one click but of course with defaults.
Freedom is the only way!

Online Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11549
  • ----IOFLU----
Re: Set all media to -noatime?
« Reply #10 on: May 06, 2010, 01:01:13 AM »
fstab is silent on these partitions:

# Entry for /dev/sdb5 :
UUID=1b82960d-b6bf-4d1a-9328-99a64d68e158 / ext4 defaults,noatime 1 1
# Entry for /dev/sdb1 :
UUID=73c5c092-e2ba-48fe-9725-62db78883871 /home ext4 defaults,noatime 1 2
none /proc proc defaults 0 0
# Entry for /dev/sdb6 :
UUID=f71e5881-0961-48e4-96e4-1c88f3952b43 swap swap defaults 0 0
none /dev/pts devpts defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0


While UUID numbers are an excellent way to get proper partitions mounted with the new kernels that see all drives as /dev/sd(x), and all partitions as /dev/sd(xn), I find that labeling each partition (which works the same way as UUID numbers) is easier for me to keep track of what's on each, and for writing mount lines in /etc/fstab. If one is using any ext formatted partition, the command to label a partition is as follows; (you must do this as root)

[root@localhost ~]# tune2fs -L <label> /dev/sd<whatever>               <Enter>

Replace <label> with the name by which the partition will be known, and <whatever> with the proper letter and number for the partition being labeled. Each label must be unique for the system being run. No two partitions can have the same label on the same machine. Each label I use has a direct relationship with the OS installed on it, the mount point I use, it's intended purpose, or the drive it resides on; usually a number indicating the drive size. Sometimes it's a combination. Labels on ext file systems are limited to 16 characters.

From cfdisk, the labels of the partitions on my 1 TB external drive, on which the MiniMe 2010 installation I'm currently running resides;

Code: [Select]
Name             Flags           Part Type       FS Type                [Label]              Size (MB)
 ----------------------------------------------------------------------------------------------------------------
     sdc1                              Primary        Linux ext3             [boot1000]              320.79       
     sdc2                              Primary        Linux swap / Solaris                          8291.09
     sdc3                              Primary        Linux ext3             [TR5]                 50009.71
     sdc5                              Logical        Linux ext3             [TR5-Documents]      109996.67
     sdc6                              Logical        Linux ext3             [tmpback]            105012.15
     sdc7                              Logical        Linux ext3             [TR6]                 32004.57
     sdc8                              Logical        Linux ext3             [mm-master]           32004.57
     sdc9                              Logical        Linux ext3             [mmbuild]             32004.57
     sdc10                             Logical        Linux ext3             [st-backup]           32004.57
     sdc11                             Logical        Linux ext3             [os-backups]         107381.04
     sdc12                             Logical        Linux ext3             [movies2]            322134.87
     sdc13                             Logical        Linux ext3             [openbox]             32012.79
     sdc14                             Logical        Linux ext3             [minime2010]          32498.09
     sdc15                             Logical        Linux ext3             [openbox2]            34365.22
                                       Logical        Free Space                                   70161.64


Cfdisk does not show swap partition labels, but the swap partition was labeled by the mkswap -L swap1000 /dev/sdc2 command.

My current /etc/fstab looks like this;

Code: [Select]
LABEL=minime2010        /                       ext4    defaults,noatime                1 1
LABEL=TR5-Documents     /home/polack/Documents  ext3    defaults,noatime                1 2
LABEL=Documents2        /home/polack/Documents2 ext3    defaults,noatime                1 2
LABEL=share7            /share7                 ext3    rw,user,auto,exec,noatime       0 0
LABEL=share9            /share9                 ext3    rw,user,auto,exec,noatime       0 0
LABEL=movies            /movies                 ext3    rw,user,auto,exec,noatime       0 0
LABEL=movies2           /movies2                ext3    rw,user,auto,exec,noatime       0 0
LABEL=TV-1              /tv                     ext3    rw,user,auto,exec,noatime       0 0
LABEL=storage00         /zstorage00             ext3    rw,user,noauto,exec,noatime     0 0
LABEL=120backup         /zbackup                ext3    rw,user,noauto,exec,noatime     0 0
none                    /proc                   proc    defaults                        0 0
# Entry for /dev/sda2 :
LABEL=swap200           swap                    swap    defaults                        0 0
# Entry for /dev/sdc2 :
LABEL=swap1000          swap                    swap    defaults                        0 0
# Entry for /dev/sde2 :
LABEL=swap750           swap                    swap    defaults                        0 0
none                    /dev/pts                devpts  mode=0620                       0 0
/dev/fd0                /mnt/floppy             auto    rw,user,noauto,exec             0 0
/dev/sr0                /mnt/cdrom              auto    ro,user,noauto                  0 0
/dev/sr1                /mnt/dvd                auto    ro,user,noauto                  0 0
# none                  /dev/shm                tmpfs   defaults                        0 0

The command swapon -s shows all the swap partitions are, indeed, mounted.

[root@littleboy ~]# swapon -s
Code: [Select]
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       1823368 13704   -1
/dev/sdc2                               partition       8096752 0       -2
/dev/sde2                               partition       6008300 0       -3

To demonstrate how the labels are used directly with the mount command, I mount /dev/sda15, the OpenBox installation below;

[root@littleboy ~]# mount LABEL=openbox2 /mnt/here

It's the same format as that of the first entry of the mount line in fstab, with the mount point I choose, in this case /mnt/here. For each mount line in /etc/fstab, the mount point directory must actually exist, and these need to be created as root, except for those that exist in the users home directory, as in my use of /home/polack/Documents, and /home/polack/Documents2.

From there, a look at the fstab from that installation reveals it is exactly the same as my MiniMe fstab, except for the / partition lines. This assures that whichever installation I boot to, all my mount points remain the same, so my data is always in the same relative position on the running system.

[root@littleboy ~]# cat /mnt/here/etc/fstab
Code: [Select]
# Entry for /dev/sdc15 :                                                                              <-- This line
LABEL=openbox2          /                       ext4    defaults,noatime                1 1           <-- and this
LABEL=TR5-Documents     /home/polack/Documents  ext3    defaults,noatime                1 2
LABEL=Documents2        /home/polack/Documents2 ext3    defaults,noatime                1 2
LABEL=share7            /share7                 ext3    rw,user,auto,exec,noatime       0 0
LABEL=share9            /share9                 ext3    rw,user,auto,exec,noatime       0 0
LABEL=movies            /movies                 ext3    rw,user,auto,exec,noatime       0 0
LABEL=movies2           /movies2                ext3    rw,user,auto,exec,noatime       0 0
LABEL=TV-1              /tv                     ext3    rw,user,auto,exec,noatime       0 0
LABEL=storage00         /zstorage00             ext3    rw,user,noauto,exec,noatime     0 0
LABEL=120backup         /zbackup                ext3    rw,user,noauto,exec,noatime     0 0
none                    /proc                   proc    defaults                        0 0
# Entry for /dev/sda2 :
LABEL=swap200           swap                    swap    defaults                        0 0
# Entry for /dev/sdc2 :
LABEL=swap1000          swap                    swap    defaults                        0 0
# Entry for /dev/sde2 :
LABEL=swap750           swap                    swap    defaults                        0 0
none                    /dev/pts                devpts  mode=0620                       0 0
/dev/fd0                /mnt/floppy             auto    rw,user,noauto,exec             0 0
/dev/sr0                /mnt/cdrom              auto    ro,user,noauto                  0 0
/dev/sr1                /mnt/dvd                auto    ro,user,noauto                  0 0
# none                  /dev/shm                tmpfs   defaults                        0 0

Labels can also be used when needing to run a file system check, even if one doesn't know/remember the /dev/sd(xn). If it's a / partition, the fsck must be run with the partition unmounted, so best to be done from the liveCD. If I wanted to check the file system on my MiniMe partition, I'd use the command;

[root@localhost ~]# fsck -f LABEL=minime2010                  <Enter>

Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline marian

  • Hero Member
  • *****
  • Posts: 608
  • Hi
Re: Set all media to -noatime?
« Reply #11 on: May 06, 2010, 02:14:14 AM »
So I changed the line to:
LABEL=extData   /media/extData   ext4   defaults,noatime 1 2
but still the same error in "Devices recently plugged in:
No mount by single click.  ???

mount LABEL=extData is working

umount LABEL=extData
umount: LABEL=extData: not found


what the... once more
mount LABEL=extData
mount: /dev/sdb4 already mounted or /media/extData busy
mount: according to mtab, /dev/sdb4 is already mounted on /media/extData


umount LABEL=extData
umount: LABEL=extData: not found


So I unplugged the drive and tried once more

mount LABEL=extData


umount LABEL=extData
umount: LABEL=extData: not found


With UUID I was able to unmount.  ???
Freedom is the only way!

Online Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11549
  • ----IOFLU----
Re: Set all media to -noatime?
« Reply #12 on: May 06, 2010, 02:53:53 AM »
So I changed the line to:
LABEL=extData   /media/extData   ext4   defaults,noatime 1 2
but still the same error in "Devices recently plugged in:
No mount by single click.  ???

mount LABEL=extData is working

umount LABEL=extData
umount: LABEL=extData: not found


what the... once more
mount LABEL=extData
mount: /dev/sdb4 already mounted or /media/extData busy
mount: according to mtab, /dev/sdb4 is already mounted on /media/extData


umount LABEL=extData
umount: LABEL=extData: not found


So I unplugged the drive and tried once more

mount LABEL=extData


umount LABEL=extData
umount: LABEL=extData: not found


With UUID I was able to unmount.  ???

Don't be mounting in /media. HAL treats those as dynamic mount points and may be deleting them when unmounting.

Put your mount point in /mnt. Ten years from now it will still be there, if you don't delete it yourself. If you want them user mountable don't use defaults as a mount option. Spell out what you want. Look at my entries, they are there for examples. To be user mountable user,noauto go together. To be mounted rw, put it in the options string. To be auto mounted, use the auto option. Remember, no spaces within the options string, comma separated between options.

If this is a temporary mount, used only part time, end the line with 0 0 not 1 2. The / partition should be 1 1, /home partition 1 2, all others 0 0.
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline marian

  • Hero Member
  • *****
  • Posts: 608
  • Hi
Re: Set all media to -noatime?
« Reply #13 on: May 06, 2010, 07:06:44 AM »
"Spell out what you want."

Just want to mount/unmount my external drives by clicking on "device notifier" with noatime setting in our case.
With mount it can be done but not with "device notifier".
When I add some entries into fstab to mount it to /media or /mnt none of them work with the notifier.

Now the setting is:
LABEL=extData /mnt/extData ext4 rw,user,noauto,noatime 0 0
(/mnt/extData is of course created)

Maybe the "device notifier" is unable to mount partitions when there are some settings in fstab for them. (see the pictures below)

mikkl
I hope you also meant the same thing when you started this thread.  :)

ps:
old-polack
Your post are always great when it comes to hard disks, partitions, grub etc. You should write some book about it. It would be BestSeller.  ;D
Freedom is the only way!

Offline Roc4fun

  • Hero Member
  • *****
  • Posts: 620
  • The life so short, the craft so long to learn
Re: Set all media to -noatime?
« Reply #14 on: May 06, 2010, 07:34:02 AM »
O-P,  Thanks for the labeling tutorial.

I was a little disappointed when the default fstab creator started using uuid.  I've used labeling in the past for an external mp3 player that I needed mounted always in the same place.

Your tutorial was very informative, and I look forward to having a meaningful fstab in the near future.

Dave