Please, read also the general memdisk introduction.
This page is about using memdisk to run DOS, plus a virtual harddrive in RAM.
Cloning a harddisk, in its simplest form, is just like cloning a floppy. Assumptions:
Then here's what we do to clone this harddisk in our diskless xterm:
[root@xterm root]# mount server:/tftpdir /tftpdir [root@xterm root]# dd if=/dev/hda of=/tftpdir/bigdos [root@xterm root]# gzip -9 /tftpdir/bigdos
[root@server root]# cd /tftpdir [root@server tftpdir]# mkelf-linux --ip=rom --rdnopad memdisk bigdos.gz > bigdos.nb
Of course, you could also disconnect the harddrive from the client and connect it to a linux box, read it out there.
Things get a bit tricky if we want our ram disk to contain only a small partition of a big harddisk. In theory, we can choose any partition of any size as long as we have enough ram to cover every sector of the harddisk from the start (MBR) upto the end of our target partition. In practice however, we prefer partition 1 starting from cylinder 1 to cylinder n because memdisk does not like fractional cylinders in partitions and space between MBR and our target partition will likely be a waste of RAM. Here's what we'll tell dd to copy (instead of the whole disk as before):
[root@xterm root]# dd if=/dev/hda of=/tftpdir/bigdos bs=512 count=S
where S is the total number of sectors from sector 0 (MBR) upto the end of our target partition. We use the -l option in fdisk (linux) to determine the harddisk's geometry and partition information then get S by:
S = number of sectors/track(s) x number of heads(h) x ending cylinder number(n)
Alternatively, some people prefer copying the MBR track and the partition separately like this:
[root@xterm root]# dd if=/dev/hda of=/tftpdir/mbr bs=512 count=s
Note: s here is the number of sectors from start of harddisk (MBR) to start of target partition which, in most cases, is the 'number of sectors/track' as before.
[root@xterm root]# dd if=/dev/hda1 of=/tftpdir/hda1
[root@xterm root]# cat /tftpdir/{mbr,hda1} | gzip -9 > /tftpdir/bigdos.gz