Friday 25 September 2015

Add a full Arch Linux OS to Easy2Boot



Here are the steps to add a full install of Arch Linux to an Easy2Boot USB drive.

We will create an empty partition file (ARCH) and then use Virtual Box + DavidB's VMUB to install to the partition file.

Use the latest MPI Tool Pack (v.0.054 2015-08-21 or later). This includes CSM menu support for grub2/syslinux installations on the 3rd partition.

I used archlinux-2015.09.01-dual.iso for the test below.



Brief Instructions (not for beginners!)

Important Note: Before you begin, save the MBR sector of your E2B USB drive in case anything goes wrong. Use RMPrepUSB - Drive>File - name=E2BMBR.BIN, start=0, size=512, filestart=0. Save the file to your Windows hard drive for safe keeping. If you find that you cannot return back to the E2B menu, restore the original MBR using RMPrepUSB - File>Drive.
Warning: The instructions below are really 'notes' on how I made a partition image containing ARCH on my E2B USB drive. You should be familiar with VBox+VMUB and linux installs and MakePartImage before you attempt this!

I used a Win10 64-bit host system and the archlinux-2015.09.01-dual.iso ISO file for this procedure, with a SSD USB 3.0  USB  drive as my E2B USB drive.

1. Create an empty folder on the Windows Desktop and drag-and-drop the empty folder onto the MPI_FAT32 Desktop shortcut. Do this twice to make two files of different sizes:

ARCH.imgPTN  (38MB - accept default size)
ARCH.NOEXT  (set size as required - e.g. 15000 for 15GB)

Now copy the files to your E2B USB drive and remove the .NOEXT file extension. You now should have:

\_ISO\LINUX\ARCH.imgPTN   (38MB)
\_ISO\LINUX\ARCH                 (15GB) - or any size you like!

2. Use VBox+VMUB, Create a new linux diskless VM in VBox.
No virtual hard disk should be present in the VM.

Boot to E2B and select the ARCH.imgPTN file and get to the CSM menu.

WARNINGDo NOT use \_ISO\SWITCH_E2B.exe to switch partitions because it creates a slightly larger partition than E2B creates. Once you have installed the OS, you can switch using any method, but for the initial installation, you must use E2B to switch to the .imgPTN file.

Tip: If you have added in the ISO as a virtual CD, and it boots to the archlinux menu instead of E2B, use the 'Boot existing OS' menu option in archlinux (as highlighted in the screenshot below) to boot to E2B.

3. Quit the CSM menu and the VM.

4. In VBox Manager - Settings, add a virtual CD with the archlinux-2015.09.01-dual.iso  as the content of the virtual CD to the new VM that you created. Ensure that the CD-ROM is first in the boot order.

5. Run VBox (via VMUB) and allow the VM to boot from the ISO which should be on your Windows drive somewhere (not the USB drive) - press F12 if required to boot from the 'CD'. Do not boot directly using the VBox Manager, but use VMUB to run VBox.

6. You should see the LiveCD menu because VBox will boot from the ISO...



Choose the first boot option to boot from the ISO file in VBox

List the partitions and ensure that you can see \dev\sda3 using   blkid

Note: If you cannot see the /dev/sda3 15GB partition, you probably did not switch to the CSM Menu!

Format the 15GB partition inside the ARCH file which is now /dev/sda3  partition 3 ...
mkfs.ext4 -L usbboot /dev/sda3

make some folders and mount the partition under /mnt/archusbdrive...
mkdir /mnt/archusbdrive
mount /dev/sda3 /mnt/archusbdrive


Your VM needs to have a working internet connection.

Install the base system on the flash drive root (this will take a few minutes!):
pacstrap /mnt/archusbdrive base

generate a filesystem table (using UUIDs -U):
genfstab -U -p /mnt/archusbdrive >> /mnt/archusbdrive/etc/fstab

We must now change the root...
arch-chroot /mnt/archusbdrive

note that the shell prompt will change after using arch-chroot.

Set the desired hostname:
echo archusb > /etc/hostname

Set your timezone, e.g.
ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
or
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

Edit and uncomment your locales in /etc/locale.gen and run locale-gen afterwards:
nano /etc/locale.gen
use Ctrl-X to exit the nano editor and Y to save the changes
locale-gen

Set your preferred locale, e.g.:
echo LANG=en_US.UTF-8 > /etc/locale.conf
or
echo LANG=en_GB.UTF-8 > /etc/locale.conf

Create the initial ramdisk
mkinitcpio -p linux

set your root password: 
passwd


7. Now we need to install grub (note that we are still under arch-chroot prompt)
pacman -S grub
grub-install --target=i386-pc --recheck /dev/sda3 --force


Make a configuration file for grub as follows:
grub-mkconfig -o /boot/grub/grub.cfg

8. Now we exit arch-chroot - and we are done!
exit
sync

umount /dev/sda3
reboot

9. You should now be able to boot to ARCH using the CSM 'Boot to Partition 2' option or return back to E2B.


I found this page very useful in preparing the USB drive further.
See the 'a desktop environment and more' section to continue installation.
You may also find the wiki page useful here.


No comments:

Post a Comment