Tag Archive : uefi

/ uefi

This is short notes on how I create a dual boot machine with Windows 8 and Slackware64. Both are 64-bit operating system and will be installed on UEFI-based computer with GPT disk layout.

Actually I do this around in earlier year 2013, so this article might not up to date. However it should work because we use general method.

In this article, i use:

  1. Microsoft Windows 8 64-bit, installation disc
  2. Slackware64 14.0, installation disc
  3. Lenovo Ideapad Z480
  4. USB disk

Note that I do the scenario (would be) mentioned because my machine is fresh and I will do it from scratch.

About Machine

Lenovo Ideapad Z480 has following specification (main):

  1. Intel Core i7-3632QM
  2. RAM 4 GB
  3. HDD 1TB
  4. Video RAM NVidia GeForce GT640

However, I also give addition to RAM so in result I have 8GB RAM.

At default, it is not using UEFI so I activated UEFI capability.

I also convert the disk format from MBR to GPT, however I do this later.

General Overview

The problem arise before me is the fact that the Windows 8 installation DVD not support UEFI yet. Therefore I cannot boot the DVD in UEFI.And also, Windows 8 cannot be installed on GPT disk, yet. At that time Slackware also does not support UEFI, yet. But, it can be installed in GPT partition, good thing to know. Therefore I need a bootable USB disk to boot Slackware then create everything I need for installing Linux.

The scenario in this article:

  1. Create partition
  2. Install Windows 8 while the disk still use MBR layout.
  3. Install Slackware64 14.0 with GPT disk
  4. Finalizing, installing and configuring bootloader

Preparation

I use a companion Linux in bootable USB stick. I create a USB stick with UEFI capable. You can download it from here.

Make a partition for USB stick with FAT32 partition and boot flag enabled. You can use either gparted or gdisk (in Linux) to accomplish it.

Just extract what inside the archive to USB stick. Make sure there are two folders: EFI and Slackware64.

Step 1: Create Partition

Boot the machine using Windows installer DVD. I need to create a partition for MBR disk. In my case I create these primary partitions:

  1. boot partition, located on partition 1 with FAT32 file system, takes about 100MB.
  2. Reserved partition, used by Windows, create it for 350MB capacity.
  3. Windows partition, NTFS, I use 100GB
  4. Linux Partition, unallocated, I use 100GB

Those are the partition I need at the moment. The rest will be create at finalizing stage.

Here, once the Windows 8 installation DVD is booted, do normal installation routine. Once we got on media selection (where we install Windows), press [Shift] + F10. This will bring command prompt. Invoke following command:

diskpart

Now we will do partitioning. I’m using only one disk, so the disk should be recognized as disk 0. Also, I don’t use GPT at this section, it would be after installation of Windows 8.

select disk 0
clean

create partition primary size=100
format quick fs=fat32 label="System"

create partition msr size=350
format quick fs=ntfs

create partition primary size=100000
format quick fs=ntfs

create partition primary size=100000

Step 2: Installing Windows 8

Still using Windows 8 installation DVD, exit the command prompt. Now I’m refreshing the list so we will know all of the partition available.

I continue installing Windows like usual on partition 3.

Once the installation finish, go to step 3.

Step 3: Installing Slackware64

I need to do some preparation first. Therefore, there would be some subsections for this.

Convert MBR to GPT

Boot the USB stick.

Conversion is inherently risky. For safety, I backup the original configuration before converting the disk. The MBR itself is stored on the first sector of the disk and can be backed up with dd by:

dd if=/dev/sda of=backup.mbr bs=512 count=1

Then I run gdisk for disk on /dev/sda

gdisk /dev/sda

Follow the option menu for conversion MBR to GPT, and I done.

Prepare the Installation Environment

Mount the USB stick. I accomplish this by invoking following command:

mkdir /src
mount /dev/sdb1 /src

Invoke setup and adjust the setting like normal installation until you reach installation media stage.

Press ALT+F2 to switch to another screen (or another tty).

Install temporary system using USB stick. Invoke these commands:

cd /src/slackware64
installpkg -root /mnt [az]*/* cd

Installation

Now, back to our main setup and choose install from CD/DVD. Also, I won’t use LILO, instead I use ELILO. So I don’t install LILO.

After installation is finished, I don’t restart the machine immediately. Instead, I go to last step: Finalizing.

Step 4: Finalizing

First, make sure we are still boot the machine using USB stick, then load following command:

modprobe efivars

Also, I need to mount the boot partition

mount /dev/sda1 /mnt/boot/efi

Add Bootstrap to Slackware

I invoke following command. Note that these commands should be invoked as is, even a dot matters. If you remember, the Slackware is installed on 4th partition.

mount /dev/sda4 /mnt/root
cd /mnt/boot/efi
cp -rvf /src/EFI /mnt/boot/efi
cd /mnt/boot/efi/EFI
mv BOOT Slackware
cd Slackware
mv bootx64.efi elilo.efi
cp /mnt/root/boot/vmlinuz-huge-3.2.29 .
vi elilo.conf

And I configure the elilo.conf:

prompt
image = vmlinuz-huge-3.2.29
label = Slackware
root = /dev/sda4

And register boot so that machine can boot Slackware.

cd /mnt
usr/bin/efibootmgr -c -L "XathryaSlackBoot" -l "\\EFI\\Slackware\\elilo.efi"

Add Bootstrap to Windows

Eject the Slackware installation disc and insert Windows 8 installation disc. I need to copy all files needed to boot EFI from Windows 8 disc.

cd /mnt/boot/efi
mkdir /mnt/disc
mount /dev/sd1 /mnt/disc
cp -R /mnt/disc/efi/microsoft /mnt/boot/efi

That will copy “microsoft” folder and whole of it’s content to /mnt/boot/efi (which is my mounted efi boot partition).

Now, to create a bootstrap we first need to restart the machine and boot with Windows 8 installation DVD. What we will do is repair the Windows 8 EFI bootloader.

I do normal installation sequence method until I was prompted with list of volumes / partitions. Now press [Shift] + F10. A new command prompt appear.

Now invoke following command, which will bring me to diskpart (disk partition) program:

diskpart

My disk is only one, so I will use disk 0.

sel disk 0

Because the EFI partition is the very first partition (/dev/sda1), it should be registered as earlier volume. However, it doesn’t have drive letter, so I will give it one.

diskpart

sel vol 1
assign letter b:

The attempt is successful and I’m prompted by a message which tell me that the volume has been assign to letter B. Now leave the diskpart with exit command. Go to the EFI partition and add the EFI bootstrap.

cd /d b:\EFI\Microsoft\Boot\
bootrec /fixboot
ren BCD BCD.bak
bcdboot C:\Windows /l en-us /s B: /f ALL

bootrec (boot recover) will fix the UEFI bootloader.

bcdboot will be used to recreate BCD store. The C:\Windows is path where Windows is installed and B: is drive of my EFI partition. The “/f ALL” parameter updates the BIOS settings including UEFI firmware/NVRAM while /l en-us is to localize for US locale (US English).

Add More Partitions

I need more partitions so I create them. I use gdisk for this.

Repair Windows 8 EFI Bootloader

December 5, 2015 | Article | 2 Comments

Suppose you have installed Windows 8 on your machine. After an unexpected incidents you can not boot your Windows anymore, what will you do? Reinstall? No, let’s fix it!
This article will discuss about how to repair / fix Windows 8 Bootloader. For simplification, we have following assumption:

  1. Our machine is EFI-based with GPT disk (thus have EFI partition on first partition)
  2. You have Windows 8 installer (yes, we use installer DVD to do)

Now boot into your machine wit Windows 8 installer. Do normal method until you are prompted with list of volumes / partitions. Now press [Shift] + F10. This will bring you alovely black-themed cmd 😀

Now invoke following commands:

diskpart

Then you will be brought to a diskpart program. First we must now what your disk (the one windows 8 installed). To do so we will issue this command:

list disk

Now you will see a list of disk you have numbered by a value from 0. In this article I assume we have 1 disk and the installed windows on disk 0. If not, change 0 with appropriate number. Now execute this:

sel disk 0

Now list the volumes by invoking:

list vol

At minimal you have 1 EFI partition, 1 MSR partition, and 1 primary partition. Look at the output and write down the letter the partition use. In this article I assume the windows partition has letter C:  as shown below. The red square means the volume / partition of my EFI partition and blue one means the partition where my Windows installed.

diskpart

To change a volume letter (i.e: from b: to c:, etc) follow this commands:

sel vol #
assign letter n:

Where # is the volume you want to assign with and n is a drive letter (b,c,d, etc).

Now assign EFI partition to B: (in this article I have vol 1):

sel vol 1
assign letter b:

On successful attempt you will be prompted that the volume has been assign to letter b.Then exit diskpart with exit command. Now go to the EFI partition and fix the boot:

cd /d b:\EFI\Microsoft\Boot\
bootrec /fixboot

Now delete (or rename) the BCD file:

ren BCD BCD.bak

Then use bcdboot.exe to recreate BCD store.

bcdboot C:\Windows /l en-us /s B: /f ALL

Where C:\Windows is our installed windows on drive C: and B: is drive of our EFI partition. The /f ALL parameter updates the BIOS settings including UEFI firmware/NVRAM, while /l en-us is to localise for US locale, it will default to US English.

To re-enable Hyper-V, we should run the following commands:

bcdedit /set {default} hypervisorlaunchtype Auto
bcdedit /set {default} nx OptIn

Now reboot and wish you luck 😀

Install FreeBSD on GPT Partition

December 3, 2015 | Article | No Comments

At previous article, we have discussed about how to install Slackware on GPT. In this article we will attempt on installing FreeBSD to GPT disk with or without EFI support.

Unlike previous article, for this article I use generic desktop PC. Thus, you can do it either on notebook or desktop PC. Obviously we constraint ourself to use GPT-based disk :). This article aim to guide you to Fresh Installing FreeBSD.

Step 1: Partitioning

Boot your FreeBSD (I use 8.3). Once you are at sysinstall menu, choose Fixit option. Later you will be brought to a terminal.

Now we will initialize the drive to support GPT partitions.

gpart create -s GPT ad0

Where ad0 is our disk. If you have more than one disk and want to also initialize them, do the similar command and replace ad0 with your device.

Then we will proceed for creating partitions. Our partition have specific purpose but all partition we want to create are a standard one. Do the followings:

gpart add -s 128 -t freebsd-boot -l boot ad0
gpart add -s 5G -t freebsd-ufs -l root ad0
gpart add -s 4G -t freebsd-ufs -l tmp ad0
gpart add -s 4G -t freebsd-swap -l swap ad0
gpart add -s 10G -t freebsd-ufs -l var ad0
gpart add -s 200G -t freebsd-ufs -l usr ad0

On above commands, we have create 6 partitions. The general syntax we use has following pattern:

gpart add -s size -t partition_type -l label disk

Where size is numeric value for size of partition. It also accept suffix K,M,G for Kilo, Mega, and Gigabyte. If no suffix is specified, the default value will be on Kilobytes.

For this article, the partition type can be freebsd-boot, freebsd-ufs, freebsd-swap.

The first partition are partitioned with freebsd-boot for type. It is equivalent to MBR of older disk type. Others are partition with freebsd-ufs (except 4th partition) for regular file system. The label is used for differentiate one partition with other partition.

To see partitions we have create we can invoke this command:

gpart show ad0

Unlike using gdisk, the change using gpart is automatically written on disk.

note: To see partition by label use this command

gpart show -l ad0

If you want to delete a partition, use following command:

gpart delete -i3 ad0

The i3 (generally -in where n is a number) is for pointing out what partition we want to delete. In this case we want to delete 3rd partition from disk ad0. So if your want to delete 5th partition, use gpart delete -i5 ad0.

In extreme condition, if you want to destroy GPT table from ad0 you can use following command:

gpart destroy ad0

The main reason might be you want to erase old disk scheme and create a new one later.

Now format the partition:

newfs -U /dev/ad0p2
newfs -U /dev/ad0p3
newfs -U /dev/ad0p5
newfs -U /dev/ad0p6

Hey, why we skip /dev/ad0p1 and /dev/ad0p4? Take look at their type 😀

Now put MBR (Master Boot Record) code in our first partition (boot partition):

gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptboot -i1 ad0

Then we mount all the partitions to install FreeBSD:

mkdir boot var usr
mount /dev/ad0p2 /mnt
mount /dev/ad0p3 /mnt/tmp
mount /dev/ad0p5 /mnt/var
mount /dev/ad0p6 /mnt/usr

Step 2: Installing FreeBSD

Now we reach the stage for FreeBSD installation itself. Do following:

export DESTDIR=/mnt
cd /dist/8.3-RELEASE
for dir in base catpages dict doc info lib32 manpages; do 
   (cd $dir; ./install.sh); 
done

If you attempt to install x86 (or i386) version of FreeBSD then exclude lib32 in the for loop (you won’t need it.

Next we install the kernel. The kernel we want to install are GENERIC version so do following:

cd kernels
./install.sh GENERIC

And then the sources:

cd ../src
./install.sh

And copy the kernel in /mnt/boot/kernel directory:

cd /mnt/boot
rmdir kernel
cp -Rp GENERIC kernel

Step 3: Configuring
Last step! Configure the FreeBSD. Create /etc/fstab, /etc/resolv.conf and /etc/rc.conf files.

/etc/fstab :

# Device Mountpoint FStype Options Dump Pass#
/dev/ad0p4 none swap sw 0 0
/dev/ad0p2 / ufs rw 1 1
/dev/ad0p3 /tmp ufs rw 1 1
/dev/ad0p5 /var ufs rw 1 1
/dev/ad0p6 /usr ufs rw 1 1

/etc/resolv.conf :

nameserver 8.8.8.8 # or your ISP's DNS

/etc/rc.conf :

defaultrouter="<your router IP>"
hostname="VedaCore"
ifconfig_em0="inet <your IP> netmask <your netmask>"
sshd_enable="YES"

Reboot and enjoy the FreeBSD >:)

NOTE:

  1. If you get error “Device Busy” when you try to delete GPT from drive with gpart delete ad0, then turn off the safety with sysctl variable: sysctl kern.geom.debugflags=16
  2. If you want to destroy GPT table from drive, make sure all partitions have been deleted.

Social media & sharing icons powered by UltimatelySocial