From f620390721e20277220893bff6a92b77232dcf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 2 Aug 2013 01:18:06 +0200 Subject: [PATCH 1/6] mount /tmp in tmpfs to allow to switch the root fs in RO --- fs/etc/fstab | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 fs/etc/fstab diff --git a/fs/etc/fstab b/fs/etc/fstab new file mode 100644 index 0000000..980ed79 --- /dev/null +++ b/fs/etc/fstab @@ -0,0 +1,34 @@ +# /etc/fstab: static file system information. +# +# The root filesystem should have a pass number of either 0 or 1. +# All other filesystems should have a pass number of 0 or greater than 1. +# +# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts. +# +# See the manpage fstab(5) for more information. +# +# + +/dev/sda1 /boot ext2 noauto,noatime 1 2 +/dev/mapper/vg0-root / ext4 noatime,discard,nodiratime,defaults 0 1 +/dev/mapper/vg0-swap none swap sw 0 0 +/dev/mapper/vg0-home /home ext4 noatime,discard,nodiratime 0 0 +/dev/mapper/vg0-var /var ext4 noatime,discard,nodiratime 0 0 +/dev/mapper/vg0-portage /usr/portage ext4 noatime,discard,nodiratime 0 0 +/dev/mapper/vg0-media /mnt/media ext4 noatime,discard,nodiratime 0 0 +/dev/mapper/vg0-virt /mnt/virt ext4 noatime,discard,nodiratime,noauto 0 0 +tmpfs /tmp tmpfs size=512M 0 0 +#tmpfs /var/tmp/portage tmpfs size=4G 0 0 +# Firefox +tmpfs /var/tmp/portage tmpfs size=10G 0 0 +#/dev/cdrom /mnt/cdrom auto noauto,ro 0 0 + +/dev/sdb1 /mnt/disk vfat defaults,noauto,uid=1000,user 0 0 +/dev/sdb1 /mnt/ntfs ntfs-3g defaults,noauto,uid=1000,user 0 0 + +/dev/mmcblk0p1 /mnt/ext_media ntfs-3g noatime,discard,nodiratime 0 0 +/dev/mmcblk0p1 /mnt/photo vfat defaults,noauto,uid=1000,user 0 0 + +# Backup +/dev/vg-backup/backup /mnt/backup/backup ext4 noauto,noatime 0 0 +/dev/vg-backup/film /mnt/backup/films xfs noauto,noatime 0 0 From 4c33a8cfb1215a79860708f28c729662ee1f188e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 2 Aug 2013 12:02:01 +0200 Subject: [PATCH 2/6] Revert "mount /tmp in tmpfs to allow to switch the root fs in RO" This reverts commit f620390721e20277220893bff6a92b77232dcf29. --- fs/etc/fstab | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 fs/etc/fstab diff --git a/fs/etc/fstab b/fs/etc/fstab deleted file mode 100644 index 980ed79..0000000 --- a/fs/etc/fstab +++ /dev/null @@ -1,34 +0,0 @@ -# /etc/fstab: static file system information. -# -# The root filesystem should have a pass number of either 0 or 1. -# All other filesystems should have a pass number of 0 or greater than 1. -# -# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts. -# -# See the manpage fstab(5) for more information. -# -# - -/dev/sda1 /boot ext2 noauto,noatime 1 2 -/dev/mapper/vg0-root / ext4 noatime,discard,nodiratime,defaults 0 1 -/dev/mapper/vg0-swap none swap sw 0 0 -/dev/mapper/vg0-home /home ext4 noatime,discard,nodiratime 0 0 -/dev/mapper/vg0-var /var ext4 noatime,discard,nodiratime 0 0 -/dev/mapper/vg0-portage /usr/portage ext4 noatime,discard,nodiratime 0 0 -/dev/mapper/vg0-media /mnt/media ext4 noatime,discard,nodiratime 0 0 -/dev/mapper/vg0-virt /mnt/virt ext4 noatime,discard,nodiratime,noauto 0 0 -tmpfs /tmp tmpfs size=512M 0 0 -#tmpfs /var/tmp/portage tmpfs size=4G 0 0 -# Firefox -tmpfs /var/tmp/portage tmpfs size=10G 0 0 -#/dev/cdrom /mnt/cdrom auto noauto,ro 0 0 - -/dev/sdb1 /mnt/disk vfat defaults,noauto,uid=1000,user 0 0 -/dev/sdb1 /mnt/ntfs ntfs-3g defaults,noauto,uid=1000,user 0 0 - -/dev/mmcblk0p1 /mnt/ext_media ntfs-3g noatime,discard,nodiratime 0 0 -/dev/mmcblk0p1 /mnt/photo vfat defaults,noauto,uid=1000,user 0 0 - -# Backup -/dev/vg-backup/backup /mnt/backup/backup ext4 noauto,noatime 0 0 -/dev/vg-backup/film /mnt/backup/films xfs noauto,noatime 0 0 From 16bdb575c18ac39e9e747c0375edd2848002498d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 2 Aug 2013 12:03:12 +0200 Subject: [PATCH 3/6] mount /tmp in tmpfs and the root fs in RO --- fs/etc/fstab | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 fs/etc/fstab diff --git a/fs/etc/fstab b/fs/etc/fstab new file mode 100644 index 0000000..f05f0fe --- /dev/null +++ b/fs/etc/fstab @@ -0,0 +1,5 @@ +proc /proc proc defaults 0 0 +/dev/mmcblk0p1 /boot vfat ro,defaults 0 2 +/dev/mmcblk0p2 / ext4 ro,defaults,noatime 0 1 +tmpfs /tmp tmpfs rw,size=64M,noexec,nodev,nosuid,mode=1777 0 0 +# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that From 3835b5f887da672f0dde4a2e6fdaa7ae71d75fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 2 Aug 2013 13:49:13 +0200 Subject: [PATCH 4/6] =?UTF-8?q?Mount=20src=20and=20dest=20partitions=20in?= =?UTF-8?q?=20/tmp=20instead=20of=20HOME.=20Thanks=20to=20R=C3=A9mi=20Laur?= =?UTF-8?q?ent.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fs/opt/groomer/constraint.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/opt/groomer/constraint.sh b/fs/opt/groomer/constraint.sh index 2506d52..ca2b30c 100644 --- a/fs/opt/groomer/constraint.sh +++ b/fs/opt/groomer/constraint.sh @@ -4,10 +4,12 @@ DEV_DST='/dev/sdb1' USERNAME='kitten' HOME="/home/${USERNAME}" -# Paths used in multiple scripts -SRC="${HOME}/src" +TMP="/tmp/" -DST="${HOME}/dst" +# Paths used in multiple scripts +SRC="${TMP}/src" + +DST="${TMP}/dst" TEMP="${DST}/temp" ZIPTEMP="${DST}/ziptemp" LOGS="${DST}/logs" From a0f168facbbc14be036dce4bf36bff3823d8dd70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 2 Aug 2013 14:30:06 +0200 Subject: [PATCH 5/6] assume the permissions of the home directory are correct. Allows us to have the root FS RO --- fs/opt/groomer/init.sh | 6 ------ prepare_rPI.sh | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/fs/opt/groomer/init.sh b/fs/opt/groomer/init.sh index a03fdfb..1627deb 100755 --- a/fs/opt/groomer/init.sh +++ b/fs/opt/groomer/init.sh @@ -12,17 +12,11 @@ fi clean(){ echo Done, cleaning. - #mount -o remount,rw / ${SYNC} } trap clean EXIT TERM INT -# Remount the root filesystem in RO mode -#mount -o remount,ro / - -chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}/ - su ${USERNAME} -c ./groomer.sh diff --git a/prepare_rPI.sh b/prepare_rPI.sh index 03006a8..3f04d04 100755 --- a/prepare_rPI.sh +++ b/prepare_rPI.sh @@ -10,3 +10,4 @@ apt-get autoremove apt-get install libreoffice p7zip-full libfontforge1 dpkg -i libpoppler28*.deb pdf2htmlex*.deb +chown -R kitten:kitten /home/kitten From a67f5e7109fcfaacbe24828409633cfa27b4f12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 4 Aug 2013 18:30:59 +0200 Subject: [PATCH 6/6] append .txt to the log files. Make it easyer to open on Windows. --- fs/opt/groomer/functions.sh | 2 +- fs/opt/groomer/groomer.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/opt/groomer/functions.sh b/fs/opt/groomer/functions.sh index 5ed2ed7..6651e77 100755 --- a/fs/opt/groomer/functions.sh +++ b/fs/opt/groomer/functions.sh @@ -9,7 +9,7 @@ source ./constraint_conv.sh RECURSIVE_ARCHIVE_MAX=3 RECURSIVE_ARCHIVE_CURRENT=0 ARCHIVE_BOMB=0 -LOGFILE="${LOGS}/processing" +LOGFILE="${LOGS}/processing.txt" # Something went wrong. error_handler(){ diff --git a/fs/opt/groomer/groomer.sh b/fs/opt/groomer/groomer.sh index 99af3e5..74b09d8 100755 --- a/fs/opt/groomer/groomer.sh +++ b/fs/opt/groomer/groomer.sh @@ -97,13 +97,13 @@ do echo "${partition} mounted at ${SRC}" # Print the filenames on the current partition in a logfile - find "${SRC}" -fls "${LOGS}/Content_partition_${PARTCOUNT}" + find "${SRC}" -fls "${LOGS}/Content_partition_${PARTCOUNT}.txt" # create a directory on ${DST} named PARTION_$PARTCOUNT target_dir="${DST}/FROM_PARTITION_${PARTCOUNT}" echo "copying to: ${target_dir}" mkdir -p "${target_dir}" - LOGFILE="${LOGS}/processing" + LOGFILE="${LOGS}/processing.txt" echo "==== Starting processing of ${SRC} to ${target_dir}. ====" >> ${LOGFILE} main ${target_dir}