Re: Ultimate Fedora partition scheme ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 18 Jun 2009 15:24:40 +0200
Valent Turkovic wrote:

> Could you be persuaded to publish more details on these tricks on your
> blog or here? ;)

Here's pretty much all the gory details:

I currently have the system setup like so:

/dev/sda1 - a fedora 10 "master" system 20GB partition with no
separate /boot, the /boot for this is just a directory inside
this root partition. Grub was installed for this one in the
MBR of the disk, and this is the normal default boot system.

/dev/sda2 - a swap area I share between all the different
linuxes (works well as long as you don't hibernate :-).

/dev/sda3 - the shared 60MB /boot partition. Every other linux
installed on this system is told to use this as /boot and
format it ext3 during the install and install grub on this
partition, NOT in the MBR.

In the master linux on /dev/sda1, I have one grub entry that
looks like this:

title Boot other linux
        rootnoverify (hd0,2)
        chainloader +1

So whatever copy of /boot happens to currently reside in
/dev/sda3 will determine which linux actually boots if I tell
grub to "Boot other linux".

By convention, I always use e2label to give the /boot
partition a unique disk label every time I install a new
linux, then my shell scripts can use e2label to check what is
currently installed and use the label name as the output file
name when doing a dd to save an existing /boot.

The dd commands are relatively simple, but grub is tricky.
When I want to boot a different linux (especially from
automated scripts while I'm not around to interact with grub),
I need to tell grub to boot the "other linux" entry next time
I say reboot.

That procedure is documented in great detail in the grub info
file, and the actual grub binary doesn't work anything like
the info file says it works :-(.

Here's my boot-other script to trick grub into booting entry #2
(instead of the normal defaul 0) the next time I reboot:

cat > /tmp/bo$$ <<'EOF'
savedefault --stage2=/boot/grub/stage2 --default=2 --once
quit
EOF
grub < /tmp/bo$$
rm -f /tmp/bo$$

That makes the fedora 10 grub boot my "other linux" entry on
the next reboot, but if the system is rebooted again (from the
other linux, or by power hit or whatever), it will come back
up the next time in my "master" system.

The other scripts aren't so tricky, they are just doing some
dd commands. Here's the save-boot script that saves the
current contents of /dev/sda3:

othername=`e2label /dev/sda3`
if [ -n "$othername" ]
then
   dd if=/dev/sda3 of=/bootbox/"$othername" ibs=10240
else
   echo Missing label for /dev/sda3 partition 1>&2
   exit 2
fi

And the corresponding restore-boot script:

if [ $# -eq 1 ]
then
   if [ -r /bootbox/"$1" ]
   then
      dd if=/bootbox/"$1" of=/dev/sda3 ibs=10240
   else
      echo No such image /bootbox/$1 1>&2
      exit 2
   fi
else
   echo Missing partition label name to be restored 1>&2
   exit 2
fi

And the master switch-linux script that puts all the bits
together:

if [ $# -eq 1 ]
then
   newlinux="$1"
   curlinux=`e2label /dev/sda3`
   if [ -r /bootbox/"$newlinux" ]
   then
      if [ "$newlinux" != "$curlinux" ]
      then
         /usr/local/bin/save-boot
         /usr/local/bin/restore-boot "$newlinux"
      fi
      /usr/local/bin/boot-other
      reboot
   else
      echo $newlinux is not a saved linux I can boot 1>&2
      exit 2
   fi
else
   echo Missing linux name argument 1>&2
   exit 2
fi

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux