[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Optimization] Live USB system could avoid writing access times to USB flash disk for filesystem.squashfs



Using live-helper "Stable" from Debian 5.0.1, after building a live USB system with 

lh_config \
	-b usb-hdd \
	-p "lxde" \
	--apt-recommends "disabled" \
	--memtest "disabled" \
	--bootappend-live "locale=fr_FR.UTF-8 keyb=fr timezone=Europe/Paris persistent quiet vga=791" \
	--linux-packages "linux-image-2.6.29-backports.2 aufs-modules-2.6.29-backports.2" \
	--hostname "live-host" \
	--categories "main contrib non-free" \
	--keyring-packages "debian-multimedia-keyring debian-archive-keyring" \
	--username "cpierret" \
	--language fr --linux-flavours "686" \
	--mirror-bootstrap "http://ftp.fr.debian.org/debian"; \
	--mirror-chroot "http://ftp.fr.debian.org/debian"; \
	--mirror-binary "http://ftp.fr.debian.org/debian"; \
	--syslinux-timeout 6 
(and a few hooks and patches)

I noticed using that USB live system that the USB flash disk was being written.
It seems that access time for /live/image/live/filesystem.squashfs is being written to USB flash disk.
Remounting the live partition with -noatime seemed to fix those unnecessary write behavior.
It is usually recommended to avoid writing access times to USB flash disk.

See shell script below on how to check for this behavior:

#!/bin/bash
## This script shows that USB device containing live system is written (for atime updates)
## and how to fix that by remounting with -o noatime
## Note: must be run with root priviledges

# Show access time for squashfs filesystem file on USB device
\ls -l --full-time --time=atime /live/image/live/filesystem.squashfs
date
## do a lot of read I/O on squashfs filesystem
nohup find / -exec grep -il "foobar" {} \; >/dev/null & 
sleep 10

# Show access time for squashfs filesystem file on USB device
\ls -l --full-time --time=atime /live/image/live/filesystem.squashfs

# remount live USB partition with "noatime" option
LIVE_DEVICE=`cat /etc/mtab|grep "/live/image"|awk '{print $1;}'`
mount -o noatime,remount,rw "${LIVE_DEVICE}"
# If you run the script again, access time will not change anymore (noatime now)

# stop the nohup find
kill `pidof find`
#### End of script ####

I could not check in latest git version if this behavior has changed or not.
Is there any option to mount -o noatime (or read-only) the live system partition from the start ? (adding a initramfs bottom script with mount -o noatime,remount ?)
Does anyone know if it is achievable ?

Christophe Pierret
  Sparus Software
  http://www.sparus-software.com



Reply to: