Tiny Core Linux
General TC => Tiny Core on Virtual Machines => Topic started by: bh3 on April 01, 2015, 05:27:35 PM
-
I'm really sorry, I'm your typical annoying newbie who's had a brief search but not found what (s)he's looking for. I want to create a LiveCD to install GRUB by running the following commands:
mount /dev/vda2 /mnt
mount --rbind /dev /mnt/dev
mount --rbind /proc /mnt/proc
mount --rbind /sys /mnt/sys
LANG=C chroot /mnt update-grub
LANG=C chroot /mnt grub-install --modules="biosdisk part_msdos" /dev/vda
reboot
That's literally all I want to do - I've already set up the virtual machine using debootstrap on the virtual machine host.
Please could somebody point me in the right direction? Sorry for wasting time!
-
Solved my own problem, yippee!
Bash script included below (for Debian Wheezy). Please read it before running it - I'm not responsible if it sets your server on fire etc. It should probably be commented, but...
#! /bin/bash
apt-get install -y advancecomp genisoimage
cd /tmp/tcl
wget http://distro.ibiblio.org/tinycorelinux/6.x/x86_64/release/CorePure64-6.1.iso
mv CorePure64-6.1.iso corepure64-6.1.iso
mount corepure64-6.1.iso /mnt -o loop,ro
cp -a /mnt/boot /tmp/tcl
mv /tmp/tcl/boot/corepure64.gz /tmp/tcl
umount /mnt
mkdir extract
cd extract
zcat ../corepure64.gz | cpio -i -H newc -d
cat >> opt/bootlocal.sh <<CONF
sudo mount /dev/hda2 /mnt
sudo mount --rbind /dev /mnt/dev
sudo mount --rbind /proc /mnt/proc
sudo mount --rbind /sys /mnt/sys
sudo LANG=C chroot /mnt update-grub
sudo LANG=C chroot /mnt grub-install --modules="biosdisk part_msdos" /dev/hda
sudo mount /dev/sda2 /mnt
sudo mount --rbind /dev /mnt/dev
sudo mount --rbind /proc /mnt/proc
sudo mount --rbind /sys /mnt/sys
sudo LANG=C chroot /mnt update-grub
sudo LANG=C chroot /mnt grub-install --modules="biosdisk part_msdos" /dev/sda
sudo mount /dev/vda2 /mnt
sudo mount --rbind /dev /mnt/dev
sudo mount --rbind /proc /mnt/proc
sudo mount --rbind /sys /mnt/sys
sudo LANG=C chroot /mnt update-grub
sudo LANG=C chroot /mnt grub-install --modules="biosdisk part_msdos" /dev/vda
sudo poweroff
CONF
find | cpio -o -H newc | gzip -2 > ../corepure64.gz
cd ..
advdef -z4 corepure64.gz
mkdir newiso
mv corepure64.gz boot
cat > boot/isolinux/isolinux.cfg <<CONF
default corepure64
label corepure64
kernel /boot/vmlinuz64
append initrd=/boot/corepure64.gz loglevel=3
CONF
mv boot newiso
genisoimage -l -J -R -V tc-grub -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o install-grub.iso newiso
mv install-grub.iso /isos
cd ~
rm -r /tmp/tcl
EDIT: This uses the CorePure fork as I'm running 64-bit guests.
-
PS: I've just realised it's not entirely clear what I'm doing - explanation below:
I've installed Debian on my VM from the host using debootstrap (https://wiki.debian.org/Debootstrap (https://wiki.debian.org/Debootstrap)) - however I cannot install grub from outside the virtual machine. Therefore, I'm using the 64-bit port of Tiny Core to install grub.