Ubuntu 管理心得

搜尋此網誌

2021年1月13日 星期三

Add ubuntu to preinstalled windows 10 in efi gpt disk

  1. Assume the disk contains the efi partition, say /dev/sda2, and windows partition, say /dev/sda3 
  2. Use Ubuntu live USB to boot up the computer
    ATTENTION: Boot the usb drive (e.g, My 64GB Jetflash)
    MUST! MUST! select the
    UEFI: JetFlashTranscend 64GB 1100, Partition 3
    to boot
    Otherwise, the efi will not work!
    (Chiao, 2020-4-25)
  3. Using vmware to install ubuntu for uefi bios, make sure this


  4. Resize windows partition /dev/sda3:
    • get 100GB space for /dev/sda4, format sda4 as ext4, mount /dev/sda4 to /mnt/4, 
    • get 1GB for /dev/sda5, format sda5 as Linux SWAP
  5. Untar (or rsync) the required ubuntu system completely to /mnt/4
  6. cd /mnt/4
    sudo mount -B /dev dev
    sudo mount -B /dev/pts dev/pts
    sudo mount -B /proc proc
    sudo mount -B /sys sys
    sudo mount -B /run run
    cd /
    sudo chroot /mnt/4
    vim /etc/hosts, add this line:
    140.110.240.80 tw.archive.ubuntu.com 
    mount /dev/sda2 /boot/efi
    apt purge grub-pc
    apt update
    apt install grub-efi
    (Yes! Do not use aptitude to install grub-efi*. )
    update-grub
    grub-install
  7. If grub-install failed, try purge all grub2:
    apt purge grub2*
    then install again:
    apt install grub-efi
  8. Also, try this:
     grub-install --target=x86_64-efi --efi-directory=/boot/efi
  9. Edit /etc/fstab for root, swap, and /boot/efi
    Use blkid for efi:/dev/sda2, root:/dev/sda5, swap:/dev/sda6
    Then replace the blkids' in /etc/fstab
  10. umount /boot/efi
  11. exit
  12. sudo umount /mnt/4/dev/pts
    sudo umount /mnt/4/dev
    sudo umount /mnt/4/proc
    sudo umount /mnt/4/sys
    sudo umount /mnt/4/run
  13. (20210623)In case of bios not being able to change boot order for ubuntu, try this inside Windows cmd shell (administrator mode):
    bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi

    (cf: https://askubuntu.com/questions/485261/change-boot-order-using-efibootmgr)
    Enter into asus uefi bios setting. The 'ubuntu' is still not at the first order. However, when  at startup, the ubuntu will show up instead of  Windows. Damn good! Oh My!
  14. (20220504) If the error message:
    mount: /var/lib/grub/esp: special device /dev/disk/by-id/nvme-ADATA_SX8200PNP_2J5220164962-part1 does not exist.
    comes out at step "apt purge grub-pc", then
    sudo ln -s /dev/disk/by-id/ata-VMware_Virtual_SATA_CDRW_Drive_01000000000000000001 /dev/disk/by-id/nvme-ADATA_SX8200PNP_2J5220164962-part1
  15. However, after following the above steps, there may not be back to the exact same PC as before because no grub boot menu is shown when reboot.  As a last resort, it needs to create a new partition and install a new ubuntu on it. I think the installation process will safely and totally find the windows partition and list in the grub menu. (20221216)
  16. YES! boot order in bios must be changed for ubuntu being the first one.
  17. (20240903) In case of using static IP in old server, make sure to change it to dhcp after reboot the clone server. 
  18. Under vmware, two important things,
    Select Ubuntu 64bit for guest OS.
    Change to UEFI in Options->Advanced
    Before starting to create Ubuntu guest OS (2024-10-12)


沒有留言:

張貼留言

網誌存檔