summaryrefslogtreecommitdiff
path: root/md/writeup/multiboot_usb_drive.md
blob: 538302fc8c2b3a3c995901027fa470f113e3370a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Multiboot USB drive

Purpose of this is to use one USB driver to test many distros. When you have
many distro ISO's it takes some time to _dd_ them on USB driver and if you
whant to try many different then it will take time to _dd_ them everytime
when you try new. If there is possible just copy many ISO's on USB driver and
run any you need it will save you some time.

## Lets install bootloader

Using _fdisk_ to delete/create new partitions on USB drive

```
mkfs.vfat /dev/sdb1
```

mount drivet to current pc

```
mount /dev/sdb1 /mnt/flash0
```

create dire where will be grub files and grub menu config file

```
mkdir /mnt/flash0/boot
```

install grub, but you can install also 64bit grub if there is need

```
grub-install --target=i386-pc --recheck --boot-directory=/mnt/flash0/boot /dev/sdb
```

check with id have usb drive

```
blkid /dev/sdb1
/dev/sdb1: UUID="D49E-18CC" TYPE="vfat" PARTUUID="5f55bd3d-01"
```

#### Mounting ISO's

Some manuals have outdatet filesystem layouts and there is need to investigate
current layout by hand. And you need to mount ISO files.

```
mount -o loop /home/fam/downloads/iso/ubuntu-14.04.3-desktop-i386.iso /mnt/flash0
```

next is to check bootloader config how they are starting image, there you 
can find extra options that need to be passed or just with image is used
to start ISO

### Boot menu 

Here is result what you have at the end some Ubuntu isos, OpenWRT image and 
your own compiled kernel

*boot/grub/grub.cfg*

```
## Begin /boot/grub/grub.cfg
set default=1
set timeout=5

probe -u $root --set=rootuuid
set imgdevpath="/dev/disk/by-uuid/$rootuuid"

menuentry "GNU/Linux, vmlinux" {
        linux   /vmlinux root=/dev/disk/by-uuid/54F9-27A2 ro
}


menuentry "Ng-Linux, bzImage" {
        linux   /bzImage root=/dev/disk/by-uuid/54F9-27A2 ro
	initrd /test.cpio.gz
}

menuentry "OpenWRT, bzImage" {
        linux   /openwrt-x86-generic-ramfs.bzImage root=/dev/sdb1 ro
        initrd /openwrt-x86-generic-rootfs.cpio.gz
}

menuentry "DSL, bzImage" {
	set isofile='/boot/iso/dsl-4.4.10.iso'
	loopback loop $isofile
        linux  (loop)/boot/isolinux/linux24 ramdisk_size=100000 init=/etc/init2 lang=us vga=normal atapicd nosound noscsi nousb nopcmcia nofirewire noagp nomce nodhcp xmodule=vesa 
        initrd (loop)/boot/isolinux/minirt24.gz knoppix base norestore legacy
}

menuentry "Austrumi, bzImage" {
        set isofile='/boot/iso/austrumi-3.2.6.iso'
        loopback loop $isofile
        linux  (loop)/austrumi/bzImage
        initrd (loop)/austrumi/initrd.gz dolivecd text
}

menuentry '[loopback]archlinux-2015.12.01-dual.iso-mnth' {
	set isofile='/boot/iso/archlinux-2015.12.01-dual.iso'
	loopback loop $isofile
	linux (loop)/arch/boot/x86_64/vmlinuz  img_dev=$imgdevpath img_loop=$isofile
	initrd (loop)/arch/boot/x86_64/archiso.img
}

menuentry '[loopback]ubuntu-14.04.3-desktop-amd64' {
	set isofile='/boot/iso/ubuntu-14.04.3-desktop-i386.iso'
	loopback loop $isofile
	linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile locale=en_US.UTF-8
	initrd (loop)/casper/initrd.lz
}

menuentry '[loopback]ubuntu-12.04.5-alternate-i386' {
	set isofile='/boot/iso/ubuntu-12.04.5-alternate-i386.iso'
	loopback loop $isofile
	linux (loop)/install/vmlinuz boot=/dev/sda1 iso-scan/filename=$isofile locale=en_US.UTF-8
	initrd (loop)/install/initrd.gz
}

menuentry "[loopback]tails-i386-1.8.1.iso" {
    set isofile='/boot/iso/tails-i386-1.8.1.iso'
    loopback loop $isofile
    linux (loop)/live/vmlinuz2 boot=live config findiso=${isofile} live-media=removable apparmor=1 security=apparmor nopersistent noprompt timezone=Etc/UTC block.events_dfl_poll_msecs=1000 noautologin module=Tails
    initrd (loop)/live/initrd2.img
}

```

## Tested

### Devices

?Some images could be not loadable becouse not enought RAM?

Tested to work on _Asus EEE PC 701_ [6]. And bigger desktop PC (12G RAM).

| Distro  | Asus | PC  |
|---|---|---|
| my own kernel + initrd | + | + |
| OpenWRT | + | - _?no kbd drivers_ |
| DSL | - | - |
| Austrumi | - | - |
| archlinux 2015.12.01 | ? | + |
| Ubuntu 14.04.3 | + |  + |
| Ubuntu 12.04.5 | + | + |
| Tails | ? | +  |

```text
+ - works fine  
- - doesnt work  
? - to long to wait, not enought ram?  
```

## Links

1. https://wiki.archlinux.org/index.php/Multiboot_USB_drive
2. https://www.kernel.org/doc/Documentation/kernel-parameters.txt
3. https://liquidat.wordpress.com/2007/10/15/short-tip-get-uuid-of-hard-disks/
4. http://www.linuxfromscratch.org/lfs/view/stable/chapter08/grub.html
5. http://www.redips.net/linux/create-fat32-usb-drive/
6. https://en.wikipedia.org/wiki/Asus_Eee_PC