Skip to content

Instantly share code, notes, and snippets.

@yuq-1s
Last active February 28, 2019 11:16
Show Gist options
  • Save yuq-1s/ca8184158d0ff46ca371f48f1ab1a66e to your computer and use it in GitHub Desktop.
Save yuq-1s/ca8184158d0ff46ca371f48f1ab1a66e to your computer and use it in GitHub Desktop.
Build my own workstation with hybrid disk and dual boot

workstation

Goal

Dual boot Ubuntu 18.04 and Windows 10

Windows occupies an 128GB ssd for gaming Ubuntu occupies a 256GB ssd and two same 1TB hdd with raid0 grouped by bcache.

Installing Windows 10

  1. Download Windows 10 Home edition from SJTU ftp

Note: The ISO from official site won't work

  1. Burn it to a DVD

There are various ways to create an installer. My usb disk failed with a missing driver error so I had to burn it to a DVD (with UltraISO on a Windows 7).

  1. Install windows on the 128GB disk following the guide.

Installing Ubuntu 18.04

Download

Download desktop live ubuntu-18.04.1-desktop-amd64.iso and burn it into a media

Partition

Boot with the media and select "Try Ubuntu"

partition disks with gparted:

SSD (/dev/nvme0n1):

Space Format Usage block device after partition
1024MB ext4 /boot /dev/nvme0n1p1
rest (any) cache /dev/nvme0n1p2

both HDD (/dev/sda and /dev/sdb):

Space Format Usage block device after partition
550MB fat32 EFI,ESP /dev/sda1
16384MB swap raid /dev/sda2
rest (any) raid /dev/sda3
sudo apt install mdadm
# create raid for swap
sudo mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sda2 /dev/sdb2
# create raid for storage
sudo mdadm --create --verbose /dev/md1 --level=0 --raid-devices=2 /dev/sda3 /dev/sdb3
sudo apt install bcache-tools
sudo wipefs -a /dev/md1
sudo wipefs -a /dev/nvme0n1p2
sudo make-bcache -B /dev/md1 -C /dev/nvme0n1p2

For partition, select /dev/bcache0 and it prompts to create a partion /dev/bcache0p1

/dev/bcache0p1   - format EXT4, use as /
/dev/nvme0n1p1   - format EXT4, use as /boot
/dev/sda1        - EFI partition
/dev/md0         - swap

Use /dev/sda1 as EFI or the installation won't success

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo mount /dev/bcache0p1 /mnt
sudo mount /dev/nvme0n1p1 /mnt/boot
sudo mount /dev/sda1 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo cp /etc/resolv.conf /mnt/etc/resolv.conf
sudo cp /etc/mdadm/mdadm.conf /mnt/etc/mdadm/mdadm.conf # will this work?
sudo chroot /mnt
sudo apt-get update
sudo apt-get install mdadm bcache-tools
# setup swap disk
sudo echo '/dev/md0 /mnt/md0 swap defaults 0 0' | sudo tee -a /etc/fstab
# no need to `update-initramfs -u` because installing bcache-tools has
# done it for you
exit
for i in /mnt/boot/efi /mnt/boot /dev/pts /dev /proc /sys /run; do sudo umount $i /mnt$i; done
sudo umount /mnt # this failed on my computer saying the device is busy
sudo reboot # but reboot anyway.

At this time, my computer failed to start after removing live disk.

So enter live disk again and restore the file system

sudo apt install mdadm bcache-tools
sudo mdadm --assemble /dev/md0 /dev/sda2 /dev/sdb2
sudo mdadm --assemble /dev/md1 /dev/sda3 /dev/sdb3
echo /dev/md1 | sudo tee /sys/fs/bcache/register
# this will quit with error but makes /dev/bcache0
sudo make-bcache -B /dev/md1

By then, If you mount /dev/bcache0, you will see the installed system.

Try sudo grub-install /dev/nvme0n1. If that fails, run sudo dpkg-reconfigure grub-pc --frontend=text as shown in the guide

Make dual boot

If grub doesn't find windows, run sudo update-grub in ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment