Friday 7 December 2012

Grub2, Grub4Dos: Config files

Iso booting is awesome. Make a thumbdrive bootable with syslinux/isolinux. Load on grub2 and grub4dos then just place your favorite livecd's iso on the drive and boot from it.

For more information check out Reboot.Pro

Just for reference here are my config files for Syslinux, Grub2 and Grub4Dos

grub.cfg

<------------------------------------------------------->

 timeout=0
default=1

insmod part_gpt
insmod part_msdos
insmod fat
insmod ext2
insmod memdisk
insmod jpeg
insmod gfxterm
insmod efi_gop

loadfont /efi/grub/fonts/unicode.pf2
set gfxmode=auto
set gfxmode=keep
terminal_output gfxterm
terminal gfxterm

use_bg=true
background_image /efi/grub/themes/RedPower.jpg

set menu_color_normal=black/black
set menu_color_highlight=light-red/black
set color_normal=red/black
set timeout=5

menuentry 'Parted Magic LiveCD'{
loopback loop /isos/pmagic_2012_10_10.iso
linux (loop)/pmagic/bzImage iso_filename="/isos/pmagic_2012_10_10.iso" directory=/isos edd=off load_ramdisk=1 prompt_ramdisk=0 rw loglevel=9 max_loop=256 vmalloc=288MiB
initrd (loop)/pmagic/initrd.img
}

menuentry 'BackBox 64bit LiveCD' {
set isofile="/isos/backbox-3.0-i386.iso"
loopback loop /isos/backbox-3.0-amd64.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/isos/backbox-3.0-amd64.iso noprompt noeject
initrd (loop)/casper/initrd.gz
}

menuentry 'Mint Cinnamon 64bit LiveCD' {
set isofile="/isos/linuxmint-13-cinnamon-dvd-64bit.iso"
loopback loop /isos/linuxmint-13-cinnamon-dvd-64bit.iso
linux (loop)/casper/vmlinuz file=/cdrom/preseed/mint.seed boot=casper initrd=initrd.lz iso-scan/filename=/isos/linuxmint-13-cinnamon-dvd-64bit.iso noeject noprompt splash --
initrd (loop)/casper/initrd.lz
}

menuentry 'ArchBoot LiveCD 64bit 2012-10-1' {
loopback loop /isos/archlinux-2012.10-1-archboot-dual.iso
linux (loop)/boot/vmlinuz_x86_64 acpi=off
initrd (loop)/boot/initramfs_x86_64.img
}

submenu 'Utilities and 32bit' {

menuentry 'ArchBoot LiveCD 32bit 2012-10-1' {
loopback loop /isos/archlinux-2012.10-1-archboot-dual.iso
linux (loop)/boot/vmlinuz_32 acpi=off
initrd (loop)/boot/initramfs_32.img
}

menuentry 'BackBox 32bit LiveCD' {
set isofile="/isos/backbox-3.0-i386.iso"
loopback loop /isos/backbox-3.0-i386.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/isos/backbox-3.0-i386.iso noprompt noeject
initrd (loop)/casper/initrd.gz
}

menuentry 'Other Live CDs'{
linux /EFI/grub4dos/grub.exe --config-file="/EFI/grub4dos/menu.lst"
}

}

menuentry 'Refind' {
exit
}

menuentry 'Restart' {
        reboot
}

menuentry 'Shutdown' {
        halt
}

<---------------------------------------------------------------------->

menu.lst

<------------------------------------------------------------------------->


color green/black black/green green/black green/black
timeout 30

title Win7PE User
 map /isos/win7PE_SEV4User.ISO (hd32)
 chainloader (hd0,0)+1
 map --hook
 chainloader (hd32)
 boot

title Win7PE Tools
 map /isos/win7PE_SEV4Tools.ISO (hd32)
 chainloader (hd0,0)+1
 map --hook
 chainloader (hd32)
 boot

title Boot 1st HD
 chainloader (hd0)+1
 rootnoverify (hd0)

title Boot 2nd HD
 chainloader (hd1)+1
 rootnoverify (hd1)

title Boot 3rd HD
 chainloader (hd2)+1
 rootnoverify (hd2)

title Kon-Boot v2.0
 map --mem /isos/kon-bootFloppy.img (fd0)
 map --hook
 chainloader (fd0)+1
 map (hd1) (hd0)
 map --hook
 rootnoverify (fd0)

title Share the Box
 find --set-root /isos/STBmc.iso
 map --mem /isos/STBmc.iso (hd32)
 map --hook
 map --status
 chainloader (hd32)

title Ultimate Boot CD 5.11
 find --set-root /isos/ubcd511.iso
 map /isos/ubcd511.iso (hd32)
 map --hook
 chainloader (hd32)

title G4L
 find --set-root /isos/g4l-v0.37.iso
 map /isos/g4l-v0.37.iso (0xff)
 map --hook
 chainloader (0xff)

title Main Menu
 chainloader (hd0)+1

title Reboot
 reboot

title Halt
 halt

title Command-line
 commandline

<----------------------------------------------------------->

syslinux.cfg

<------------------------------------------------------------>

UI menu.32
Prompt 0

MENU TITLE Boot Menu
TIMEOUT 20
Default Grub2

label Grub2
menu label Grub2
COM32 chain.c32
append file=/boot/grub/i386-pc/boot.img

label Grub4Dos
menu label Grub4Dos
kernel /EFI/grub4dos/grub.exe

<------------------------------------------------------------->

Thursday 6 December 2012

Bash Script: Random File Sync

A simple bash script I wrote.

It will randomly sync files from a source directory to a destination directory.

Features:

  • Prompt for megabytes to move; defaults to 4 GB.
  • Prompt for a source destination.
  • Searches all sub-folders in source directory for files
  • Prompt for a destination directory.
  • Option to delete some, all or none of the files in destination directory.
  • If "none" is typed. No files are deleted.
  • If "all" is typed. All files and folders in destination directory are deleted.
  • If "some" is typed. User is prompted for megabytes to delete. This then becomes the amount of megabytes moved.
  • Files are randomly deleted from destination directory.
  • Files are chosen at random from source directory and moved to destination directory.
Why:

This was written because I could not find a media player that would sync a directory to a directory. I mount my Android phone via sshfs to a folder in my home directory and wanted to randomly sync music files to it from my server. My music collection is quite large and going though it can be laborious. This program suits my needs. It can delete songs at random from my phone and replace them; or it can add files to my phone if I want increase the amount of music on it; or it can completely rebuild the music directory.

Limitations:
  • No error checking. If you enter a wrong parameter it will probably just error out.
  • No auto-completion when choosing directories. You must know where your file are coming from and going to.
  • Does not check if there is enough room in the destination folder. Sshfs (the version I use at least) does not support the checking of free space on a mounted directory. There is some code commented out at the bottom of the script to perform this action for regular directories. It was not tested very much so it may work for you, it may not.
  • Default values are set for me. Change them in the script to your preferences.
Usage:

Create a text file and copy the code below to it.
Save file into a folder you have permission to work in
From the command line type: 

chmod +x foo

where foo is the name you saved the file under.

To run the script from the command line type:

./foo

while in the directory you saved the file in.