For example, I have 12 Gigabytes in my Music directory, and a number of VirtualBox hard disk images (at 20 to 30 Gigabytes each) that I would like to access from both OS's. So my plan is to create a new partition which I will mount on /media/share on both Ubuntu and Scientific Linux. Then I'll make symbolic links from /home/[username]/Music to /media/share/Music from each home directory.
Before I could create a new partition, I needed to shrink one of my existing partitions to free up space. Here is how the partitions looked when I started:
and here is what they looked like after shrinking /dev/sda3, growing /dev/sda4 and inserting /dev/sda7 into the new space inside it:
I made the change by booting my computer from an Ubuntu 14.04 Live DVD and running GParted. It took about 20 minutes to shrink my home partition, but it worked without incident.
The next step is to add a mount for the new /dev/sda7 partition. It's been several years since I played around with mounting partitions, but I still remembered that it involved editing the /etc/fstab file and adding the device and the mount point. So I loaded my /etc/fstab file and noticed something had changed since I last looked at it:
# /etc/fstab: static file system information.I was completely unfamiliar with UUID, and had been expecting to see device names (like /dev/sda3 etc.) instead. I bit of searching led me to several links:
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during installation
UUID=4ae26245-fe59-40d2-a380-2c2de57b652b / ext4 errors=remount-ro 0 1
# /home was on /dev/sda3 during installation
UUID=5c4e86f6-1d94-4eab-9931-5d3aa29e1583 /home ext4 defaults 0 2
# swap was on /dev/sda1 during installation
UUID=bba8f235-d8b0-4131-9a3e-ec286c3b3837 none swap sw 0 0
- Why does fstab use UUID instead of the actual file system name?
- How to retrieve and change partition's UUID Universally Unique Identifier on linux
- UsingUUID
- Persistent block device naming
/dev/sda1: UUID="b70d7272-e47f-426a-a979-5417bb2f7801" TYPE="swap"which I used to add the following line to /etc/fstab:
/dev/sda2: UUID="4ae26245-fe59-40d2-a380-2c2de57b652b" TYPE="ext4"
/dev/sda3: UUID="5c4e86f6-1d94-4eab-9931-5d3aa29e1583" TYPE="ext4"
/dev/sda5: UUID="76f8dd02-3671-49ba-b75a-da6d8bb65b19" TYPE="ext4"
/dev/sda6: UUID="e7e58de9-a748-4500-b300-ae1ca10f2056" TYPE="xfs"
/dev/sda7: UUID="44244888-7000-49bf-8ac8-2c32e2f73eb5" TYPE="ext4"
UUID=44244888-7000-49bf-8ac8-2c32e2f73eb5 /media/share ext4 defaultsand then ran:
$ sudo mkdir /media/sharewhich mounted /dev/sda7 on /media/share. Next I moved all my music files to /media/share/Music, deleted the Music directory in my home directory, and replaced it with a symbolic link (note: run from my user's home directory):
$ sudo mount -a
$ ln -s /media/share/Music MusicI started Rhythmbox and it worked as if nothing had changed.
Rebooting into Scientific Linux, I added the same line to /etc/fstab and ran the same mkdir and mount commands, then removed my still empty Music directory, made the same sym link, and voila, I had access to all my music from Scientific Linux (after installing Rhythmbox, that is).
For VirtualBox VM sharing, things are a bit more complicated. Ubuntu makes installing VirtualBox trivial, since it is in the main repository, but on Ubuntu 14.04 version 4.3 is what you get. On Scientific Linux I installed version 5.0 using the instruction from an earlier post.
Fearing there might be meta-data conflicts between the two versions, but feeling confident the virtual hard disk image files (.vdi) could be shared between them without conflict (since I regularly copy these files back and forth between distros without problems), I did the following:
- On the Ubuntu side, I moved my entire VirtualBox VMs directory from my home directory to /media/share and sym linked to it as I had done with the Music directory.
- On the Scientific Linux side, I kept VirtualBox VMs in my home directory, using sym links only for the virtual disk image files. For example, from inside $HOME/VirtualBox VMs/Server1 I ran:
$ ln -s /media/share/VirtualBox\ VMs/Server1/Server1.vdi Server1.vdi
Finally, after noticing that VirtualBox-4.3 was available for Scientific Linux 7.1, I ran # yum remove VirtualBox-5.0 and then # yum install VirtualBox-4.3, made the VirtualBox VMs directory in my home directory a sym link to /media/share/VirtualBox VMs and quickly added all the VMs back. Now even the VMs with the VirtualBox extensions installed (for full screen GUI and auto mouse capture) work on both OS's.