Cyclone Boot From USB
Contents
- 1 Boot Cyclone from USB stick
- 1.1 Create empty 8Mb image
- 1.2 Put MBR on it
- 1.3 Partition image
- 1.4 Mount partitioned image on loop device
- 1.5 Format ext4
- 1.6 Remove wasted space
- 1.7 Mount created image
- 1.8 Create extlinux boot sector
- 1.9 Create kernel image from Rom-o-Matic
- 1.10 Copy kernel to mounted stick
- 1.11 Create the most basic config
- 1.12 Unmount image
- 1.13 Test the image
- 1.14 Copy image to usb stick
Boot Cyclone from USB stick
- You can do this directly to your USB stick, however it may be easier to create an image which can then be written out to any stick, quickly.
- Creating an image also means you can test very quickly with qemu.
For more detailed information about this process please see [] []
Create empty 8Mb image
$ dd if=/dev/zero of=/tmp/test.ima bs=512 count=16384 16384+0 records in 16384+0 records out 8388608 bytes (8.4 MB) copied, 0.0160887 s, 521 MB/s
Put MBR on it
$ dd if=syslinux-4.05/mbr/mbr.bin of=/tmp/test.ima bs=440 count=1 conv=notrunc 1+0 records in 1+0 records out 440 bytes (440 B) copied, 1.7179e-05 s, 25.6 MB/s
Partition image
Dont forget to set it active! Accept defaults for start/end.
$ fdisk /tmp/test.ima Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xf3e250f0. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4, default 1): 1 First sector (2048-16383, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-16383, default 16383): Using default value 16383 Command (m for help): a Partition number (1-4): 1 Command (m for help): p Disk /tmp/test.ima: 8 MB, 8388608 bytes 255 heads, 63 sectors/track, 1 cylinders, total 16384 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xf3e250f0 Device Boot Start End Blocks Id System /tmp/test.ima1 * 2048 16383 7168 83 Linux Command (m for help): w The partition table has been altered! Syncing disks.
Mount partitioned image on loop device
This is using offset to start of the partition (the start of the filesystem), see http://www.richud.com/wiki/Ubuntu_Create_Hard_Drive_Image#Get image offset to mount on loop device
$ losetup -o 1048576 /dev/loop0 /tmp/test.ima
Format ext4
Not using FAT saves having to fixup the boot sector
$ mkfs.ext4 -L Cyclone /dev/loop0 mke2fs 1.41.14 (22-Dec-2010) Filesystem label=Cyclone OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 1792 inodes, 7168 blocks 358 blocks (4.99%) reserved for the super user First data block=1 Maximum filesystem blocks=7340032 1 block group 8192 blocks per group, 8192 fragments per group 1792 inodes per group Writing inode tables: done Creating journal (1024 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 36 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Remove wasted space
(Can omit the tune steps if feeling lazy)
$ tune2fs /dev/loop0 -m0 -O sparse_super tune2fs 1.41.14 (22-Dec-2010) Setting reserved blocks percentage to 0% (0 blocks) $ tune2fs -O ^has_journal /dev/loop0 tune2fs 1.41.14 (22-Dec-2010)
Mount created image
$ udisks --mount /dev/loop0 Mounted /org/freedesktop/UDisks/devices/loop1 at /media/Cyclone
Create extlinux boot sector
- This is equivalent command to writing a syslinux boot sector for FAT
$ syslinux-4.05/extlinux/extlinux --install /media/Cyclone /media/Cyclone is device /dev/loop0 Warning: unable to obtain device geometry (defaulting to 64 heads, 32 sectors) (on hard disks, this is usually harmless.)
Create kernel image from Rom-o-Matic
- select syslinux/grub/lilo kernel
- select all drivers (default)
- Enter this into the script box, changing XXX for you ip/hostname and "pxe" to your server pxe root path, if changed
dhcp net0 set 209:string pxelinux.cfg/default set 210:string http://xxx.xxx.xxx.xxx/pxe/ chain ${210:string}pxelinux.0
- click create image , save out created kernel "gpxe-1.0.1+-gpxe.lkrn", in this examples to /media/7200.12/gpxe-1.0.1+-gpxe.lkrn
Copy kernel to mounted stick
$ cp /media/7200.12/gpxe-1.0.1+-gpxe.lkrn /media/Cyclone/
Create the most basic config
$ echo "DEFAULT /gpxe-1.0.1+-gpxe.lkrn" > /media/Cyclone/syslinux.cfg
Unmount image
$ udisks --unmount /dev/loop0
Test the image
(optional)
qemu -hda /tmp/test.ima
It should boot up and connect to your server
Copy image to usb stick
Insert a USB stick and make sure its unmounted (automount may well be default), assuming its /dev/sdd
$ udisks --unmount /dev/sdd1
Then write the image to the stick, and "sync" to make sure its finished writing.
$ dd if=/tmp/test.ima of=/dev/sdd bs=1M 8+0 records in 8+0 records out 8388608 bytes (8.4 MB) copied, 6.38277 s, 1.3 MB/s $ sync
Then you can yank the stick out and it should chain load through to the server! You can now image from anywhere you have inet connection!