LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-21-2016, 04:18 AM   #1
GioBonvi
Member
 
Registered: Feb 2015
Location: Trento, Italy
Distribution: Ubuntu 15.04, Linux Mint 17.2
Posts: 36

Rep: Reputation: Disabled
Multiboot USB dropping to initramfs


Hi everyone, I am trying to build a multiboot USB out of my 32 GB pendrive.

First of all what I would like to achieve is this:
  1. One partition for data storage (Windows compatible)
  2. One partition LUKS encrypted
  3. One partition multiboot (Linux mint + RemixOS)

Now, I have achieved (1) and (2) completely and (3) partially.

Here are the partitions on the USB:
Code:
/dev/sdd1 FAT32 (20 GB)
/dev/sdd2 LUCKS EXT4 (2GB)
/dev/sdd3 FAT32 (8 GB)
/dev/sdd4 EXT2 (2GB)

/dev/sdd1 is my data storage partition: I use it as a normal USB: being the first partition on the USB and being FAT32 it's recognized by Windows and works OK

/dev/sdd2 is the encrypted partition: it's not recognized by WIndows (obviously), but under Linux I can access it through a password. It works OK

/dev/sdd3 is the multiboot partition. I used Unetbootin to load the OS here. I fllowed a tutorial which said to load the first OS on the partition with Unetbootin, then copy all the files on the PC, load the second OS on the partiion and copy all the files back. Then you simply have to adjust syslinux.cfg and boom: you are done.

/dev/sdd4 is the persistence partition for Linux Mint, one of the tow OSes I loaded in /dev/sdd3. I labeled this partition casper-rw as requested.

Here is the syslinux.cfg file:
Code:
DEFAULT menu.c32
PROMPT 0
MENU TITLE Bonvi Usb Live
TIMEOUT 100

LABEL unetbootindefault
MENU LABEL ^Default (Linux Mint persistent)
TEXT HELP
Avvia Linux Mint 18.0 (Sarah) XFCE con persistenza.
I dati permangono attraverso i riavvii.
ENDTEXT
KERNEL /ubnkern
APPEND initrd=/ubninit file=/cdrom/preseed/linuxmint.seed boot=casper quiet splash -- persistent

MENU  BEGIN ^Linux Mint

LABEL linuxmint0
MENU LABEL Linux Mint (^persistent)
TEXT HELP
Avvia Linux Mint 18.0 (Sarah) XFCE con persistenza.
I dati permangono attraverso i riavvii.
ENDTEXT
KERNEL /casper/vmlinuz
APPEND initrd=/casper/initrd.lz file=/cdrom/preseed/linuxmint.seed boot=casper  quiet splash -- persistent

LABEL linuxmint1
MENU LABEL Linux Mint (^live)
TEXT HELP
Avvia Linux Mint 18.0 (Sarah) XFCE senza persistenza.
I dati non permangono attraverso i riavvii.
ENDTEXT
KERNEL /casper/vmlinuz
APPEND initrd=/casper/initrd.lz file=/cdrom/preseed/linuxmint.seed boot=casper  quiet splash --

LABEL linuxmint2
MENU LABEL Linux Mint (ISO in ^RAM - MIN 2GB)
TEXT HELP
Avvia Linux Mint 18.0 (Sarah) XFCE con persistenza.
I dati permangono attraverso i riavvii.
Il file ISO viene caricata in RAM (Almeno 2 GB), per un esecuzione piu' veloce.
ENDTEXT
KERNEL /casper/vmlinuz
APPEND initrd=/casper/initrd.lz file=/cdrom/preseed/linuxmint.seed boot=casper  toram -- persistent

LABEL linuxmint3
MENU LABEL Linux Mint (^compatibility mode)
TEXT HELP
Avvia Linux Mint 18.0 (Sarah) XFCE con persistenza.
I dati permangono attraverso i riavvii.
Modalità di compatibilita' per vecchi sistemi.
Per rimuovere la persistenza rimuovere "persistent" dalla stringa initrd.
ENDTEXT
KERNEL /casper/vmlinuz
APPEND initrd=/casper/initrd.lz file=/cdrom/preseed/linuxmint.seed boot=casper xforcevesa nomodeset b43.blacklist=yes  ramdisk_size=1048576 root=/dev/ram rw noapic noacpi nosplash irqpoll -- persistent

LABEL linuxmint4
MENU LABEL Linux Mint (^PAE forced)
TEXT HELP
Avvia Linux Mint 18.0 (Sarah) XFCE con persistenza.
I dati permangono attraverso i riavvii.
Forza l'utilizzo della tecnologia PAE (utile per alcuni vecchi sistemi).
Per rimuovere la persistenza rimuovere "persistent" dalla stringa initrd.
ENDTEXT
KERNEL /casper/vmlinuz
APPEND initrd=/casper/initrd.lz file=/cdrom/preseed/linuxmint.seed boot=casper  quiet splash -- forcepae persistent

MENU END

MENU BEGIN Remix OS (^Android x86)

