mirror of
https://bitbucket.org/mangelo/snippets.git
synced 2024-11-27 21:21:00 +02:00
Xubuntu readonly filesystem.
This commit is contained in:
parent
b39369c09a
commit
7e9c859e60
@ -1,63 +1,105 @@
|
|||||||
XUbuntu 16.04 with read only filesystem for use with SSD disk
|
Xubuntu 16.04 with read only root filesystem for SSD disk
|
||||||
---------------------------------------------------------------
|
----------------------------------------------------------
|
||||||
|
|
||||||
* Example:
|
* example:
|
||||||
/dev/sda: HDD disk (mechanical disk)
|
/dev/sda: HDD disk (mechanical disk)
|
||||||
/dev/sdc: SSD disk (solid state disk)
|
/dev/sdc: SSD disk (solid state disk)
|
||||||
/dev/sdc1: /
|
|
||||||
/dev/sda2: /home /tmp /var/tmp
|
/dev/sda2: /home /tmp /var/tmp
|
||||||
/dev/sda3: swap
|
/dev/sda3: swap
|
||||||
|
/dev/sdc1: /
|
||||||
|
|
||||||
* Install XUbuntu 16.04 in /dev/sdc1.
|
* install xubuntu 16.04 in /dev/sdc1.
|
||||||
|
|
||||||
* mkdir /hddsda2
|
* mkdir -p /var/mounts/sda2 ; chmod 755 /var/mounts/sda2
|
||||||
|
|
||||||
* mount /dev/sda2 /hddsda2
|
* mkdir -p /var/mounts/ro ; chmod 755 /var/mounts/ro
|
||||||
|
|
||||||
* mkdir /hddsda2/tmp
|
* mkdir -p /var/mounts/rw ; chmod 755 /var/mounts/rw
|
||||||
|
|
||||||
* chmod 1777 /hddsda2/tmp
|
* mount /dev/sda2 /mnt
|
||||||
|
|
||||||
* mkdir -p /hddsda2/home/username
|
* mkdir /mnt/tmp ; chmod 1777 /mnt/tmp
|
||||||
|
|
||||||
* rsync -av /home/username/ /hddsda2/home/username/
|
* mkdir /mnt/home ; chmod 0755 /mnt/home
|
||||||
|
|
||||||
* chmod 0700 /hddsda2/home/username
|
* rsync -av /home/ /mnt/home/
|
||||||
|
|
||||||
* chown -R username.username /hddsda2/home/username
|
* rm -fr /home/* /tmp/* /tmp/.* <-- CAUTION!
|
||||||
|
|
||||||
* blkid
|
* /usr/local/bin/readonlyfs
|
||||||
/dev/sda1: UUID="D4EA43ACEA438A26" TYPE="ntfs"
|
|
||||||
/dev/sda2: UUID="c1a48592-1d54-4b61-822b-e02ce0c8094d" TYPE="ext4"
|
#!/bin/bash
|
||||||
/dev/sda3: UUID="7af9d5db-eac4-49f1-aafd-3cb82f08c9df" TYPE="swap"
|
### BEGIN INIT INFO
|
||||||
/dev/sdc1: UUID="9d0a8f06-d686-4a6d-97d5-2320598335fb" TYPE="ext4"
|
# 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
|
||||||
|
|
||||||
|
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo "Starting read only filesystem."
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
* chmod 0744 /usr/local/bin/readonlyfs
|
||||||
|
|
||||||
|
* ln -s /usr/local/bin/readonlyfs /etc/init.d/readonlyfs
|
||||||
|
|
||||||
|
* ln -s ../init.d/readonlyfs /etc/rcS.d/S99readonlyfs
|
||||||
|
|
||||||
|
* update-rc.d readonlyfs disable
|
||||||
|
|
||||||
|
* update-rc.d readonlyfs enable
|
||||||
|
|
||||||
* /etc/fstab
|
* /etc/fstab
|
||||||
UUID=9d0a8f06-d686-4a6d-97d5-2320598335fb / ext4 ro,noatime,errors=remount-ro 0 1
|
UUID=<UUID_/dev/sdc1> / ext4 ro,noatime,errors=remount-ro 0 0
|
||||||
UUID=c1a48592-1d54-4b61-822b-e02ce0c8094d /hddsda2 ext4 rw,noatime,errors=remount-ro 0 1
|
UUID=<UUID_/dev/sda3> none swap sw 0 0
|
||||||
UUID=7af9d5db-eac4-49f1-aafd-3cb82f08c9df none swap sw 0 0
|
|
||||||
tmpfs /var/lib/lightdm tmpfs nosuid,nodev,mode=0750,rw,size=32M,uid=lightdm,gid=lightdm 0 0
|
|
||||||
tmpfs /var/log tmpfs nosuid,nodev,mode=0777,rw,size=32M,uid=root,gid=syslog 0 0
|
|
||||||
/hddsda2/home /home none bind 0 0
|
|
||||||
/hddsda2/tmp /tmp none bind 0 0
|
|
||||||
/hddsda2/tmp /var/tmp none bind 0 0
|
|
||||||
/var/log /media none bind 0 0
|
|
||||||
/var/log /var/spool none bind 0 0
|
|
||||||
/var/log /var/lib/blueman none bind 0 0
|
|
||||||
/var/lib/lightdm /var/lib/lightdm-data none bind 0 0
|
|
||||||
|
|
||||||
* /usr/local/bin/remountrw
|
* /etc/default/grub
|
||||||
|
GRUB_TIMEOUT=N
|
||||||
|
GRUB_RECORDFAIL_TIMEOUT=$GRUB_TIMEOUT
|
||||||
|
update-grub
|
||||||
|
|
||||||
|
* /usr/local/bin/remountrw + chmod 744
|
||||||
mount -o remount,rw /
|
mount -o remount,rw /
|
||||||
|
|
||||||
* /usr/local/bin/remountro
|
* /usr/local/bin/remountro + chmod 744
|
||||||
sync
|
sync
|
||||||
sleep 1
|
sleep 1
|
||||||
mount -o remount,ro /
|
mount -o remount,ro /
|
||||||
|
|
||||||
* Issues:
|
|
||||||
* The guest session not work: /etc/password and /etc/shadow are read only.
|
|
||||||
* Lightdm can not remember the last user logged.
|
|
||||||
|
|
||||||
* Network Manager: wired connection with fixed IP address:
|
* Network Manager: wired connection with fixed IP address:
|
||||||
* Create and chmod 600 the file:
|
* Create and chmod 600 the file:
|
||||||
"/etc/NetworkManager/system-connections/Wired Connection"
|
"/etc/NetworkManager/system-connections/Wired Connection"
|
||||||
@ -81,3 +123,7 @@ XUbuntu 16.04 with read only filesystem for use with SSD disk
|
|||||||
dns=<IP_ADDRESS>;
|
dns=<IP_ADDRESS>;
|
||||||
address1=<IP_ADDRESS>/<MASK 0-30>,<DEFAULT_GATEWAY>
|
address1=<IP_ADDRESS>/<MASK 0-30>,<DEFAULT_GATEWAY>
|
||||||
may-fail=false
|
may-fail=false
|
||||||
|
|
||||||
|
* Issues:
|
||||||
|
* The guest session not work: /etc/password and /etc/shadow are read only.
|
||||||
|
* Lightdm can not remember the last user logged.
|
||||||
|
Loading…
Reference in New Issue
Block a user