/
Using the Certified Ubuntu on Xilinx Devices image with a SATA hard disk

Using the Certified Ubuntu on Xilinx Devices image with a SATA hard disk

This page details how to use the Certified Ubuntu on Xilinx Device release image with a SATA hard disk rather than via the typical SD Card-based filesystem.

Table of Contents

Introduction

By default, the Certified Ubuntu on Xilinx Devices image is configured to use an ext4 partition located on an SD card.  This can be limiting, both in terms of partition size as well as speed.  This page describes how to configure the Certified Ubuntu on Xilinx Devices to use an ext4 partition (and swap partition) located on a SATA hard disk on the ZCU102 evaluation platform (other platforms are similar so long as they have SATA available).

The instructions on this page use a command line environment via the USB UART terminal but the same commands can be run via a terminal emulator in the Ubuntu GUI from the running system.

Selecting the Hardware

Before beginning, you will need to acquire at lest the following items:

  • SATA hard disk of a suitable size

  • SATA cable

  • SATA power connector

Selecting the SATA hard disk size is an important consideration, largely driven by your target application. As seen in the default configuration on the SD card, the Ubuntu installation can fit in a disk as small as ~8GB. Most SATA hard disks are considerably larger than this so it is wise to evaluate the packages that you intend to use and then choose a disk that is large enough to store all of those packages with some space left over for things such as temporary files and the swap partition. If budget allows it is recommended to start at 64GB in size as a minimum.

Additionally, this example uses a SATA-attached solid state drive because they are low-power devices. This example can work with a traditional magnetic storage drive.

As seen in the image below, this example used a combination power/data cable for SATA devices. This specific adapter can be purchased from Amazon.com here: https://smile.amazon.com/dp/B06XXZSHJS/ref=cm_sw_r_tw_dp_JRSRRE1KPVGKJ92E2K73

If you do not have this adapter, Molex-to-SATA power and SATA data cable will work.

Attach the Hardware

The ZCU102 evaluation board has everything needed to attach a SATA hard disk.  It has a SATA hard disk data connector as well as a 4-connector Molex power connector.  Start by attaching the hard disk to both data and power as shown in the image below.

 

Partitioning the Hard Disk

To get started, first make sure that the disk is working properly.  The easiest way is to boot into Ubuntu like normal after attaching the hard disk.  Once Ubuntu starts, log in like normal and check the dmesg log to see if the hard disk was found.  By default, it will be located at /dev/sda (this may be different depending on the hard disk).

 

In this example, a hard disk was found at /dev/sda and it has two partitions: sda1 (an existing ext4 partition) and sda2 (and existing swap partition).  Next, use the command line parted tool to re-initialize the disk and set up new partitions.

Start by launching parted

$ sudo parted /dev/sda

This will start the parted terminal interface.  You can see a current listing of the existing partitions by using the print command:

(parted) print

 

Next, clear the existing partition table by issuing:

(parted) mklabel msdos

You will be prompted to confirm since this is a destructive operation.  Types “Yes” to continue. 

After, initializing the disk, you can verify that the disk has been cleared by re-running the print command.

To create a new partition, use the mkpart command.  In this example, the partition is being created as a primary partition, formatted as ext4.  The size dimension will extend from the beginning of the disk (0%) to 239GB.  If your desired partition size is larger or smaller, alter the second size value accordingly.

(parted) mkpart primary ext4 0% 250GB

Next, create another partition that can be used for the swap space area. By definition, this partition will be an extended partition but a logical partition must also be created so that it can be assigned the linux-swap type. The specific size of the swap partition is a decision that is heavily dependent upon the intended use of the system. Red Hat has guidance on swap partition sizes (and whether or not a swap partition is needed at all) on their wiki.

(parted) mkpart extended 250GB 256GB

(parted) mkpart logical linux-swap 250GB 256GB

Now, you can verify the layout looks the way you expect.  The output should be similar to:

(parted) print Model: ATA LITEONIT LCS-256 (scsi) Disk /dev/sda: 256GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number  Start   End    Size    Type      File system     Flags  1      1049kB  250GB  250GB   primary   ext4            lba 2      250GB   256GB  6060MB  extended                  lba 5      250GB   256GB  6059MB  logical   linux-swap(v1)  lba

Once you are satisfied with the partition layout, exit the parted tool by simply using the quit command.

(parted) quit

Next, initialize the data and swap partitions by formatting them. First, the primary data partition must be formatted. In this example it is being formatted as an ext4 filesystem so the mkfs.ext4 command will be used. Substitute the appropriate mkfs command for other filesystems.

ubuntu@zynqmp:~$ sudo mkfs.ext4 /dev/sda1 mke2fs 1.45.5 (07-Jan-2020) /dev/sda1 contains a ext4 file system last mounted on / on Wed Dec 15 15:59:28 2021 Proceed anyway? (y,N) y Discarding device blocks: done Creating filesystem with 61035008 4k blocks and 15261696 inodes Filesystem UUID: db2ad263-853e-44b4-8fa3-40cb2c2e5405 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done