Two version of linux — my setup

In this post, I’ll describe what I do when I want two versions of linux.  Typically, one is for normal use and the other is for testing.  I noticed some confusion about how to do this in a recent thread at opensuse forums.  So I thought it might be of interest to describe what I am doing.

This is intended for information only.  Of course there are many different ways of handling this.  I am describing just one of them.

The particular computer is an older one that uses legacy (MBR) booting.  It was my main desktop, until around two years ago.  Now I mainly use it for testing and as a backup in case my main desktop fails.

I currently have both opensuse 13.1 and opensuse 13.2 installed.  I also have another partition for test installs.  Opensuse 13.2 is a 64-bit install, while opensuse 13.1 is a 32-bit install (actually the “linux for education” version.

Some background

This computer also has Windows Vista.  I purchased it in 2007, and it has served me well.  I have had both a working system and a test system, but the way that I originally organized these was somewhat haphazard.

The computer came with a 320G hard drive.  That failed around Feb or March last year.  I replaced it with a 750G drive, which gave me some extra space to think about organizing.  I started out looking for a drive with around 500G capacity, but most of those listed at Amazon were refurbished.  I went with the 750G because I preferred a new drive.

Fortunately, I did have an Acronis backup of Windows Vista, and I successfully restored that.  I chose to reinstall opensuse, then restore “/home” from a backup.  I originally installed 13.1 64-bit, but have since replaced that with a 13.2 install.  And I also installed the 32-bit “linux for education” because I found that had some interesting applications to play with.

I’ll mainly describe my linux setup.

My setup

I like using encryption.  So the core of my setup is based on an encrypted LVM.

For reference, here’s the partition table, as shown by “fdisk”.

# fdisk -l /dev/sda

Disk /dev/sda: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xbf1c9325

Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1            2048    1026047    1024000   500M 83 Linux
/dev/sda2  *      1026048  126855167  125829120    60G  7 HPFS/NTFS/exFAT
/dev/sda3       126857214 1465149167 1338291954 638.2G  5 Extended
/dev/sda5       126857216  130953215    4096000     2G  7 HPFS/NTFS/exFAT
/dev/sda6       130955264  132003839    1048576   512M 83 Linux
/dev/sda7       132005888  446578687  314572800   150G 8e Linux LVM
/dev/sda8       446580736  530466815   83886080    40G 83 Linux
/dev/sda9       530468864 1465149167  934680304 445.7G 83 Linux

Partition 4 does not start on physical sector boundary.

The heart of my install is in the encrypted LVM.  So I’ll describe that first.

The LVM

“/dev/sda7” is a LUKS encrypted partition.  Using Yast partitioner, I created an LVM, and added the encrypted space.  I then divided that into volumes.

There are four volumes.  They are named “root1”, “root2”, “swap” and “home”.  Both “root1” and “root2” are around 40G, and the swap volume is at around 5G.  The remainder is in the home volume.

I am using the home volume for both 13.1 and 13.2, but I am not using it the same way in both.  I also use the same swap volume for both systems.  The “root1” volume contains the root file system for opensuse 13.2, and the “root2” volume contains the root system for 13.1.

It is usually best to have a separate “/boot” when using an encrypted LVM.  So “/dev/sda1” is the “/boot” file system for 13.2, and is formatted as “ext2”.  And “/dev/sda6” is the “/boot” file system for 13.1, also formatted as “ext2”.

For my 13.2 system, the home logical volume is mounted at “/home”, so that’s a more-or-less typical arrangement when using an encrypted LVM.

With my 13.1 system, I have mounted the home logical volume as “/xhome”.  So, under 13.1, “/home” is actually part of the root file system.  I do it that way to avoid configuration conflicts between the 13.2 desktop and the 13.1 desktop.  The configuration files in the home directory are in separate file systems.

In my home directory for 13.1, there are many symbolic links to the corresponding directory for 13.2.

For example, in my 13.1 home directory, I did:

ln -s ../../xhome/$USER/bin bin

So I actually see the same files in my $HOME/bin for both systems.

Configuration files and directories such as “.kde4” and “.config” are not symlinks, so those are separate for the two.  However, “.ssh” and “.gnupg” are symlinks because I want to share those between the two systems.

To install, I used existing partitions.  In the partitioner section of install, I clicked the “create partitioning” option, and then the “custom partitioning”.  That listed existing partitions and logical volumes.  I could right click on one of those, select “edit” and change how it was to be used.  Installing mostly went smoothly.

Booting

With muliple systems, there’s a question of how to boot.  For both systems, I told the installer to:

  • boot from the “/boot” partition;
  • do not put generic code in the MBR (there is already Windows generic boot code there;
  • do not set the active partition.

Since legacy systems can only boot from a primary partition, I can only set it to boot Windows Vista (on “/dev/sda2”) or opensuse 13.2 (where “/boot” is “/dev/sda1”.  It actually works either way, and I sometimes change my mind on which to make active.

At present, the Windows Vista system is marked active.  I have entries in the Windows Boot manager for booting the two linux systems.  For that, I used “dd” to copy the boot sector to a file in the Windows C drive.

# cd /windows/C
# dd if=/dev/sda1 of=bootsect.lnx count=1

and then I used BCDEDIT to add an entry to Windows boot manager.  I used similar commands for the other installed linux version.

After a fresh install, I must refresh that “bootsect.lnx” file (again using “dd”), but there is no need to again run BCDEDIT in Windows.

The grub2 boot menu for opensuse 13.2 has a boot entry to boot Windows (automatically generated), and has another entry to boot my 13.1 linux system.  I manually added the second entry.  The automatically generated grub menu also has its own entry for 13.1, but that one won’t be automatically updated after a kernel update.  So I preferred to add my own entry.  I added that in “/etc/grub.d/40_custom”.  I actually have two entries for that

### Entry to boot grub from "/dev/sda6"
menuentry "Alternate grub/linux on /dev/sda6"  {
        set root=(hd0,6)
        chainloader +1
}
menuentry "configfile for grub/linux on /dev/sda6" {
       configfile (hd0,6)/boot/grub2/grub.cfg
}

The first uses chain-loading, and the second uses “configfile”.  Either one works, unless there is a problem with the boot sector.

Whether I make 13.2 or Windows the active partition, I can thus boot any of my systems.

Additional notes

Partition “/dev/sda8” is for testing other systems when I want to do that.  At one stage, I had kubuntu 14.04 installed there.  At present, it contains Tumbleweed but I am not actively maintaining it (my main Tumbleweed system is on a different computer).  There is also a grub2 boot  menu entry to boot this system.  I made it separate so that I am not tied to using encryption or an LVM.

On my main desktop, I have a file system mounted as “/shared”  I share that over the home network using Samba (to share with Windows) and NFS (to share with linux).  The partition “/dev/sda9” that you see in the “fdisk” output is a back up of that shared file system.  I run periodic “rsync” to keep a backup.  My “/shared” and the backup on “/dev/sda9” are both LUKS encrypted.  So any sensitive information in Windows can be stored on the shared system where it will be encrypted on disk.  The sensitive information is mostly income tax return information.  Multimedia (such as music) is also on the shared file system, for sharing among all systems.  I don’t consider the multimedia files to be sensitive.

That’s more than you ever wanted to know about my setup.

Advertisements

Tags: , , ,

About Neil Rickert

Mathematician and computer scientist who dabbles in cognitive science.

Trackbacks / Pingbacks

  1. Two versions of linux and UEFI | Thoughts on computing - 2015/04/19

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: