Skip to content

Commit

Permalink
Initial working
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeslattery committed Jan 17, 2020
0 parents commit fb102de
Show file tree
Hide file tree
Showing 23 changed files with 4,149 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
root = true

[*]
indent_style = space
insert_final_newline = true

[*.{cmd,bat}]
end_of_line = crlf
indent_size = 4

[*.{ps1,psm1,psd1}]
end_of_line = crlf
indent_size = 4
trim_trailing_whitespace = true

[*.{ps1xml,props,xml.yaml,yml}]
indent_size = 2

[*.sh]
end_of_line = lf
indent_size = 2

10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto

*.ps1 text eol=crlf
*.psm1 text eol=crlf
*.psd1 text eol=crlf
*.cmd text eol=crlf
*.bat text eol=crlf

*.sh text eol=lf

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tmp
tunic.exe

*.ova
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Tunic

Install Linux on Windows without a Live USB.

The goal is a program that can install Linux on an existing Windows machine without need of a Live USB or making firmware/BIOS changes.

## Status

This project is pre-alpha quality.
We do not suggest you use on real hardware; use inside a virtual machine or on a computer you don't care about damaging.

### Requirements

* Windows 10, 64 bit
* Single unencrypted hard drive hosting the C: volume
* UEFI
* At least 4 GB RAM
* At least 15 GB of free disk space on C:
* Administrator user permissions
* Internet access

### Limitations

