Saturday, September 22, 2012

Booting Fedora 17 from an SD Card

After booting from the external drive (Fedora 17 Live), I mounted the ISO file in loopback mode
[root@localhost home]# mkdir /tmp/livecd
[root@localhost home]# mount -o loop /run/media/liveuser/WINDOWS/Fedora-17-i686-Live-Desktop.iso /tmp/livecd
[root@localhost home]# cd /tmp/livecd/LiveOS/
Next make sure that you have an empty SD Card at '/dev/mmcblk0'. Erase the head if need be and recreate the partition table.
## Destroys partition table and MBR
[root@localhost LiveOS]# dd if=/dev/zero of=/dev/mmcblk0 bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 21.0922 s, 5.0 MB/s

[root@localhost LiveOS]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.21.1).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


WARNING: GPT (GUID Partition Table) detected on '/dev/mmcblk0'! The util fdisk doesn't support GPT. Use GNU Parted.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x4bc55751.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-3994623, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3994623, default 3994623): 
Using default value 3994623
Partition 1 of type Linux and of size 1.9 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): b
Changed system type of partition 1 to b (W95 FAT32)

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p
Disk /dev/mmcblk0: 2045 MB, 2045247488 bytes
4 heads, 16 sectors/track, 62416 cylinders, total 3994624 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: 0x59ff053c

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1   *        2048     3994623     1996288    b  W95 FAT32

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
[root@localhost ~]# 
Next, create a file system on the SD Card partition as per:
[root@localhost ~]# mkdosfs -n SDCARD -F 32 /dev/mmcblk0p1 
mkdosfs 3.0.12 (29 Oct 2011)
[root@localhost ~]# 
Once the SD Card has been prepared, use the 'livecd-iso-to-disk' utility to make our live Fedora card.
[root@localhost LiveOS]# ./livecd-iso-to-disk --reset-mbr /run/media/liveuser/WINDOWS/Fedora-17-i686-Live-Desktop.iso /dev/mmcblk0p1 Verifying image...
/run/media/liveuser/WINDOWS/Fedora-17-i686-Live-Desktop.iso:   69c0ec4f4d8cd8203cb1e46a09001acc
Fragment sums: 11b5317a1a8a1cf35b9ff2184d716cae27c68d34b4c7b64f2ef714cfb399
Fragment count: 20
Press [Esc] to abort check.
Checking: 100.0%

The media check is complete, the result is: PASS.

It is OK to use this media.
WARNING: THIS WILL DESTROY ANY DATA ON /dev/mmcblk0!!!
Press Enter to continue or ctrl-c to abort

2 bytes were erased at offset 0x000001fe (dos): 55 aa
Waiting for devices to settle...
mkdosfs 3.0.12 (29 Oct 2011)
/dev/mmcblk01: No such file or directory
Cleaning up to exit...
[root@localhost LiveOS]# 
At this point, the card is bootable and ready to test.
Unfortunately, this didn't work well for me. So I followed an alternate route. I now tried to use a Mac to make the SD Card bootable.
Convert the ISO file into an IMG using the 'hdiutil' as per:
ksutaria@Downloads$ hdiutil convert -format UDRW -o ./Fedora-17-i686-Live-Desktop.img ./Fedora-17-i686-Live-Desktop.iso
Reading Master Boot Record (MBR : 0)…
Reading Fedora-17-i686-Live-Desktop.iso  (Apple_ISO : 1)…
Reading  (Type EF : 2)…
Reading Fedora-17-i686-Live-Desktop.iso  (Apple_ISO : 3)…
...............................................................................
Elapsed Time: 32.124s
Speed: 20.1Mbytes/sec
Savings: 0.0%
created: /Users/ksutaria/Downloads/Fedora-17-i686-Live-Desktop.img.dmg
ksutaria@Downloads$ mv Fedora-17-i686-Live-Desktop.img.dmg Fedora-17-i686-Live-Desktop.i
Fedora-17-i686-Live-Desktop.img.dmg  Fedora-17-i686-Live-Desktop.iso
Note that Macs tend to add ".dmg" to the file name. Fix this:
ksutaria@Downloads$ mv Fedora-17-i686-Live-Desktop.img.dmg Fedora-17-i686-Live-Desktop.img
Next, identify the right disk by using "diskutil list". Once identified use dd to write the image to the card. Note that the use of "rdisk" instead of "disk" may result in a quicker flush to disk. YMMV.
ksutaria@Downloads$ sudo dd if=/Users/ksutaria/Downloads/Fedora-17-i686-Live-Desktop.img of=/dev/rdisk1 bs=1m
645+1 records in
645+1 records out
677355520 bytes transferred in 177.251607 secs (3821435 bytes/sec)
ksutaria@Downloads$ 

0 comments: