Booting a TonidoPlug from an External USB or Internal SATA Drive

Here are the steps that you need to follow to put a root filesystem on an external USB drive or internal SATA drive (TonidoPlug 2 only). The process for building a bootable drive is the same whether the drive is an internal SATA or external USB.

These same steps can also be used from the command prompt on any Linux OS to build a bootable USB for the TonidoPlug. This is useful if you need to create a “rescue” USB for your plug.

1. Connect the USB or SATA drive to TonidoPlug. On the Plug v2, the USB or SATA drive will be mounted as media/disk1part1. On the Plug v1, the USB drive will be automounted on /media/usb0; we will set up a new mount point.
Stop samba server and unmount the USB/SATA drive before proceeding. To do this, establish an SSH connection to the TonidoPlug and run the following commands:

TonidoPlug 2:

/etc/init.d/samba stop
umount /media/disk1part1

TonidoPlug 1:

/etc/init.d/samba stop
umount /media/usb0
mkdir /media/disk1part1

2. Make sure the USB/SATA drive is not mounted anywhere else. To do this, check the output of the following command:

mount
rootfs on / type rootfs (rw)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,nosuid,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
tmpfs on /var/cache/apt type tmpfs (rw,noatime)

As you can see the USB/SATA hard drive (usually /dev/sdaX) is not mounted anywhere else.

Doing two extra steps will help ensure a trouble free installation:
- Make sure your partition table layout is MBR (MS-DOS) and not GPT. The TonidoPlug will not boot from GPT disks.
- Create a fresh Linux partition before formatting. It can save hours of frustration with drives that fail to boot or permissions that cannot be modified.

3. Check to see that your drive’s partition table layout is ms-dos (MBR) and not GPT. A GPT partition layout is the most common reason a plug fails to boot from USB or SATA drive. Take the time to check.

parted
(parted) select /dev/sda
(parted) print

The output should include the line:
Partition Table: msdos

If it does not, you need to change the partition table layout before proceeding.

parted
(parted) select /dev/sda
(parted) mklabel msdos
(parted) quit

Changing the partition table layout to ms-dos with effectively wipe all the data on the drive.

4. Remove existing partitions and create a new partition on your USB/SATA drive.

a. Start fdisk to partition the USB/SATA drive:

   fdisk /dev/sda 

At the fdisk prompt, delete old partitions and create a new one:

b. Type o. This will clear out any partitions on the drive.
c. Type p to list partitions. There should be no partitions left.
d. Now type n (for new partition), then p for primary, 1 for the first partition on the drive, and then press ENTER, accepting default values.
e. Type a. This will toggle the bootable flag on the drive, then 1 for the first partion on the drive, and then press ENTER.
f. Exit by typing w.

Deleting existing partitions on the USB/SATA drive will wipe all the data on the drive!

5. Format the USB/SATA drive partition. You are about to create Ext3 filesystem on the USB/SATA drive partition:

mkfs.ext3 /dev/sda1

Formatting the USB/SATA drive will wipe all the data on the partition!

If you have multiple partitions on your USB/SATA drive, you have to use the first partition, because the TonidoPlug will boot only from the first partition of any drive.

6. Once the formatting is completed, mount the partition on a temporary directory:

mount /dev/sda1 /media/disk1part1

7. Download the root and modules tar ball from TonidoPlug site and place in the newly created Ext3 partition:

TonidoPlug 2:

cd /media/disk1part1
wget http://www.tonido.com/downloads/plug2/rootfs.tar.gz

TonidoPlug 1:

cd /media/disk1part1
wget http://www.tonido.com/downloads/plug/rootfs.tar.gz
wget http://www.tonido.com/downloads/plug/modules.tar.gz

Please make sure the checksum of the files match the following values:

TonidoPlug 2:

md5sum rootfs.tar.gz
2f02407d8161acc42ccac0e6815f04c5 rootfs.tar.gz

TonidoPlug 1:

md5sum  rootfs.tar.gz
958a32161e1daf1c79d88b1c6f6e85bf  rootfs.tar.gz
md5sum modules.tar.gz
c2b89c8dd681656427b27a2fc1db725f  modules.tar.gz

8. Untar the downloaded tar file onto the Ext3 partition:

TonidoPlug 2:

tar zxvf rootfs.tar.gz

TonidoPlug 1:

tar zxvf rootfs.tar.gz
tar zxvf modules.tar.gz

9. Now stop tonido and copy the tonido directory from your existing internal flash disk.

initctl emit tstop
cp -dpr /root/app/ /media/disk1part1/root/

10. Now everything is ready. You can unmount the drive and reboot the plug. Leave the USB hard disk on the plug itself. When the plug reboots, it should reboot off the USB/SATA drive:

cd /root
umount /media/disk1part1
reboot

11. You can ensure that the plug has booted on the external USB/SATA drive by using the following command.

df -h /
Filesystem            Size  Used Avail Use% Mounted on
rootfs                3.8G  669M  2.9G  19% /

In this case, you can see that we have booted the plug from the 4GB USB stick. If you see 512MB then probably you are still booting off the internal flash.


Source: http://www.tonido.com/forum/viewtopic.php?f=37&t=312&start=0, http://www.tonido.com/support/display/docs/Booting+off+USB+Drive