Ugh, another guide about installing Ubuntu from you? Stop it!
Yeah, I wrote quite a bit about that in the past, But I figured I would warm my fingers up for another long-winded typing session for people who don't want to put a Linux system on a spare media device that's half clapped-out, and would rather put their Linux installation on the same half clapped-out media device Windows exists on. That, and I've learned some new stuff since, and had dealt with other people's machines.
Before you proceed...
- This guide assumes you don't have to mess with EFI / SecureBoot stuff
- If you have to, that is on you.
- If using an SSD, you still need to provision some disk space for wear leveling
- Failure to do so, and subsequent expedited device failure is your fault
- You follow this guide at your own risk. If you mess up, that's your dumb, not mine.
- Provision a means to roll back, however you may. For brevity I won't mention any of that.
- A lot of this stuff is abstract, and requires you to be in full control, with a complete understanding of your filesystem
- If this makes you dizzy at any time, feel free to stop reading and consult a physician. Or your local IT nerd. Whatever works.
- This guide will have some specifics about Ubuntu and Ubuntu MATE.
- Adapt for whatever system you're using.
- If you are using an encrypted / compressed NTFS partition, some things will become more difficult.
- That isn't to say some things will be impossible, but more steps will be required to purpose an NTFS partition for cross-platform support.
This guide will also contain a lot of op-ed writing, so there are some opinions presented but there's nothing in here which isn't backed with and established by anything factual. This is intended for newbies, and people unfamiliar with partitioning, and it should be read top-down since a lot of what comes after makes less sense without reading what comes before.
Filesystem concepts and provisioning for dual-boot installation
If you're only interested in a single-partition installation, that is fine; you can run a system without swap of any kind and keep everything in
/ but that's a little foolish for several reasons;
- If you are not vigilant about linking directories, then you'll run out of space and have to move things between partitions before updating the system
- Lack of swap space or swapfile may cause instability on systems with less RAM available
- If you ever have to destroy the partition for any reason, you may end up losing files that are exclusive to the Debian userland left outside of linked directories into the NTFS partition, and lose special configuration files for reinstallation (should you want to reinstall / upgrade the system).
Bear all of that in mind; partition in whatever way will inconvenience you and compromise stability the least.
Notes about encrypted / compressed NTFS partitions
Since open-source systems with NTFS support work best (i.e. work at all) with NTFS partitions that have nothing special, instead of making room for a new system outside of Windows, you'll want to consider opening
diskmgmt.msc in Windows and using its tools to shrink the partition Windows is on (since you can shrink the present bootable partition in real-time), then create a new plain NTFS partition for cross-system storage later.
Note that for the purposes of exporting a lot of files it is better to move all users' library contents away from
%systemdrive%, to another externally-connected drive so the system partition can be shrunk down as much as possible, while provisioning for updates and additional programs. This can be done by visiting each user's library (in
%userprofile%), then right-clicking on each directory to change its properties. There is a tab called Location where you can define a new path; Windows will handle everything else.
An easy way to figure how much space to allocate for a new NTFS partition is to subtract whatever space is available (in megabytes) by how much you intend for the Linux system to occupy, then divide that by two; Use that figure to add onto the space used, and shrink to that size. If you don't have a lot in there already, that should provide enough space for extra programs and updates. After, with the media used for initial migration still connected change locations once again to the new NTFS partition.
Keeping the filesystem DRY
Don't Repeat Yourself; It is a concept used in programming all the time to not write the same code twice, and it can also be exercised on a hybrid NTFS5 / Ext4 disk setup. This will be explained later on, however in brief it is best in a dual-boot situation to repurpose existing directories for user profiles; this can be done very easily with
ln in Linux, and
mklink in Windows' command prompt as admin. Certain cross-platform programs can also use the same configuration files, albeit in different places; it should be considered, to squeeze every last byte out of a hard disk whether it is worth the effort of experimenting with using the same config files between systems.
This may differ depending on what the hard disk is capable of, but most 2.5" media I've ever encountered only allows for four primary partitions, or three with one extended.
However much space you need depends on whatever you are going to use the system for. Most setups I use on external devices go as follows;
- Ext4 (
- Ext4 (
- NTFS (Cross-system storage)
- (Whatever else I may place here in the future)
But most Windows setups are like this;
- NTFS (Windows)
- Fat32 / NTFS (Diagnostic software)
- Fat32 (Norton GHOST image, built-in drivers, whatever else)
An Ext4 partition can be squeezed into there, but it might be better to make an extended partition instead so it's set up like this;
- NTFS (Windows)
- Ext4 (
- Ext4 (
- NTFS (Non-compressed / -encrypted cross-system storage, if necessary)
- Ext4 (
- Fat32 / NTFS (Diagnostic software)
- Fat32 (Whatever else)
If you cannot do swap space, there's no need for it; a swapfile can be made instead.
However much space you need is entirely dependent on tasks to be performed. Most open-source software doesn't need that much space; The system itself demands 10 gigabytes, and other software therein usually don't take gigabytes of space alone. Altogether additional software may use another 5 gigabytes. 56 gigabytes is a good all-around figure to set;
- 32,768 megabytes for the system
- 16,384 megabytes for
- 8,192 megabytes for
If you need more space, you can use the NTFS partition that exist already for this, and all of that can be dealt with post-installation. Later on in this guide this concept will be explored. Also consider labeling the NTFS partition, since it will make certain procedures easier in the future.
How to boot
The bootloader is important to consider; If you can boot from SD or USB, it might be a good idea to keep a low-capacity SD card or USB device (512 megabytes, for example) to write the bootloader. Since it will only be needed when booting the system, it doesn't have to be used all the time and can be removed after booting is complete. That will also prevent boot issues with Windows updates, since the boot device is kept entirely separate.
Alternatively if you keep a USB device full of portable applications (FUSE software, PortableApps for Windows or stand-alone scripts and tools) you can also purpose that as a boot device, so long you are cognizant you can boot another system from it.
Executing provisioned changes
Everything above this is information to put into consideration when making changes with
gksu gparted (or use
gksu isn't an option) to tamper with your partitions, and make whatever changes you see fit which accommodate your needs. If you don't know what you're doing, everything I've presented before in this post is a good baseline to follow.
Only shrink the size of the NTFS partition to whatever size you need for the remaining partitions, then add in the partitions for the Ubuntu system as desired. Label as desired each partition as you are making it (extended and swap cannot be labelled), then commit your changes. Afterward, restart and confirm your changes did not ruin the Windows partition; if you can get to the Windows login screen, reboot into the live session once again to execute installation.
Installing the system
Ubiquity is a little weird about existing partitions, but they can still be purposed; at the installation screen, select which partitions you've committed for root (and home) and make them the same partition format they are right now (Ext4), but disallow formatting of these partitions; you just made them, you know what they are, and what they are suppose to do so there is no reason for Ubiquity to do anything more than copy files over and commit updates as necessary.
Use the information I presented prior about handling the bootloader to determine whether or not GRUB would be more at home in the same drive as Windows (overriding the Windows bootloader) or on a separate device (preserving the Windows bootloader). During the installation process, to make things even easier on yourself create users that are named exactly as they are on the Windows partition, so that any instance of
$USER is system-independent. You can only make one user now, but others can be made in the system later.
The difference between
~refers to the filepath of
/home/$USER; similar to
$USERrefers to the name of the present active user
Making the NTFS partition usable
There is a handy utility included in Ubuntu MATE called
gnome-disks and select the drive you installed the system onto. Select the NTFS partition in the media map, then click on the gears icon below to configure the drive so it mounts automatically. How it mounts is dependent upon what information about the partition exists; If you labeled the NTFS partition earlier,
/mnt/LABEL is a good option, since it will mount in
/mnt as the name of the partition, which will be easier to remember and easier to handle when moving content to another disk. Reboot once more to confirm your changes work.
Using the NTFS partition
To make use of the partition Windows exists on for your own personal storage in
/home, symbolic links can be used. Using
ln is the easiest way to do it, since you can go straight to business and have to rename nothing, but there needs to be special consideration for how many levels down each linked directory should be. There are two ways of handling this;
- Single-level links per NTFS directory
- Double-level links per NTFS directory
If you never plan on reinstalling the system from scratch, going right to the folders you need to share between systems is ideal but it may be better for long-term use to link the NTFS partition first, then make additional links from there.
For brevity I'll assume a link from the NTFS filesystem in
.ntfsis made in
~. If the previous advice about user creation was followed, then the below will work as provided with no changes necessary.
To make these links easily, here's a basic shell script you can save,
chmod +x and use with
.sh in the Bash shell to create links for the five most-used home directories, for any terminal emulator (
mate-terminal or whatever
x-terminal-emulator is as specified by
# Replace "$USER" with specific usernames if necessary! ### Duplicate old contents (if any) cp -R ~/Documents ~/.ntfs/Users/$USER/Documents cp -R ~/Downloads ~/.ntfs/Users/$USER/Downloads cp -R ~/Pictures ~/.ntfs/Users/$USER/Pictures cp -R ~/Music ~/.ntfs/Users/$USER/Music cp -R ~/Videos ~/.ntfs/Users/$USER/Videos ### Delete folders rm -rf ~/Documents ~/Downloads ~/Music ~/Pictures ~/Videos ### Make symbolic links of directories to supersede ln -s ~/.ntfs/Users/$USER/Documents ~/Documents ln -s ~/.ntfs/Users/$USER/Downloads ~/Downloads ln -s ~/.ntfs/Users/$USER/Music ~/Music ln -s ~/.ntfs/Users/$USER/Pictures ~/Pictures ln -s ~/.ntfs/Users/$USER/Videos ~/Videos
If you needed to use another partition instead because the NTFS partition Windows resides on is compressed or encrypted, then use Windows Explorer to change the location of the library file contents so they reside in the same working partition that will be in use when you boot into the other OS.
It's not easy to create a dual-boot setup. But after you're finished with initial configuration, it should be easy to maintain, and a great way to hop in head-first without losing any of your files. And when you decide the whole Linux thing isn't for you, everything about it can be deleted. If it happens the bootloader was written where Windows is, you might want to see my guide about ms-sys to fix Windows if the Windows installation media is unavailable; this can be done from the same media you used to install the system you're removing.