- if [[ -f /etc/default/grub ]] ; then
- # We want the default options used by the distribution, stored here....
- source /etc/default/grub
- fi
- RootFS=`df / | grep dev | cut -f 1 -d " "`
- StartOfDevname=`echo $RootFS | cut -b 1-7`
- if [[ $StartOfDevname == "/dev/sd" || $StartOfDevName == "/dev/hd" ]] ; then
- # Identify root filesystem by UUID rather than by device node, if possible
- Uuid=`blkid -o export -s UUID $RootFS 2> /dev/null | grep UUID=`
- if [[ -n $Uuid ]] ; then
- RootFS=$Uuid
- fi
- fi
- DefaultOptions="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT"
- echo "\"Boot with standard options\" \"ro root=$RootFS $DefaultOptions \"" > $RLConfFile
- echo "\"Boot to single-user mode\" \"ro root=$RootFS $DefaultOptions single\"" >> $RLConfFile
- echo "\"Boot with minimal options\" \"ro root=$RootFS\"" >> $RLConfFile
+ RootFS=`df / | grep dev | cut -f 1 -d " "`
+ StartOfDevname=`echo $RootFS | cut -b 1-7`
+ if [[ $StartOfDevname == "/dev/sd" || $StartOfDevName == "/dev/hd" ]] ; then
+ # Identify root filesystem by UUID rather than by device node, if possible
+ Uuid=`blkid -o export -s UUID $RootFS 2> /dev/null | grep UUID=`
+ if [[ -n $Uuid ]] ; then
+ RootFS=$Uuid
+ fi
+ fi
+ FirstCmdlineOption=`cat /proc/cmdline | cut -d ' ' -f 1`
+ if [[ "$FirstCmdlineOption" =~ (vmlinuz|bzImage|kernel) ]] ; then
+ DefaultOptions=`cat /proc/cmdline | cut -d ' ' -f 2- | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'`
+ else
+ DefaultOptions=`cat /proc/cmdline | sed 's/\S*initrd=\S*//g' | sed 's/ *$//' | sed 's/^ *//'`
+ fi
+ echo "\"Boot with standard options\" \"$DefaultOptions\"" > $RLConfFile
+ echo "\"Boot to single-user mode\" \"$DefaultOptions single\"" >> $RLConfFile
+ echo "\"Boot with minimal options\" \"ro root=$RootFS\"" >> $RLConfFile