NSLU2-Linux
view · edit · print · history

How to add a second drive with multiple partitions to R63/Unslung6

This is an extension of the description of a non-native disk mount at NonNativeDiskMount. It is also related to CustomSizedPartitions.

Due to the odd behavior of rc.bootbin as discussed in R63DiskBehaviour,'''it is not advisable to use two natively-formatted disks in R63 or Unslung6!''' It is possible to partition, format and add a second drive manually without complications.

This method creates three partitions -- one NTFS, one ext3 and one swap.

Following WhichUSBPortforUnslung6 recommendations, root will be installed on the NSLU disk port 2 (/dev/sda) and the hard disk in port 1 (/dev/sdb). The instructions will use a memory stick for the root device.

Start with a fresh NSLU2, and have access to a Windows machine.

  1. Ensure that the memory stick does not have a old Unslung partitions on it. Repartition and reformat if required.
  2. Flash Unslung 6.x following the Readme. When instructed to format the disk (memory stick), ensure that you put it in the Disk 2 port....unsling to disk 2, reboot, install ssh, etc. Then turn off the slug. Do not attempt to install shares or users yet.
  3. Prepare the hard drive. Connect it to a Window machine. Start Menu-->My Computer-->Manage. In the computer management application, use the "Storage-->Disk Management" application to add a primary partition taking up all but about 10 GB of the disk (or however much you want to leave for the ext3 partitions). I recommend that you let the Window machine entirely format the new partition to NTFS -- not using quick format. (Also, see the note below).
  4. Connect the hard disk to the slug and restart.
  5. Establish a telnet or ssh connection to the slug and log in as root.
  6. Access the fdisk command to manage the disk: /bin/busybox fdisk /dev/sdb
  7. Add the first new partition. You can accept the default starting cylinder. For the end cylinder use less than the default to leave some for the third partition (see the note below).
  8. Add the last new partition, accepting the defaults for start and end cylinders to use up the remainder of the device.
  9. Change the partition type for the swap partition (swap is type 82).
  10. Exit fdisk by writing (not quiting). I received an error message at this point, but with no noticable effect.
  11. Format the second new partition to ext3: mkfs.ext3 /dev/sdb2
  12. Prepare the swap space: mkswap /dev/sdb3
  13. Now create a diversion script to mount the new partitions and turn on the swap space at boot time. Create file /unslung/rc.samba with the following contents (also see note below):
 
#!/bin/sh
#
# Under Linksys R63, this first mount command
# is not needed if the first partition is NTFS
# (or FAT?)
# 
# mount /dev/sdb1 /share/hdd/data

mount /dev/sdb /share/hdd/conf

swapon /dev/sdb3

return 1

NOTE: My [R63] slug auto-mounts the NTFS partition that is the first one on the disk. During my first attempt, I put a couple dummy partitions on the drive before adding the NTFS one, so it ended up third on the disk. I might be recalling incorrectly, but I don't think it was auto-mounted later.

NOTE: After some time and unknown events...possibly due to temporarily swapping the disk drive to a Windows machine, the automount of the NTFS partition stopped working. When that occurred I had to uncomment the first mount command in the above script (and change some scripts towards the new mount point).

NOTE: Regarding the size of a swap partition. Probably best to make sure it is at least as large as the slug's memory (32MB), better twice the memory (though that might be a bit overkill on a slug). If you do the command p (print) in fdisk, you'll see that a cylinder is about 8 MB. I used 25 cylinders in my swap and have around 200 MB available.

After rebooting, you should be able to see the new partitions

 
# df
Filesystem           1k-blocks      Used Available Use% Mounted on
/dev/sda1              1718400    125468   1575476   7% /
/dev/mtdblock4            6528      6204       324  95% /initrd
/dev/sda1              1718400    125468   1575476   7% /share/flash/data
/dev/sda2               122963      4149    117545   3% /share/flash/conf
/dev/sdb1            302078192 111448992 190629200  37% /share/hdd/data/HDD_1_1_1
/dev/sdb2             10128084     57916   9555688   1% /share/hdd/conf

# free
              total         used         free       shared      buffers
  Mem:        30516        29856          660            0        12548
 Swap:       200804         4840       195964
Total:       231320        34696       196624

# swapoff /dev/sdb3
# free
              total         used         free       shared      buffers
  Mem:        30516        29608          908            0          480
 Swap:            0            0            0
Total:        30516        29608          908


That free output was from a baseline slug with only mt-daapd added. As the second free shows, if the swap is removed it just uses up the buffers. The point is, if it has swap available, the slug is going to tend to use it for some things.

CAUTION: I do not believe this is related, but mentioning it just in case. At some point after doing this, my slug started booting slowly, was not available via the web server and after about one out of ten boots the ssh daemon would not start and I couldn't log in. Looking into /var/log/messages, I discovered warnings about Out of Memory conditions and killing of processes. The first such message was the first message after the system time had been updated. And that message was alway about killing the thttpd process. I went so far as to remove the third partition (swap space) describe on this page, but that did not solve the problem. (Re-created it later). The situation appears to be fixed by adding a diversion script that turned on the new swap space before attempting to start the thttpd process, /unslung/rc.thttpd

 
#/bin/sh
# /unslung/rc.thttpd
#
swapon /dev/sdb3

return 1

view · edit · print · history · Last edited by dbh.
Originally by dbh.
Page last modified on March 01, 2009, at 05:12 AM