Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maxsei/5044fe1302aa7cf4bdddf74d4eac2d3e to your computer and use it in GitHub Desktop.
Save maxsei/5044fe1302aa7cf4bdddf74d4eac2d3e to your computer and use it in GitHub Desktop.
# How to Dual-Boot Arch Linux on my Lenovo t440 ThinkPad using a USB
## Overview
## From Boot Format to Factory Format
1. Open press **Win+R** to open up **Run**
2. Type **diskpart** and press **Enter**
3. `$ list disk` to list all available drives
4. `$ select disk x` (where X is the disk number of the USB drive) to select the disk to format
5. `$ clean` will wipe the drive selected (may need to run more than once if it fails)
6. `$ create partition primary` creates a single primary partition on the USB
8. `$ active` marks the current partition as active
9. `$ format fs=fat32 quick` formats the hard drive with fat32 formatting schema
10. `$ exit` to exit the terminal
11. The drive is not formatted back to factory
## From Factory Format to Boot Format
1. Open **msys2 terminal as Administrator**
2. Change directory to where the boot iso is `$ cd ../archlinux-2019.03.01-x86_64.iso`
3. `$ cat /proc/partitions` to view the partitions and disk names of all available drives. **Make note of the drive you want to format** something like **sdx** (where x is the drive letter)
4. Run disk dump (also known as disk destroyer be careful!) to modify permanently the contents of the drive selected. Input file is the location of the .iso, the output file is the drive partition, and the boot size is 4M. The progress of this command is monitored with the *status=progress* option. `$ dd if=archlinux-2019.03.01-x86_64.iso of=/dev/sdx bs=4M status=progress oflag=sync` **WARNING THIS REMOVES EVERYTHING FROM THE DRIVE SELECTED**
5. The USB should now have bunch of wacky file names like: *mw>╩ßt'. *
## Allocating Hard Drive Space for Arch in Windows
1. Type **disk management** in the windows search and select **create and format hard disk partitions**
2. Right click the c drive and select **shrink volume** which will wipe any data within the shrinked end of the partition
3. Shrink the drive, in MB, the amount of space needed to be dedicated to arch linux and click ok (minimum of 32GiB)
## Booting from USB
1. Restart the system and press **F12** on startup
2. Select the **boot menu** and make sure the bios is set to **UEFI MODE ONLY**
3. Disable secure boot and press **F10** to save changes and reboot
4. Again press **F12** on startup
5. Select **Use a Device** and then select **Boot Menu**
6. Inside the boot menu select **USB HDD: Mass Storage Device**
7. Select **Boot Arch Linux (x86_64)**
## Adding Linux Partitions to Hard Drive
1. Do these steps **after booting from USB**
2. `$ cfdisk /dev/sdx`to enter the drive partition program with X drive (where X is the letter of the hard drive)
3. Create a new partition with size of 150% of RAM size, Linux swap (code 8200), and name "Linux SWAP" for the swap partition.
4. Create a new partition with size of 20G, Linux filesystem, and name "Linux Root" for the root partition.
4. Create a new partition with all defaults except the name "Linux Home" for the home partition.
5. Write the changes to the disk with the "Write" option then quit the program
6. The boot partition is going to be the EFI windows partition so nothing to be done with making a boot partition
## Creating Linux File Systems
1. TO create a file system for the swap partition do `$ mkswap /dev/sdxy` where **x** is the **drive letter** and **y** is the **partition number** of the swap partition
2. To create a file system for the root partition do `$ mkfs.btrfs -f /dev/sdxy` where **x** is the **drive letter** and **y** is the **partition number** of the root partition
3. To create a file system for the home partition do `$ mkfs.btrfs -f /dev/sdxy` where **x** is the **drive letter** and **y** is the **partition number** of the home partition
## Mounting the File Systems
1. mount the swap drive with `$ swapon /dev/sdxy` where **x** is the **drive letter** and **y** is the **partition number** of the swap drive
2. mount the root partition with `$ mount /dev/sdxy /mnt`where **x** is the **drive letter** and **y** is the **partition number** for root
3. make directories for the boot and home to mount to by doing `$ mkdir /mnt/boot && mkdir /mnt/home`
4. mount the boot partition with `$ mount /dev/sdxy /mnt/boot`where **x** is the **drive letter** and **y** is the **partition number** for the windows bootloader
5. mount the home partition with `$ mount /dev/sdxy /mnt/home`where **x** is the **drive letter** and **y** is the **partition number** for home
# Generating File Systems Table
1. `$ genfstab -U -p /mnt >> /mnt/etc/fstab`generates a filesystem table u option is UUID
2. `$ vim /mnt/etc/fstab` to verify it wrote properly. There should be four file systems in the table.
# Installing Arch Linux
1. make sure you have ethernet plugged into the device or do `$ wifi-menu` to configure wifi
2. check the connection with `$ ping -c 1 google.com`
3. install arch with base packages, tools, and vim with `$ pacstrap /mnt base base-devel vim`
4. To enter the HDD of the install do `$ arch-chroot /mnt `
# Getting a Network Manager on Statup
1. `$ pacman -S networkmanager`
2. `$ systemctl enable NetworkManager` creates system links to start program on startup
# Time, Language, and Hostname/Password Configuration
1. `$ vim /etc/locale.gen` press insert to uncomment line with "en_US.UTF-8 UTF-8" write and quit with ":wq"
2. `$ vim /etc/locale.conf` creates a new file and write "LANG=en_US.UTF-8". write and quit with ":wq" to save a language configuration
3. `$ locale-gen` to finalize locale
4. `$ vim /etc/hostname` and just type your hostname on the first line do ":wq" to write and quit.
5. do `$ passwd` to set a password
6. `$ ls /usr/share/zoneinfo/` lists all time zones
7. `$ ln -sf /usr/share/zoneinfo/{country/region} /etc/localtime` link zoneinfo to localtime
8. `$ hwclock --systohc --utc` set the time of your computer
9. `$ timedatectl set-ntp true` to enable time syncronization with timezone
# Grub Install and Configuration
1. do `$ pacman -S grub` to install grub
2. do `$ pacman -S efibootmgr` to get efibootmgr that is needed for booting on a UEFI computer
3. install grub on the bootloader with EFI with `$ grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --recheck /dev/sdx` where x is the drive letter
# Rebooting
1. do `$ exit` to get back to the USB
2. `$ umount -a` to unmount HDD partitions from USB
3. `$ reboot` I hope this works
# GRUB Bootmenu and Arch Congiguration
* Log in with your previous password
* Then to set up a new user do `$ useradd -m -g users -G wheel -s /bin/bash yourusernamehere`
* `passwd yourusernamehere` to set up password for user
* `vim etc/sudoers` to do sudo privledge for users in the wheel group without using a password uncomment **%wheel ALL=(ALL) NOPASSWD: ALL**
* `$ pacman -S os-prober` to get the package
* `$ os-prober` run os prober
* `$ grub-mkconfig -o /boot/grub/grub.cfg` to make grub configuration file at that directory
## Commands
* `$ pacman -S efibootmgr`
* `$ grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB`
* `$ cfdisk /dev/sdx` make a new partition of 100M with type EFI System
* `$ pacman -S os-prober` to get the package
* `$ os-prober` run os prober
* `$ mkdir esp/EFI/boot`
* `$ cp esp/EFI/grub_uefi/grubx64.efi esp/EFI/boot/bootx64.efi`
* `$ grub-mkconfig -o /boot/grub/grub.cfg` to make grub configuration file at that directory
* install grub on the bootloader with EFI with `$ grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB --recheck /dev/sdx` where x is the drive letter
## Notes
* Windows forces type of partitioning depending on the firmware mode used
* In case where Windows and Linux dual boot from the same disk, it is advisable to follow the method used by Windows
* Disable Secure Boot
* disable fast startup on windows
* windows has file path max length of 260 chars
* The Windows installation will create the EFI system partition which can be used by your Linux boot loader.
# Trouble shoot ethernet
* `$ ip link` to list network devices
* `$ ip link set dev enp0xxx up` wehere enp0xxx is the the ethernet device to set up
* `$ ping -c 1 google.com` to test connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment