Next Previous Contents

4. Drive swap

This chapter describes how to install a new diskimage on a NetWinder by removing the hard disk and installing it as the slave drive in another system. This method is not recommended since it will void the warrantee, but its a practical method especially for those people with very small hard disks.

4.1 Requirements

This method requires a second computer where the NetWinder's hard disk can be installed. The second machine could be another NetWinder, or an ordinary PC running some form of unix. In the case of a regular PC, an adaptor cable is required since the NetWinder hard drive is of the 2.5" laptop variety, which will not plug directly into the normal IDE connectors. Adaptors are available at most computer stores for about $10.

Static electricity can kill a NetWinder! Be sure to be properly grounded before you start poking around inside your computer.

4.2 Preparation

The NetWinder's hard drive should be connected to the host computers IDE controller, and (possibly) the master/slave jumper will need to be adjusted on the NetWinder's drive. To gain access to the drive, open the four screws on the bottom of the NetWinder. Usually it's possible to move the NetWinder close enough to the PC so that the cable can be directly connected, if not, you'll have to remove the hard drive itself (the screws are on the bottom of the motherboard).

Once the drive is connected, the PC can be powered up. Do whatever is necessary for the drive to be detected (this might mean going into the BIOS and specifying the drive parameters, or on modern PC's, the drive will be auto-detected). I'll assume for the purpose of this example that the PC's main hard drive is /dev/hda and that the NetWinder's drive is /dev/hdb - but you'll have to verify that this is the case on your machine (use the dmesg command for this).

4.3 Freeing space

There must be enough room to install the new disk image on the NetWinder's drive. You have the option of moving/deleting files to free up a partition, or you might choose to format the NetWinder's hard disk completely and repartition it as you wish. I cannot give you a step-by-step guide here, so I'll describe the available options and let you decide.

Moving files between partitions

To transfer files between partitions, you need to mount both partitions and then use the cp and rm commands. Two mountpoints are required for this - you can use any two directories - for example /mnt/one and /mnt/two. Of course the directories must exist before they can be used, so go wild with the mkdir command. Then mount the two partitions (picking on /dev/hdb1 and /dev/hdb2 for this example):

        mount /dev/hdb1 /mnt/one
        mount /dev/hdb2 /mnt/two

Now files can be copied from /mnt/one to /mnt/two (or vice-versa) using the cp command. To remove the originals after they've been copied, use the rm command. When you're done, unmount the partitions again:

        sync
        umount /mnt/one
        umount /mnt/two

Formatting a parition

Once a partition has been cleared of files, or if you don't want to keep the old files, the format command can be used to initialize a new filesystem. This will completely wipe out everything on the partition, with no way to restore it. Use with care, and check very carefully that the correct partition and drive are specified.

        mke2fs /dev/hdb1

The preceeding example will format the first partition on the second (slave) drive, presumably the NetWinder drive. In case you're not clear on the naming convention yet, the drives are called /dev/hdXY where X is a letter (a for the first drive, b for the second, etc) and Y is a number indicating the partition (starting from one).

Repartitioning the drive

In some cases it may be desirable to repartition the entire drive, for example if you are updating an old system and don't want to keep the old version anyhow. Note that after repartitioning, you must format the partitions, and this will destroy all data on the drive.

To adjust the partition tables, use the fdisk command. You have to tell it which drive you want to repartition - for example say fdisk /dev/hdb to adjust the partition table on the second (slave) drive. The rest of the commands (for deleting a partition, creating a new one, etc) are explained in the on-line help. There is also a nice man page (man fdisk) that gives more information.

The recommended disk layout is as follows: the first partition is the root filesystem (type 83, Linux) usually about 1 GB in size. The second partition is used for swap (type 82, Linux swap) and is 64 to 128 MB in size. Anything remaining space is allocated to third partition and gets mounted as /home.

4.4 Installing the image

To install the image, you need to ensure that both the source and destination partitions are mounted, then you can use the tar command to extract files from the diskimage. Most likely, the diskimage is located on your main disk (hda) and the destination is the first partition on hdb. In this case, the appropriate commands are as follows:

        mount /dev/hdb1 /mnt/hdb1
        cd /mnt/hdb1
        tar zxpf /path/to/YourImage.tar.gz

You'll need to ensure that the mountpoint /dev/hdb1 exists (or use a different name), and you'll need to specify an appropriate path and filname instead of path/to/YourImage. This process should be pretty quick, about 5-10 minutes, since the data is moving over the IDE bus directly.

4.5 Post installation

After the installation of the disk image is completed, be sure to review the etc/fstab file in the installed image. The entries in this file must correspond with the way the partitions are used, eg. if the first partition contains the main image, then it should be mounted as / in the fstab file. Keep in mind that the drive names listed in the fstab file should be those that will be seen when the disk drive is booted on the NetWinder (/dev/hda in most cases). Also be sure to edit the right etc/fstab file - you want to edit the one in the image you just untarred, not the one belonging to the host PC.

The drive can then be unmounted and the PC can be powered down. The NetWinder's hard disk should then be reinstalled. If the partition usage has changed, then firmware settings may need to be changed. Consult section 2.5 for details, but remember to use the appropriate /dev/hdaX value for your particular situation.


Next Previous Contents