<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 8, 2016, at 7:29 AM, Patrick &lt;<a href="mailto:plafratt@gmail.com" class="">plafratt@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><span style="font-family:arial,sans-serif" class="">On Fri, Mar 4, 2016 at 9:09 PM, 张云 </span><span dir="ltr" style="font-family:arial,sans-serif" class="">&lt;<a href="mailto:zyunone@163.com" target="_blank" class="">zyunone@163.com</a>&gt;</span><span style="font-family:arial,sans-serif" class=""> wrote:</span><br class=""></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">First your must know exactly how linux boot (not at source code level).<br class="">
<br class="">
Most recent linux distributions boot as<br class="">
<br class="">
&nbsp; &nbsp; &nbsp; &nbsp; grub —&gt; kernel —&gt; initramfs’ /init executable<br class="">
<br class="">
All the userspace affair is started by initramfs’ /init. Kernel no longer join the boot process.<br class="">
<br class="">
&gt;From you description, I think you were blocked by the initramfs concept. Initramfs is the first root filesystem and reside in memeory.<br class="">
It’s loaded by grub, and the kernel automatically mount it, execute the /init. The /init executable can do some extra initialisation<br class="">
and switch to the real root filesystem on disk.<br class="">
for detail /Documentaion/filesystems/ramfs-rootfs-initramfs<br class="">
<br class="">
Hope that would be useful to your.<br class="">
</blockquote></div><br class=""></div><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">​Thanks for the response. I was able to get a minimal boot using the files in the mini.iso image from Ubuntu.​ I just copied the kernel and the ramdisk image from that iso, and these have given me enough to start learning some things. It is still just dropping me into the prompt for the ramdisk image, so the kernel hasn't yet made the switch over to root filesystem on a drive, but this is at least enough to get me started.</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">One thing I noticed that confused me was the result of the commands pasted below. It looks like the partition table on the disk image might be getting messed up. But, interestingly enough, it still seems to allow me to use the image for booting. In spite of this, fdisk is giving me strange output when I ask it to print out the partition tables after I build a file system on the disk image using mkfs. When I look at the disk image using gparted, on the other hand, it actually looks OK.</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">It looks like I might be using mkfs incorrectly. Can anyone see anything obvious that I am doing wrong?</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">==============</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">dd if=/dev/zero of=./disk.img bs=1M count=1000</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">sudo losetup /dev/loop0 ./disk.img</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">sudo fdisk /dev/loop0</div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">(commands in fdisk)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; n (new partition)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; p (primary partition)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; 1 (partition number)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; (default start and end for partition)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; t (change type of partition)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; b (change type of partition to FAT32)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; a (set boot flag)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; 1 (set boot flag for first partition)</div></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">&gt; w (write changes)</div></div></blockquote><font face="georgia, serif" class=""><div class="gmail_default" style="font-family:georgia,serif;font-size:small;display:inline">​fdisk -lu /dev/loop0</div></font><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class=""><font face="georgia, serif" class=""><div class="gmail_default" style="font-family:georgia,serif;font-size:small;display:inline">​</div>Disk /dev/loo</font><span style="font-family:georgia,serif" class="">​p0​</span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class=""><font face="georgia, serif" class="">: 1048 MB, 1048576000 bytes</font></div><div class=""><font face="georgia, serif" class=""><div class="">123 heads, 59 sectors/track, 282 cylinders, total 2048000 sectors</div></font></div><div class=""><font face="georgia, serif" class=""><div class="">Units = sectors of 1 * 512 = 512 bytes</div></font></div><div class=""><font face="georgia, serif" class=""><div class="">Sector size (logical/physical): 512 bytes / 512 bytes</div></font></div><div class=""><font face="georgia, serif" class=""><div class="">I/O size (minimum/optimal): 512 bytes / 512 bytes</div></font></div><div class=""><font face="georgia, serif" class=""><div class="">Disk identifier: 0x7b9351bf</div></font></div><div class=""><font face="georgia, serif" class=""><div class=""><br class=""></div></font></div><div class=""><font face="georgia, serif" class=""><div class="">&nbsp; &nbsp; &nbsp; Device Boot &nbsp; &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; &nbsp; &nbsp;Blocks &nbsp; Id &nbsp;System</div></font></div><div class=""><font face="georgia, serif" class=""><div class="">/dev/loop<div class="gmail_default" style="font-family:georgia,serif;font-size:small;display:inline">​0​</div>p1 &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp;2048 &nbsp; &nbsp; 2047999 &nbsp; &nbsp; 1022976 &nbsp; &nbsp;b &nbsp;W95 FAT32</div></font></div></blockquote><div class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br class=""></div></div></div></div></div></blockquote><div><br class=""></div>The problem is caused by the command below</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">mkfs -t vfat /dev/loop0</div></div></div></div></div></blockquote><div><br class=""></div><div>/dev/loop0 is the whole disk, and /dev/loop0p1 is the partition.</div><div><br class=""></div><div>The command make a file system on the disk, thus overrides the disk’s partition table. &nbsp;</div><div><br class=""></div><div>I guess that it is the partition on which you want to make a filesystem.</div><div>The right command is&nbsp;</div><div><br class=""></div><div>&nbsp; &nbsp; &nbsp; mkfs -t ext2 /dev/loop0p1</div><div><br class=""></div><div>We prefer ext2,3,4 to fat32 on linux.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">fdisk -lu /dev/loop0</div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><span style="font-family:georgia,serif;font-size:small" class="">​</span><font face="georgia, serif" class="">Disk /dev/loop0: 1048 MB, 1048576000 bytes</font></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><font face="georgia, serif" class="">255 heads, 63 sectors/track, 127 cylinders, total 2048000 sectors</font></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><font face="georgia, serif" class="">Units = sectors of 1 * 512 = 512 bytes</font></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><font face="georgia, serif" class="">Sector size (logical/physical): 512 bytes / 512 bytes</font></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><font face="georgia, serif" class="">I/O size (minimum/optimal): 512 bytes / 512 bytes</font></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><font face="georgia, serif" class="">Disk identifier: 0x00000000</font></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><font face="georgia, serif" class=""><br class=""></font></div></div></div><div class=""><div class="gmail_extra"><div class="gmail_default" style=""><font face="georgia, serif" class="">&nbsp; &nbsp; &nbsp; Device Boot &nbsp; &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; &nbsp; &nbsp;Blocks &nbsp; Id &nbsp;System</font><span style="font-family:georgia,serif;font-size:small" class="">​</span></div></div></div></blockquote><div class=""><div class="gmail_extra"><br class=""></div></div><div class="gmail_extra"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">​==============</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Thanks,</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Patrick​</div><br class=""></div></div>
_______________________________________________<br class="">Kernelnewbies mailing list<br class=""><a href="mailto:Kernelnewbies@kernelnewbies.org" class="">Kernelnewbies@kernelnewbies.org</a><br class="">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies<br class=""></div></blockquote></div><br class=""></body></html>