slitaz-boot-scripts view etc/init.d/bootopts.sh @ rev 35

Mount /home failed with options -o uid=500,gid=500
author Christophe Lincoln <pankso@slitaz.org>
date Sat Feb 23 22:35:46 2008 +0100 (2008-02-23)
parents 85421faee535
children ea584991ebae
line source
1 #!/bin/sh
2 # /etc/init.d/bootopts.sh - SliTaz boot options from the cmdline.
3 #
4 . /etc/init.d/rc.functions
6 # Check if swap file must be generated in /home: swap=size (Mb).
7 # This option is used with home=device.
8 gen_home_swap()
9 {
10 if grep -q "swap=[1-9]*" /proc/cmdline; then
11 SWAP_SIZE=`cat /proc/cmdline | sed 's/.*swap=\([^ ]*\).*/\1/'`
12 # DD to gen a virtual disk.
13 echo "Generating swap file: /home/swap ($SWAP_SIZE)..."
14 dd if=/dev/zero of=/home/swap bs=1M count=$SWAP_SIZE
15 # Make the Linux swap filesystem.
16 mkswap /home/swap
17 fi
18 }
20 # Mount /home and check for user hacker home dir.
21 #
22 mount_home()
23 {
24 echo "Home has been specified to $DEVICE..."
25 echo "Sleeping 10 s to let the kernel detect the device... "
26 sleep 10
28 DEVID=$DEVICE
29 if [ -x /sbin/blkid ]; then
30 # Can be label, uuid or devname. DEVID give us first: /dev/name.
31 DEVID=`/sbin/blkid | grep $DEVICE | cut -d: -f1`
32 DEVID=${DEVID##*/}
33 fi
34 if [ -n "$DEVID" ] && grep -q "$DEVID" /proc/partitions ; then
35 echo "Mounting /home on /dev/$DEVID... "
36 mv /home/hacker /tmp/hacker-home
37 mount /dev/$DEVID /home
38 gen_home_swap
39 else
40 echo "Unable to find $DEVID... "
41 fi
42 # Move all hacker dir if needed.
43 if [ ! -d "/home/hacker" ] ; then
44 mv /tmp/hacker-home /home/hacker
45 chown -R hacker.hacker /home/hacker
46 else
47 rm -rf /tmp/hacker-home
48 fi
49 }
51 # Parse /proc/cmdline with grep.
52 #
54 echo "Parsing kernel cmdline for SliTaz live options... "
56 # Check for a specified home directory on cmdline (home=*).
57 #
58 if grep -q "home=usb" /proc/cmdline; then
59 DEVICE=sda1
60 mount_home
61 elif grep -q "home=" /proc/cmdline; then
62 DEVICE=`cat /proc/cmdline | sed 's/.*home=\([^ ]*\).*/\1/'`
63 mount_home
64 fi
66 # Active an eventual swap file in /home and on local hd.
67 #
68 if [ -f "/home/swap" ]; then
69 echo "Activing swap (/home/swap) memory..."
70 swapon /home/swap
71 fi
72 if [ "`fdisk -l | grep swap`" ]; then
73 for SWAP_DEV in `fdisk -l | grep swap | awk '{ print $1 }'`; do
74 echo "Swap memory detected on: $SWAP_DEV"
75 swapon $SWAP_DEV
76 done
77 fi
79 # Check for a specified locale (lang=*).
80 #
81 if grep -q "lang=*" /proc/cmdline; then
82 LANG=`cat /proc/cmdline | sed 's/.*lang=\([^ ]*\).*/\1/'`
83 echo -n "Setting system locale to: $LANG... "
84 echo "LANG=$LANG" > /etc/locale.conf
85 echo "LC_ALL=$LANG" >> /etc/locale.conf
86 status
87 fi
89 # Check for a specified keymap (kmap=*).
90 #
91 if grep -q "kmap=*" /proc/cmdline; then
92 KMAP=`cat /proc/cmdline | sed 's/.*kmap=\([^ ]*\).*/\1/'`
93 echo -n "Setting system keymap to: $KMAP..."
94 echo "KMAP=$KMAP.kmap" > /etc/kmap.conf
95 status
96 fi
98 # Check for a specified screen (screen=*).
99 #
100 if grep -q "screen=*" /proc/cmdline; then
101 SCREEN=`cat /proc/cmdline | sed 's/.*screen=\([^ ]*\).*/\1/'`
102 if [ "$SCREEN" = "text" ]; then
103 echo -n "Disabling X login manager: slim..."
104 sed -i s/'slim'/''/ /etc/rcS.conf
105 status
106 # Creat /etc/X11/screen.conf to avoid tazx execution by hwconf.sh
107 mkdir -p /etc/X11
108 echo 'SCREEN=1024x768x24' > /etc/X11/screen.conf
109 else
110 echo "Option not yet implemented: screen=$SCREEN"
111 sleep 2
112 fi
113 fi
115 # Laptop option to load ac and battery Kernel modules.
116 if grep -q "laptop" /proc/cmdline; then
117 echo "Loading laptop modules: ac battery..."
118 modprobe ac
119 modprobe battery
120 fi