# [SOLVED]HOWTO liveUSB with grub and serial console support

## NiceGuy

Hi everyone, 

Just wanted to know if it was possible to convert the isolinux boot loader on the Gentoo minimal liveCD to the grub boot loader?

I would like to make a liveUSB.

Thanks

----------

## booleandomain

I think all you have to do is:

1) mount the .iso image to /mnt/cdrom or something like that

2) mount your usb flash drive partition to /mnt/usb or something like that

3) copy everything from /mnt/cdrom to /mnt/usb

4) emerge --config grub and insert /mnt/usb as the path where to install files

5) configure /mnt/usb/boot/grub/grub.conf

----------

## neysx

Use unetbootin

----------

## NiceGuy

Hi everyone,

I am spending sometime this afternoon closing some of my posts and passing on the information to all gentoo users. I decided to rename this post to "Build a gentoo liveUSB with grub serial console support".

My GOAL was to build a Gentoo LiveUSB that utilizes grub as its boot loader (not isolinux, etxlinux etc ... ) and with Serial Console support and Grub Serial Console Support (both @115200 baud)

Assumptions

* Note I assume your usb is /dev/sdb (changw where appropriate)

** Note I assume your usbstick is mounted at /media/disk (change where appropriate)

Prepare USB : 

For < 4Gig USB disk

```
user@laptop$ mkdosfs -F 16 /dev/sdb1
```

For  >= 4Gig USB disk

```
user@laptop$ mkdosfs -F 32 /dev/sdb1
```

First, to get grub the cd I had to remaster the iso

1. Download gentoo.iso

2. mount gentoo.iso /mnt/isoimage/ -t iso9660 -o loop

3. cp -rf /mnt/isoimage/* /media/disk

4. umount /mnt/isoimage 

5. cd /media/disk

6. mkdir -p /home/squashfs

7. mkdir -p /mnt/newsquashfs

8. mount -t squashfs -o loop /media/disk/image.squashfs /mnt/newsquashfs

9. cp -rf /mnt/newsquashfs/* /home/newsquashfs

10. umount /mnt/squashfs

11. Edit /home/newsquashfs/etc/securetty to:

```
tt/s0

ttyS0
```

12. Edit /home/newsquashfs/etc/inittab

```
#SERIAL CONSOLE

s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 115200 ttyS0 vt100
```

13. cd /media/disk

14. rm image.squashfs

15 mksquashfs /home/newsquashfs image.squashfs

16. verify /media/disk 

```
ls -l

username@laptop:$ ls /media/disk

gentoo.efimg  gentoo.efimg.mountPoint  image.squashfs  isolinux  livecd
```

17. For completness say hi to your cd/usb kernel ... labeled "gentoo" inside isolinux folder

```
user@laptop:$ ls /media/disk/isolinux

boot.cat  elilo.efi  gentoo  gentoo.igz  isolinux.bin  isolinux.cfg  memtest86  System.map-gentoo
```

18. From the home Gentoo system copy over the boot folder into /media/disk (aka usb) directory    -- special thanks to DONAHUE from Goose Creek SC for step 16

```
user@laptop:$  cp -rf /boot .

echo "usbstick" > /media/disk/boot/grub/usbstick

ls -l  /media/disk                 # verify boot folder copied

ls -l  /media/disk/boot         # verify the boot folder contents

ls -l  /media/disk/boot/grub # verify the /boot/grub contents

grub

find /boot/usbstick

# return should be formatted like (hdx,y)

root (hdx,y) # substitute the returned digits for x,y

setup (hdx) # substitute the returned digits for x

quit 
```

19. For this post ... verify /media/disk structure .. note the new boot directory added to the /media/disk folder

```
name@laptop:/media/disk$ ls

boot  gentoo.efimg  gentoo.efimg.mountPoint  image.squashfs  isolinux  livecd 
```

20. USB directory structure (/media/disk/boot)

```

user@laptop:/media/usbdisk/boot$ ls

grub  usbstick
```

21. USB directory structure (/media/disk/boot/grub)

```
name@laptop:/media/usbdisk/boot/grub$ ls

e2fs_stage1_5  ffs_stage1_5   grub.conf         jfs_stage1_5  minix_stage1_5     stage1  stage2_eltorito  vstafs_stage1_5

fat_stage1_5   glidevice.map  iso9660_stage1_5  menu.lst      reiserfs_stage1_5  stage2  ufs2_stage1_5    xfs_stage1_5
```

20. Edit liveUSB /media/disk/boot/grub/grub.conf and /media/disk/boot/grub/menu.lst

```
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 

terminal --timeout=15 serial console

default 0

timeout 10

title=USB disk - Serial Console

root(hd0,0)

kernel /isolinux/gentoo root=/dev/ram0 init=/linuxrc slowusb looptype=squashfs loop=/image.squashfs cdroot console=ttyS0,115200

initrd /isolinux/gentoo.igz

title=USB disk - Terminal

root(hd0,0)

kernel /isolinux/gentoo root=/dev/ram0 init=/linuxrc slowusb looptype=squashfs loop=/image.squashfs cdroot vga=791

initrd /isolinux/gentoo.igz
```

21. For gentoo forum completeness:

Of course I still had to modify the /etc/securetty to allow for ttyS0 and tts/0 logins 

/etc/securetty

```
tts/0

ttyS0
```

I had to modify /etc/inittab 

```
#SERIAL CONSOLE

s0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 115200 ttyS0 vt100
```

22. umount /media/disk

23. Change BIOS to boot to USB HDD

24. Reboot

25. Done .. if all goes well you should have booted into the liveUSB

Really hope that helps at least one other person .. and if I made a mistake re-typing this I apologize in advance as I wrote this from pure memory

Thanks and enjoy

----------

## pilla

Moved from Other Things Gentoo to Documentation, Tips & Tricks.

----------

## pilla

Moved from Other Things Gentoo to Documentation, Tips & Tricks.

----------

## BlackLodge

Hi,

I tried this method for building an USB bootable stick to run in a headless machine, but I'm stuck in the part where the grub is intalled to the MBR of the stick. 

Are these lines still working?

 *Quote:*   

> 
> 
> 18. From the home Gentoo system copy over the boot folder into /media/disk (aka usb) directory -- special thanks to DONAHUE from Goose Creek SC for step 16 
> 
> ```
> ...

 

If the bootable kernel is /media/disk/isolinux/gentoo , I don't get how is this location passed to grub   :Smile: 

----------