* Currently, Tunic only installs [Linux Mint with Cinnamon, 64 bit](https://blog.linuxmint.com/?p=3832).
* We are working on support for Windows 7 and 8, and other Debian/Ubuntu based Linux distros.
* There are no short term plans for MBR or 32 bit support.
* Error handling needs improvement. A failed install could leave the system in an undesirable state.

### What Tunic Does

1. Asks all questions at beginning
1. Offers full disk overwrite or dual boot arrangement.
1. If dual boot, shrink C: volume to make space for Linux. May require reboot.
1. Download the Linux .iso file
1. Install Grub with Secure Boot support
1. Reboot and run the Ubiquity installer, automated
1. Reboot into Linux!

## Getting Started

### Preparation

Backup your data!

Before you start, make sure to backup up your entire disk(s).
Tunic does not assist with full disk backup.
Read disclaimer for more information.

### Usage

1. Download and run the latest .exe file from releases.
1. Answer questions.
1. Let it run and walk away. It can take up to an hour.
1. Enjoy your new Linux OS!

## More information

See the docs directory for more information.

## Legal Stuff

### License

Copyright (c) 2020 Michael Slattery. See commit history for list of other authors.

Distributed under the [GNU General Public License, version 3](https://www.gnu.org/licenses/gpl-3.0.en.html).

### Disclaimer

This software could inadvertantly and permanently destroy all data, leave a computer unbootable,
or otherwise leave a computer in an undesirable state.
This software comes as-is with absolutely no warranty.
In no event shall shall the authors be held liable for damages arising out of use of this software.
Read sections [15, 16, and 17](https://www.gnu.org/licenses/gpl-3.0.en.html#section15) of the GNU GPL version 3 license for more information.

89 changes: 89 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Windows build script

# This is only for packaging a convenient, self-extracting .exe.
# tunic.ps1 is usable without packaging.

# Install tools

Set-StrictMode -version 1.0
$ErrorActionPreference = 'Stop'

mkdir -force tmp
$web = (New-Object System.Net.WebClient)

if( ! (get-installedmodule -name ps2exe -errorAction silentlyContinue) ) {
install-packageprovider -name nuget -force
Install-Module -force -confirm:$false ps2exe
}

if( ! ( Get-Command "7z" -ErrorAction SilentlyContinue ) ) {
if( ! ( Get-Command "choco" -ErrorAction SilentlyContinue ) ) {
iex $web.DownloadString('https://chocolatey.org/install.ps1')
}
choco install -y 7zip
}

if( ! ( test-path "$PWD\tmp\7zSD.sfx" -errorAction SilentlyContinue) ) {
$web.downloadFile('https://www.7-zip.org/a/lzma1900.7z', "$PWD\tmp\lzma.7z")
7z e "$PWD\tmp\lzma.7z" -otmp bin\7zSD.sfx
}

#TODO: remove?
#$web = (New-Object System.Net.WebClient)
#iex $web.DownloadString('https://chocolatey.org/install.ps1')
#choco install -y nsis-advancedlogging
#$env:PATH += ";C:\Program Files (x86)\NSIS\Bin"

function Test-Syntax
{
[CmdletBinding(DefaultParameterSetName='File')]
param(
[Parameter(Mandatory=$true, ParameterSetName='File', Position = 0)]
[string]$Path,

[Parameter(Mandatory=$true, ParameterSetName='String', Position = 0)]
[string]$Code
)

$Errors = @()
if($PSCmdlet.ParameterSetName -eq 'String'){
[void][System.Management.Automation.Language.Parser]::`
ParseInput($Code,[ref]$null,[ref]$Errors)
} else {
[void][System.Management.Automation.Language.Parser]::`
ParseFile($Path,[ref]$null,[ref]$Errors)
}

return [bool]($Errors.Count -lt 1)
}

Test-Syntax 'tunic.ps1'

# Clean

Remove-Item tmp\lzma.7z -ErrorAction Ignore
Remove-Item tunic-script.exe -ErrorAction Ignore
Remove-Item tunic.exe -ErrorAction Ignore
Remove-Item tmp\tunic.7z -ErrorAction Ignore

# Convert tunic.ps1 to tunic-script.exe

invoke-ps2exe -inputfile tunic.ps1 -outputfile tunic-script.exe `
-title Tunic `
-credentialsGUI -requireAdmin `
-noconsole -nooutput -noerror

# Package self-extracting .exe

7z a tmp\tunic.7z tunic.ps1 tunic-script.exe files\*

gc -Encoding Byte -Path "tmp\7zSD.sfx","files\7z.conf","tmp\tunic.7z" `
| sc -Encoding Byte tunic.exe

copy tunic.exe ~\Desktop\tunic.exe

# Clean

Remove-Item tunic-script.exe -ErrorAction Ignore
Remove-Item tmp\tunic.7z -ErrorAction Ignore

158 changes: 158 additions & 0 deletions doc/REFERENCES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Reseach and References

## References

### Backup and Recovery

* https://www.howtogeek.com/167984/how-to-create-and-restore-system-image-backups-on-windows-8.1/
* https://en.wikipedia.org/wiki/Comparison_of_disk_cloning_software
* http://odin-win.sourceforge.net/
* http://www.invoke-ir.com/2015/06/ontheforensictrail-part3.html
* https://devblogs.microsoft.com/scripting/use-powershell-to-interact-with-the-windows-api-part-1/
* https://code.msdn.microsoft.com/windowsapps/CCS-LABS-C-Low-Level-Disk-91676ca9
* https://tuxboot.org/

### Cleanup

* https://social.technet.microsoft.com/Forums/en-US/d053e005-c5fd-45bd-9bab-0379f31dba7a/how-to-set-the-no-paging-file-option-within-a-powershell-script?forum=ITCG
* https://stackoverflow.com/questions/37813441/powershell-script-to-set-the-size-of-pagefile-sys
* https://gallery.technet.microsoft.com/scriptcenter/Script-to-delete-System-4960775a
* https://superuser.com/a/1347749
* https://www.tenforums.com/tutorials/4189-turn-off-fast-startup-windows-10-a.html
* https://windowsreport.com/delete-system-error-memory-dump-files-in-windows/
* https://stackoverflow.com/questions/6035112/disable-application-crash-dumps-on-windows-7

### Install Linux

* https://phoenixnap.dl.sourceforge.net/project/osboxes/v/vb/31-Lx-M-t/19.2/Cinnamon/19-2C-64bit.7z
* https://www.groovypost.com/howto/dual-boot-windows-10-linux/
* https://www.dell.com/support/article/us/en/04/sln151664/how-to-install-ubuntu-linux-on-your-dell-pc

### Downloads

* https://github.com/unetbootin/unetbootin/blob/master/src/unetbootin/distrolst.cpp

### ISO

* https://askubuntu.com/questions/484434/install-ubuntu-without-cd-and-usb-how
* https://blogs.gnome.org/muelli/2016/08/remastering-a-custom-ubuntu-auto-install-iso/
* https://github.com/core-process/linux-unattended-installation/

### VM

* https://www.perkin.org.uk/posts/create-virtualbox-vm-from-the-command-line.html
* https://www.oracle.com/technical-resources/articles/it-infrastructure/admin-manage-vbox-cli.html
* https://www.virtualbox.org/ticket/8760 - locking
* https://www.howtogeek.com/213145/how-to%C2%A0convert-a-physical-windows-or-linux-pc-to-a-virtual-machine/ggj
* https://app.vagrantup.com/Microsoft/boxes/EdgeOnWindows10
* https://github.com/samrocketman/vagrant-windows/blob/master/windows10/Vagrantfile
* https://www.vagrantup.com/docs/provisioning/shell.html

### Testing and Support

* https://www.microsoft.com/en-us/download/details.aspx?id=8002 - XP
* https://www.makeuseof.com/tag/download-windows-xp-for-free-and-legally-straight-from-microsoft-si/

### Boot Menu

#### Repartitioning

* http://www.smorgasbork.com/2019/04/23/fedora-windows-10-dual-boot-on-dell-inspiron/
* https://docs.microsoft.com/en-us/powershell/module/bitlocker/suspend-bitlocker?view=win10-ps

#### Swap file
* https://serverfault.com/questions/558069/use-wmi-to-remove-a-page-file
* https://www.c-sharpcorner.com/Blogs/disk-cleanup-using-powershell-scripts

#### MBR

* https://www.linuxquestions.org/questions/linux-general-1/using-bcdedit-to-configure-a-multiboot-system-and-add-linux-4175644308/
* https://wiki.archlinux.org/index.php/Dual_boot_with_Windows/SafeBoot
* https://docs.microsoft.com/en-us/windows/deployment/mbr-to-gpt

#### EFI

* https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-and-gpt-faq
* https://wiki.archlinux.org/index.php/EFI_system_partition
* https://forums.linuxmint.com/viewtopic.php?t=300030
* https://askubuntu.com/questions/342365/what-is-the-difference-between-grubx64-and-shimx64
* https://wiki.archlinux.org/index.php/EFI_system_partition
* https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/bcd-system-store-settings-for-uefi
* http://www.rodsbooks.com/linux-uefi/
* https://neosmart.net/wiki/bcdedit/
* https://askubuntu.com/questions/831216/how-can-i-reinstall-grub-to-the-efi-partition
* https://www.codeproject.com/Articles/833655/Modify-Windows-BCD-using-Powershell

### Automated Install

#### Ubiquity

* https://code.launchpad.net/ubiquity
* https://wiki.ubuntu.com/UbiquityAutomation
* https://github.com/linuxmint/ubiquity/blob/master/d-i/source/preseed/debian/file-preseed.postinst
* https://github.com/linuxmint/ubiquity/blob/master/bin/ubiquity
* https://github.com/linuxmint/ubiquity/blob/master/d-i/source/preseed/preseed.sh

#### Preseeding

* https://www.leifove.com/2016/11/fully-automated-linux-mint-desktop.html
* https://help.ubuntu.com/lts/installation-guide/armhf/apbs02.html
* https://askubuntu.com/questions/1002043/how-to-an-unattended-installation-of-ubuntu-16-04-on-a-disk-with-existing-os
* https://github.com/core-process/linux-unattended-installation/tree/master/ubuntu/18.04/custom
* https://www.leifove.com/2016/11/fully-automated-linux-mint-desktop.html
* https://debian-handbook.info/browse/stable/sect.automated-installation.html
* https://help.ubuntu.com/lts/installation-guide/example-preseed.txt
* https://www.debian.org/releases/stable/example-preseed.txt
* https://www.packer.io/guides/automatic-operating-system-installs/preseed_ubuntu.html
* https://askubuntu.com/questions/457528/how-do-i-create-an-efi-bootable-iso-of-a-customized-version-of-ubuntu
* https://askubuntu.com/questions/806820/how-do-i-create-a-completely-unattended-install-of-ubuntu-desktop-16-04-1-lts
* https://github.com/hvanderlaan/ubuntu-unattended
* https://wikitech.wikimedia.org/wiki/PartMan
* https://wikitech.wikimedia.org/wiki/PartMan/Auto
* https://github.com/xpeppers/provisioning-example
* https://wiki.ubuntu.com/Enterprise/WorkstationAutoinstallPreseed
* https://help.ubuntu.com/lts/installation-guide/amd64/apbs04.html#preseed-partman

### Keyboard
* https://github.com/linuxmint/ubiquity/blob/master/ubiquity/misc.py#L672
* https://wiki.archlinux.org/index.php/Linux_console/Keyboard_configuration
* https://github.com/alexriss/keyboard-layout-converter

#### Kickstart

* https://help.ubuntu.com/community/KickstartCompatibility
* http://gyk.lt/ubuntu-16-04-desktop-unattended-installation/

#### Migration

* https://git.launchpad.net/ubiquity/tree/ubiquity/plugins/ubi-migrationassistant.py?id=251afaeba2ee760267bd0253d24ffa6b668239a2

### Post Install

These are things that can be used after the install for better integration between the partitions.

* https://www.glump.net/howto/desktop/seamless-remote-linux-desktop-in-windows
* https://www.reddit.com/r/linuxquestions/comments/e964o5/way_to_reboot_to_windows_from_within_linux/

### Powershell

* https://ss64.com/ps/syntax-elevate.html

#### GUI
* https://theitbros.com/powershell-gui-for-scripts/
* https://lazyadmin.nl/powershell/powershell-gui-howto-get-started/
* https://poshgui.com/Editor
* https://github.com/MScholtes/PS2EXE
* https://stackoverflow.com/questions/21607593/powershell-form-layout

#### 7Zip
* https://superuser.com/questions/42788/is-it-possible-to-execute-a-file-after-extraction-from-a-7-zip-self-extracting-a#42792
* https://github.com/CommitteeOfZero/lzma-sdk/blob/master/DOC/installer.txt
* https://www.7-zip.org/download.html

#### Timezone
* https://github.com/mj1856/TimeZoneConverter
* https://dejanstojanovic.net/aspnet/2018/july/differences-in-time-zones-in-net-core-on-windows-and-linux-host-os/
* https://github.com/unicode-org/cldr/blob/master/common/supplemental/windowsZones.xml
* http://www.unicode.org/cldr/charts/latest/supplemental/zone_tzid.html

Loading

0 comments on commit fb102de

Please sign in to comment.