Cubian X – How to move filesystem to HDD

  • SumoMe

If you want to boot Cubian from a hard drive instead of the SD card or the nand flash, you can attach the hard disk to your Cubieboard via USB or via the SATA connector. I connected mine via USB, using a powered USB hub, since I noticed the Cubieboard didn’t provide enough power for the hard drive, when connected directly.

The tutorial is focused on Cubian X, but with minor changes should work for other distributions as well.

  1. Get the path to your hard disk (should be something like /dev/sda1):
    sudo fdisk -l [enter]
  2. Create a primary partition on your hard drive. Be aware that all the information on your hard drive will be lost!:
    sudo fdisk /dev/sda[enter]

    Replace /dev/sda with the path you got in step 1.
    To create the partition you should issue the following commands:

    Command (m for help): n [enter]
    Partition type:
    p primary (0 primary, 0 extended, 4 free)
    e extended
    Select (default p): p [enter]
    Partition number (1-4, default 1): [enter]
    Using default value 1
    First sector (2048-524288000, default 2048): [enter]
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-524288000, default 524288000): [enter]
    Using default value 524288000

    Note that if you have any existing partitions you need to remove them first, so your outout may vary slightly. You can always type m [enter] for help.

  3. Create a filesystem on your newly created partition:
    sudo mkfs.ext4 /dev/sda1 [enter]

    Again, I’m assuming your partition is /dev/sda1, but make sure to adjust your commands if your setup is different.

  4. Move rootfs to the hard drive:
    sudo dd if=/dev/nandb of=/dev/sda1 bs=1M [enter]
    sudo sync [enter]

    Here I’m moving rootfs from the nand to the hard drive, as I previously installed Cubian on the nand via cubian-nandinstall. To move it from the SD-card, you should probably use:

    sudo dd if=/dev/mmcblk0p2 of=/dev/sda1 bs=1M [enter]
    sudo sync [enter]

    This might take a while, be patient.

  5. Edit uEnv.txt:
    sudo nano /boot/uEnv.txt [enter]

    Replace this line:

    root=/dev/nandb rootwait

    or this one (if you move the filesystem from the SD card):

    root=/dev/mmcblk0p2 rootwait


    root=/dev/sda1 rootwait
  6. Reboot your system:
    sudo reboot [enter]

    Cubian should now boot from the hard drive. Give it some time.

  7. Resize the filesystem to fully use your hard drive space:
    sudo resize2fs /dev/sda1 [enter]
  8. Edit /etc/fstab:
    sudo nano /etc/fstab [enter]

    and replace this line:

    /dev/mmcblk0p2 / ext4 defaults 0 1

    or this line:

    /dev/nandb / ext4 defaults 0 1


    /dev/sda1 / ext4 defaults 0 1

That’s all!

Leave a Reply

Your email address will not be published. Required fields are marked *