LABEL remixos0
MENU LABEL ^Resident mode
TEXT HELP
Avvia Remix OS (Android x86 M 32bit B2016091301).
I dati verranno salvati e persisteranno fra i riavvii.
ENDTEXT
KERNEL /kernel
APPEND initrd=/initrd.img root=/dev/ram0 androidboot.hardware=remix_x86 androidboot.selinux=permissive quiet SERIAL=random logo.showlogo=1 SRC= DATA= CREATE_DATA_IMG=1

LABEL remixos1
MENU LABEL ^Guest mode
TEXT HELP
Avvia Remix OS (Android x86 M 32bit B2016091301).
I dati non verranno salvati e non persisteranno fra i riavvii.
ENDTEXT
KERNEL /kernel
APPEND initrd=/initrd.img root=/dev/ram0 androidboot.hardware=remix_x86 androidboot.selinux=permissive quiet SERIAL=random logo.showlogo=1 SRC= DATA= DATA_IN_MEM=1

MENU END

MENU BEGIN Strumenti

LABEL tools0
MENU LABEL ^Memory test
TEXT HELP
Cerca errori nella memoria RAM del PC.
ENDTEXT
KERNEL /casper/memtest
APPEND initrd=/ubninit 

LABEL tools1
MENU LABEL ^Reboot
TEXT HELP
Riavvia il PC.
ENDTEXT
COM32 reboot.c32

MENU END

Now here is the problem...
When I boot from USB this happens:
  • All the RemixOS entries are fully working: Guest mode loads a clean system everytime and Resident mode maintains files and preferences
  • Reboot works fine
  • Memtest doesn't work (not that I care much about it, but maybe it's related to the other problems)
  • Linux Mint Live works (it loads a fresh system everytime)
  • Linux Mint ISO to RAM works (it loads and persistence is enabled: it retains files and preferences between reboots)
  • All the other Linux Mint options fail to boot and drop me to an initramfs shell

I am very happy with what I came up with until now and i probably could use the ISO to RAM mode, although I would really prefer to solve these last problems. (The ISO to RAM mode needs at least 1.5 GB of free RAM and needs a lot more time loading, thus I would prefer to also have a "normal" option working).

The errors before I am dropped to the initramfs shell are in the attached image.

Thank you in advance for any help!
Attached Thumbnails
Click image for larger version

Name:	Error.jpg
Views:	55
Size:	161.2 KB
ID:	23070  
 
Old 09-23-2016, 03:04 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
This has been sitting here so I'll venture a guess or some thoughts.

I know there has been a fantastic amount of work on syslinux/isolinux/pxelinux over the decades. It might be a great choice but I'm more leaning towards using grub to load and if need be chain to other loaders depending on the choice.


One of the ways at pendrivelinux has the user install grub4dos as a choice of booting multi.

As to a solution for syslinux then maybe try one choice at a time. I'd think that dropping to infra means that either it can't find location of next file or doesn't have support built into it to find next file.
 
1 members found this post helpful.
Old 09-26-2016, 04:31 PM   #3
GioBonvi
Member
 
Registered: Feb 2015
Location: Trento, Italy
Distribution: Ubuntu 15.04, Linux Mint 17.2
Posts: 36

Original Poster
Rep: Reputation: Disabled
Jefro, thank a lot: you pointed me into the right direction and after some work I solved this!

I insisted with syslinux for a day or two, but at the end I gave up: nothing worked. Then your post came, I made a quick search for "grub usb multiboot" and landed here.

This sounded really promising so I followed the steps on the page (except those about formatting the pendrive as I already had my partitions):
Code:
mkdir /mnt/USB && mount /dev/sdxy /mnt/USB
grub-install --force --no-floppy --boot-directory=/mnt/USB/boot /dev/sdx
Then I gave a look to the grub.cfg file they hosted and searched around the web for "grub menu configuration" and "manually edit grub.cfg" until I understood how it worked.

First try:
take the grub.cfg off the site pretty much "as it is" and change the name of the ISOs and labels.

Result: Linux Mint works. No persistence however<.

Second try:
Take the grub.cfg, edit it interpolating some info from the old syslinux.cfg and the new grub.cfg. Add my custom entries for "persistence", "live", "ISO to RAM", "compatibility mode" and "PAE forced". Add submenus. Repeat for Remix OS.

Result: Linux Mint fully functional (all modes at 100%, even persistence - yay!). Memtest working. Remix OS Guest working. Remix OS Resident refusing to boot up (it got stuck with the logo). From the message it spit out before the logo I was able to understand that it was trying to mount the data partition (the one where files are stored) inside obviously readonly.

Third try:
Take a spare USB, format it FAT32, flash RemixOS on it with Unetbootin, copy all the files except the grub.cfg into my USB. Make RemixOS boot from initrd instead of ISO file.

Result: the same. RemixOS could not make the data partition work.

Fourth try:
Read up some forum posts about "RemixOS multiboot USB", especially the grub configurations. Find out one promising: it removed all the specification at the end of the "linux /kernel" line.

Result: MAGIC! It works! It really does! Everything boots up nicely!

SUMMARY

It took me ages, but finally I do have my MULTI-USE-MULTI-BOOT USB key.

