mikrotik_snippets/xubuntu-read-only-filesystem.txt

130 lines
3.5 KiB
Plaintext
Raw Normal View History

2016-05-29 18:57:08 +03:00
Xubuntu 16.04 with read only root filesystem for SSD disk
----------------------------------------------------------
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
* example:
2016-05-22 02:45:45 +03:00
/dev/sda: HDD disk (mechanical disk)
/dev/sdc: SSD disk (solid state disk)
2016-05-29 18:57:08 +03:00
2016-05-16 20:31:33 +03:00
/dev/sda2: /home /tmp /var/tmp
2016-05-16 02:55:04 +03:00
/dev/sda3: swap
2016-05-29 18:57:08 +03:00
/dev/sdc1: /
* install xubuntu 16.04 in /dev/sdc1.
* mkdir -p /var/mounts/sda2 ; chmod 755 /var/mounts/sda2
* mkdir -p /var/mounts/ro ; chmod 755 /var/mounts/ro
* mkdir -p /var/mounts/rw ; chmod 755 /var/mounts/rw
* mount /dev/sda2 /mnt
* mkdir /mnt/tmp ; chmod 1777 /mnt/tmp
* mkdir /mnt/home ; chmod 0755 /mnt/home
* rsync -av /home/ /mnt/home/
* rm -fr /home/* /tmp/* /tmp/.* <-- CAUTION!
* /usr/local/bin/readonlyfs
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
#!/bin/bash
### BEGIN INIT INFO
# Provides: readonlyfs
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Read only root filesystem.
# Description: This script provides a read only root
# filesystem for use xubuntu with solid
# state drives.
### END INIT INFO
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
PATH=/usr/sbin:/usr/bin:/sbin:/bin
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
case "$1" in
start)
echo "Starting read only filesystem."
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
mount -t tmpfs -o size=1M tmpfs /var/mounts/rw
mount -t aufs -o br=/var/mounts/rw=rw:/var/mounts/ro=ro -o udba=reval none /media
chmod 0755 /media
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
mount -o noatime /dev/sda2 /var/mounts/sda2
mount --bind /var/mounts/sda2/home /home
mount --bind /var/mounts/sda2/tmp /tmp
mount --bind /var/mounts/sda2/tmp /var/tmp
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
mount -t tmpfs -o nosuid,nodev,mode=0755,rw,size=1M,uid=lightdm,gid=lightdm tmpfs /var/lib/lightdm
mount --bind /var/lib/lightdm /var/lib/lightdm-data
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
mount -t tmpfs -o nosuid,nodev,mode=0777,rw,size=8M,uid=root,gid=syslog tmpfs /var/log
mount --bind /var/log /var/spool
mount --bind /var/log /var/lib/blueman
;;
stop)
echo "Stopping read only filesystem."
;;
*)
echo "Usage: readonlyfs start|stop"
;;
esac
exit 0
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
* chmod 0744 /usr/local/bin/readonlyfs
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
* ln -s /usr/local/bin/readonlyfs /etc/init.d/readonlyfs
2016-05-16 02:55:04 +03:00
2016-05-29 18:57:08 +03:00
* ln -s ../init.d/readonlyfs /etc/rcS.d/S99readonlyfs
* update-rc.d readonlyfs disable
* update-rc.d readonlyfs enable
2016-05-16 02:55:04 +03:00
* /etc/fstab
2016-05-29 18:57:08 +03:00
UUID=<UUID_/dev/sdc1> / ext4 ro,noatime,errors=remount-ro 0 0
UUID=<UUID_/dev/sda3> none swap sw 0 0
* /etc/default/grub
GRUB_TIMEOUT=N
GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT
update-grub
* /usr/local/bin/remountrw + chmod 744
2016-05-16 02:55:04 +03:00
mount -o remount,rw /
2016-05-29 18:57:08 +03:00
* /usr/local/bin/remountro + chmod 744
2016-05-16 02:55:04 +03:00
sync
sleep 1
mount -o remount,ro /
2016-05-16 20:31:33 +03:00
2016-05-19 19:18:31 +03:00
* Network Manager: wired connection with fixed IP address:
* Create and chmod 600 the file:
"/etc/NetworkManager/system-connections/Wired Connection"
[ethernet]
duplex=full
mac-address=xx:xx:xx:xx:xx:xx
[connection]
id=Wired Connection
uuid=66b010e7-d2b0-4e5a-a2d8-f1d8191a241d
type=ethernet
timestamp=1440124541
[ipv6]
method=auto
ip6-privacy=0
[ipv4]
method=manual
dns=<IP_ADDRESS>;
address1=<IP_ADDRESS>/<MASK 0-30>,<DEFAULT_GATEWAY>
may-fail=false
2016-05-29 18:57:08 +03:00
* Issues:
* The guest session not work: /etc/password and /etc/shadow are read only.
* Lightdm can not remember the last user logged.