193 | | 12. install to bootable media: |
194 | | * For a removable block storage device supported by your board such as a USB Mass Storage device, a microSD, an mSATA SSD the example below will create a single ext4 rootfs partition on a removable block storage device. Ensure you set DEVICE properly for your system. We use the 'udisks' application for mount/unmount so that the mount-point is obvious - if you know what your doing you could use standard mount/unmount as well: |
195 | | {{{ |
196 | | #!bash |
197 | | DEVICE=/dev/sdc |
198 | | # unmount all auto-mounted partitions for this device |
199 | | sudo umount ${DEVICE}? |
200 | | # partition disk - single ext partition |
201 | | printf ",,L,,\n" | sudo sfdisk -uS ${DEVICE} |
| 185 | At this point you have a directory containing a root filesystem (without kernel) and likely want to install it onto removable storage or the on-board FLASH of a target board. Some intermediate formats that are useful to keep around would be a tarball, perhaps an ext4 filesystem image, or a compressed disk image suitable for flashing in the U-Boot bootloader. |
| 186 | |
| 187 | To create a tarball which is the most flexible storage format and can be used for a variety of future installation uses: |
| 188 | {{{#!bash |
| 189 | sudo tar --numeric-owner -cvJf xenial-newport.tar.xz rootfs/ . |
| 190 | }}} |
| 191 | |
| 192 | To create a 'Compressed Disk Image' using this tarball see [#disk-images above] and to install this onto a board's embedded FLASH see [wiki:newport#serial-ethernet here]. |
| 193 | |
| 194 | |
| 195 | === ext4 filesystem === |
| 196 | If desired you can create an ext4 filesystem from the directory or tarball. This requires you choose a size for the filesystem. This size can be increased at runtime using {{{resize2fs}}} as long as the partition table has room for it to grow. The advantage of using an as small as possible size is that the time necessary to flash it onto storage is reduced to a minimum (when flashing you have to write the entire ext4 fs but when formatting or resizing it only has to write periodic markers to FLASH). |
| 197 | |
| 198 | For a given size (see SIZEMB variable below) you can create a rootfs with: |
| 199 | {{{#!bash |
| 200 | SIZEMB=1536 # 1.5GB - expandable later with resize2fs |
| 201 | OUT=xenial-newport.ext4 |
| 202 | # create a file of specific size |
| 203 | truncate -s ${SIZEMB}M ${OUT} |
| 204 | # format it as an ext4 filesystem |
| 205 | mkfs.ext4 -q -F -L rootfs ${OUT} |
| 206 | # mount it to a temporary mount point |
| 207 | tmp_mnt=$(mktemp -d -p/tmp) |
| 208 | mount ${OUT} ${tmp_mnt} |
| 209 | # copy files to it |
| 210 | cp -rup rootfs/* ${tmp_mnt} |
| 211 | # and/or extract files from a tarball |
| 212 | tar -C ${tmp_mnt} -xf linux-newport.tar.xz |
| 213 | # unmount temporary mount point |
| 214 | umount ${tmp_mnt} |