For those interested here I leave you a small summary of the steps (leaving out all the trial and error):
  1. format the key (say it's /dev/sdx) so that:
    • /dev/sdx1 is a FAT32 partition. Give it a nice name. This partition will be the only one available under Windows;
    • /dev/sdx2 is ext4. This partition will be encrypted in the next step
    • /dev/sdx3 as FAT32, however it won't be recognized by Windows. Here we'll keep the boot files and ISOs;
    • /dev/sdx4 as ext2 with label casper-rw (mandatory). This partition will hold the persistence files of Linux Mint
  2. encrypt /dev/sdx2: I followed this guide.
  3. download all the ISOs file you want to put on the USB
  4. install unetbootin and use it to flash RemixOS on /dev/sdx3
  5. install grub on the USB. Make sure it's mounted somewhere in your system (say "/mnt/USB"):
    Code:
    grub-install --force --no-floppy --boot-directory=/mnt/USB/boot /dev/sdx
  6. copy the ISO of Linux Mint on /dev/sdx3 (I also downloaded memtest as suggested here)
  7. edit /boot/grub/grub.cfg on /dev/sdx3 to look something like the file you'll find at the end of the post
  8. The End: boot your USB to test it

Now you have a USB key which:
  • works with Windows/Linux/Mac for file transfer
  • has an encrypted linux compatible partition
  • can boot as many OSes as you like (as long as you have space on /dev/sdx3 and have time to find the right options for grub.cfg)
  • can boot OSes with persistence

This works best with USB 3.0 and 32 GB or more of total space.

Other things you could add are obviously other OSes (antivirus scan, system rescue...) or portableApps for Windows (they must go to /dev/sdx1 as it's the only partition visibile from Windows).

So thank you again jefro for your hint! You saved me

Here is my final grub.cfg file:
Code:
set timeout=10
set default=0

submenu "Linux Mint" {

  menuentry "Linux Mint XFCE 18.0 Sarah (persistent)" {
    loopback loop /linuxmint-18-xfce-32bit.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/linuxmint-18-xfce-32bit.iso quiet splash -- persistent
    initrd (loop)/casper/initrd.lz
  }
    
  menuentry "Linux Mint XFCE 18.0 Sarah (live)" {
    loopback loop /linuxmint-18-xfce-32bit.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/linuxmint-18-xfce-32bit.iso quiet splash --
    initrd (loop)/casper/initrd.lz
  }
  
  menuentry "Linux Mint XFCE 18.0 Sarah (ISO to RAM)" {
    loopback loop /linuxmint-18-xfce-32bit.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/linuxmint-18-xfce-32bit.iso toram -- persistent
    initrd (loop)/casper/initrd.lz
  }
  
  menuentry "Linux Mint XFCE 18.0 Sarah (compatibility mode)" {
    loopback loop /linuxmint-18-xfce-32bit.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/linuxmint-18-xfce-32bit.iso xforcevesa nomodeset b43.blacklist=yes  ramdisk_size=1048576 root=/dev/ram rw noapic noacpi nosplash irqpoll -- persistent
    initrd (loop)/casper/initrd.lz
  }
  
  menuentry "Linux Mint XFCE 18.0 Sarah (PAE forced)" {
    loopback loop /linuxmint-18-xfce-32bit.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/linuxmint-18-xfce-32bit.iso quiet splash -- forcepae persistent
    initrd (loop)/casper/initrd.lz
  }
}

submenu "Remix OS" {
  
  menuentry 'Resident mode - All your data and apps are saved' {
    search --file --no-floppy --set=root /system.sfs
    linux /kernel root=/dev/ram0 androidboot.hardware=remix_x86 androidboot.selinux=permissive quiet SERIAL=random logo.showlogo=1
    initrd /initrd.img
  }

  menuentry 'Guest mode - No data will be saved after each session' {
    search --file --no-floppy --set=root /kernel
    linux /kernel root=/dev/ram0 androidboot.hardware=remix_x86 androidboot.selinux=permissive quiet SERIAL=random logo.showlogo=1 REMOUNT_RW=0 DATA= DATA_IN_MEM=1
    initrd /initrd.img
  }

}

submenu "Tools" {
  menuentry "Memtest 86+" {
   linux16 /memtest86+.bin
  }
  
  menuentry "Turn off the computer" {
    echo "Turning off the computer..."
    halt
  }

  menuentry "Reboot the computer" {
    echo "Rebooting the computer..."
    reboot
  }
}
 
1 members found this post helpful.
Old 09-26-2016, 06:14 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Wow! Great job. Thanks for the solution.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiboot USB. devinmcelheran Linux - General 11 09-21-2014 07:54 PM
[SOLVED] Clone USB Multiboot digitaldefector Linux - Software 1 04-24-2014 02:51 AM
[SOLVED] systemrescuecd + usb + multiboot vnc Linux - Newbie 2 02-10-2013 11:02 PM
Multiboot USB armans Linux - Software 1 09-01-2012 05:41 AM
Lilo-multiboot and initramfs igadoter Slackware 7 04-14-2011 12:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration