dstefaniuk
May 15th, 2012, 10:05 PM
I've prepared an usb stick this way:
echo "d
1
d
n
p
1
+1024M
t
b
n
p
2
a
1
w
" | fdisk /dev/sdb
mkfs.vfat -F 32 /dev/sdb1
fdisk -l
mkdir -p /mnt/usb > /dev/null 2>&1
mount -t vfat /dev/sdb1 /mnt/usb
grub-install --no-floppy --force --root-directory=/mnt/usb /dev/sdb
cp -v ~/ubuntu-12.04-server-amd64.iso /mnt/usb
sync
function substring() {
local STR="${1#${1%${2}*}${2}}";
echo "${STR%${3}*}";
}
UUID=$(substring $(blkid | grep /dev/sdb1 | awk '{ print $2 }') 'UUID="' '"')
cat <<EOF > /mnt/usb/boot/grub/grub.cfg
set default=0
set timeout=10
insmod fat
search --no-floppy --fs-uuid $UUID --set=usb
set iso_path=/ubuntu-12.04-server-amd64.iso
loopback loop (\${usb})\${iso_path}
set root=(loop)
set bootopts="boot=casper iso-scan/filename=\${iso_path} ro noprompt noeject --"
menuentry "Boot ISO from USB" {
linux (loop)/install/vmlinuz \$bootopts
initrd (loop)/install/initrd.gz
}
EOF
This script should create a bootable usb stick that starts installation from mounted iso image - and it does. However, everything goes well up to the point when it tries to read from the image. So, it boots, starts installation process, I'm able to select language and keyboard type and that's it. Next, I get a message that the CD/DVD is not valid.
Why is that? How can I solve this problem?
echo "d
1
d
n
p
1
+1024M
t
b
n
p
2
a
1
w
" | fdisk /dev/sdb
mkfs.vfat -F 32 /dev/sdb1
fdisk -l
mkdir -p /mnt/usb > /dev/null 2>&1
mount -t vfat /dev/sdb1 /mnt/usb
grub-install --no-floppy --force --root-directory=/mnt/usb /dev/sdb
cp -v ~/ubuntu-12.04-server-amd64.iso /mnt/usb
sync
function substring() {
local STR="${1#${1%${2}*}${2}}";
echo "${STR%${3}*}";
}
UUID=$(substring $(blkid | grep /dev/sdb1 | awk '{ print $2 }') 'UUID="' '"')
cat <<EOF > /mnt/usb/boot/grub/grub.cfg
set default=0
set timeout=10
insmod fat
search --no-floppy --fs-uuid $UUID --set=usb
set iso_path=/ubuntu-12.04-server-amd64.iso
loopback loop (\${usb})\${iso_path}
set root=(loop)
set bootopts="boot=casper iso-scan/filename=\${iso_path} ro noprompt noeject --"
menuentry "Boot ISO from USB" {
linux (loop)/install/vmlinuz \$bootopts
initrd (loop)/install/initrd.gz
}
EOF
This script should create a bootable usb stick that starts installation from mounted iso image - and it does. However, everything goes well up to the point when it tries to read from the image. So, it boots, starts installation process, I'm able to select language and keyboard type and that's it. Next, I get a message that the CD/DVD is not valid.
Why is that? How can I solve this problem?