HC1 - OS on hdd?

Post Reply
mintz
Posts: 27
Joined: Wed Feb 27, 2013 7:19 pm
languages_spoken: english
ODROIDs: ODROID U2
Has thanked: 0
Been thanked: 0
Contact:

HC1 - OS on hdd?

Unread post by mintz » Thu Nov 09, 2017 7:50 pm

I have a question about the HC1.
Can i fully install and run ubuntu on the attached harddrive or does it have to be installed on the SD-card?

User avatar
mad_ady
Posts: 6530
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 163 times
Been thanked: 125 times
Contact:

Re: HC1 - OS on hdd?

Unread post by mad_ady » Thu Nov 09, 2017 8:00 pm

You can install and run ubuntu from hdd, but you need at minimum an sd card with the bootloader (and typically kernel)

mintz
Posts: 27
Joined: Wed Feb 27, 2013 7:19 pm
languages_spoken: english
ODROIDs: ODROID U2
Has thanked: 0
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by mintz » Thu Nov 09, 2017 8:27 pm

Does that means that i only need the SDCard for it to boot and after that everything will be running 100% on the HDD side? Reason for this is i am thinking of running a HC1 as homeserver and don't want to have the SDCard read/write speed to compromise the performance.

trilby
Posts: 3
Joined: Tue Oct 24, 2017 8:35 pm
languages_spoken: english
ODROIDs: HC1
Has thanked: 0
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by trilby » Thu Nov 09, 2017 9:51 pm

I followed the instructions in this post to do this: viewtopic.php?t=23925

User avatar
mad_ady
Posts: 6530
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 163 times
Been thanked: 125 times
Contact:

Re: HC1 - OS on hdd?

Unread post by mad_ady » Thu Nov 09, 2017 10:33 pm

@mintz: yes, the sd card would only be read on boot and written to on various upgrades (bootini, uboot, kernel), but it wouldn't be touched otherwise. The guide referenced by @trilby should be just fine.

mintz
Posts: 27
Joined: Wed Feb 27, 2013 7:19 pm
languages_spoken: english
ODROIDs: ODROID U2
Has thanked: 0
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by mintz » Thu Nov 09, 2017 11:17 pm

Thank, guys. HC1 with an SSD ordered :)

adeuring
Posts: 46
Joined: Sun Jul 09, 2017 9:50 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by adeuring » Fri Nov 10, 2017 5:34 am

The guide mentioned by trilby has IMHO two problems:

Firstly, it is way too complex because it mixes the steps to move the OS installation to a HDD/SDD with other things like a VPN setup.

Secondly, and much more importantly, it misses to mention the file boot.ini.default on the boot partition (mounted on /media/boot). It is really important to edit this file too, otherwise any changes to boot.ini will be lost when the package named bootini is updated. (Or did I miss this detail in the guide?)

I intended anyway to install an Ubuntu image for the XU4 on an HDD, so I saved everything I did in a log file. Since the HC1 is basically an XU4 minus HDMI und USB3 ports plus a SATA port, it should be applicable to the HC1 too. Below is this log with some annotations.

Before I start, one remark:

I would strongly recommend to connect a USB/UART adapter to the XU4/HC1, and to watch the boot process via a terminal program from a PC/laptop/other SBC. "Early errors" won't appear on the HDMI output of an XU4, and the HC1 provides any early diagnostic output only on its UART. <offtopic>HK folks, did you consider to add a USB/UART adapter to your boards? At least one Udoo has such an adapter on board, and even at least some Cuboxes have it.</offtopic>

Now let's start. The first step is to install an Ubuntu image on an SD card. For details, refer to the guide on the wiki:
https://wiki.odroid.com/troubleshooting ... hing_tools.

I used the image ubuntu-16.04.3-4.9-minimal-odroid-xu4-20170824.img.xz from https://odroid.in/ubuntu_16.04lts/
This choice (there is a more recent version available) was deliberate: I hoped that an "apt-get upgrade" would install a newer version of the bootini package, thus allowing me to immediately check if the changes to the file boot.ini.default were correct. And as you can see below, a new version was indeed installed during the upgrade.

Then insert the card into the slot of the XU4/HC1, connect the SSD/HDD, connect the ethernet port to your network and, if possible, connect the UART to an USB/UART adapter and the adapter to a PC/laptop.

Next, power the XU4/HC1 on and log in as root (password is "odroid") via the UART or via ssh.
(The wiki has somewhere also a guide how to figure out the IP address of an HC1 and how to make an ssh connection to it.)

Then prepare the SSD/HDD. Firstly, add a partition for the root file system. (The disk of the XU4 was used before elsewhere, so I remvoed the old partition first.)

The keys to type after the "fdisk /dev/sda" are "p" (print current partition table"), "d" to delete the old partition, "n" to create a new partition, "1" for the partition number, <return> for the first and last sector, and finally "w" to write the modified table to the disk.

Code: Select all

root@odroid:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: dos
Disk identifier: 0x6583d705

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 625142447 625140400 298.1G 83 Linux

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-625142447, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-625142447, default 625142447): 

Created a new partition 1 of type 'Linux' and of size 298.1 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Next, we need a file system on the partition:

Code: Select all

root@odroid:~# mkfs.ext4 /dev/sda1
mke2fs 1.42.13 (17-May-2015)
/dev/sda1 contains a ext4 file system
        last mounted on /media/abel/72c0579c-78bc-4e99-aacd-db8c5b651403 on Wed Nov  8 17
Proceed anyway? (y,n) y
Creating filesystem with 78142550 4k blocks and 19537920 inodes
Filesystem UUID: 86d5b640-cd96-49bb-9414-96adcb28eee8
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
Now the new partition on the disk can be mounted:

Code: Select all

root@odroid:~# mount /dev/sda1 /mnt
and the OS installation is copied from the SD card to the HDD:

Code: Select all

root@odroid:~# time tar --one-file-system -cpf - / | (cd /mnt && tar -xpf -)
tar: Removing leading `/' from member names
tar: Removing leading `/' from hard link targets

real    1m10.851s
user    0m1.250s
sys     0m15.760s
Now we need to tell the kernel that the root file system is on the HDD/SSD, not on the SD card. Partitons are nowadays identified by UUIDs, so the first thing is to find the UUID of the partition of the root file system on the HDD/SSD:

Code: Select all

root@odroid:~# lsblk -f
NAME        FSTYPE LABEL  UUID                                 MOUNTPOINT
mmcblk1
|-mmcblk1p1 vfat   boot   52AA-6867                            /media/boot
`-mmcblk1p2 ext4   rootfs e139ce78-9841-40fe-8823-96a304a09859 /
sda
`-sda1      ext4          86d5b640-cd96-49bb-9414-96adcb28eee8 /mnt
So, the partition "sda1" (on the SSD/HDD) has (in my case – UUIDs sould always be different on different systems) the UUID 86d5b640-cd96-49bb-9414-96adcb28eee8, and the currently used root file system on the SD card has the UUID e139ce78-9841-40fe-8823-96a304a09859.

The old UUID is used in three places, the files /media/boot/boot.ini, /media/boot/boot.ini.default and /etc/fstab

/media/boot/boot.ini is the file that specifies the actual boot process, /media/boot/boot.ini.default specifies settings that are used to generate a new file /media/boot/boot.ini during an update of the package "bootini", and /etc/fstab is the traditional Unix file that specifies how disk partitions, network shares etc are to be mounted.

Let's first edit /media/boot/boot.ini. Before typing the command below, copy the UUID of sda1 (i.e., the string "865d...eee8" in my case) into the clipboard.

Next, start nano to edit the file:

Code: Select all

nano /media/boot/boot.ini
In the editor, find this line:

Code: Select all

setenv bootrootfs "console=tty1 console=ttySAC2,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro fsck.repair=yes net.ifnames=0"
(line 160 in the image I used)

Replace the string "e139ce78-9841-40fe-8823-96a304a09859" (or whatever else comes after "UUID=" with the UUID of your sda1 partition. (86d5b640-cd96-49bb-9414-96adcb28eee8 iy my case). Use the "paste" command of your terminal emulator to "type" the UUID. Doing this manually is quite error prone.

Then save the file (ctrl-X, "y", <return>) and open /media/boot/boot.ini.default:

Code: Select all

nano /media/boot/boot.ini.default
Look for a line like

Code: Select all

#bootrootfs=console=tty1 console=ttySAC2,115200n8 root=UUID=e139ce78-9841-40fe-8823-96a304a09859 rootwait ro fsck.repair=yes net.ifnames=0
Remove the leading '#', replace the old UUID (e139ce78-9841-40fe-8823-96a304a09859) with that of your sda1 partition, and save the file.

In my case, the line is now:

Code: Select all

bootrootfs=console=tty1 console=ttySAC2,115200n8 root=UUID=86d5b640-cd96-49bb-9414-96adcb28eee8 rootwait ro fsck.repair=yes net.ifnames=0
Finally, open the file /etc/fstab

Code: Select all

nano /etc/fstab
and replace again the meanwhile well known UUID e139ce78-9841-40fe-8823-96a304a09859 with that of your sda1 partition.

Now you can reboot the XU4/HC1. Assuming that you did not make any typos, the root file system will now be the partition /dev/sda1. To check, log in as root and invoke df:

Code: Select all

root@odroid:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev              951668       0    951668   0% /dev
tmpfs             204192    8752    195440   5% /run
/dev/sda1      307534288 1100420 290788976   1% /
tmpfs            1020952       0   1020952   0% /dev/shm
tmpfs               5120       0      5120   0% /run/lock
tmpfs            1020952       0   1020952   0% /sys/fs/cgroup
/dev/mmcblk1p1    130798   10404    120394   8% /media/boot
tmpfs             204192       0    204192   0% /run/user/0
The line starting with "/dev/sda1" coonfirms that the root FS is indeed on the HDD/SSD.

Now let's see if boot.ini.default was properly changed. Running apt-get update/upgrade will hopefully install a new version of the bootini package. But let us firstly see what the "modify" time stamps of the files in /media/boot are before the upgrade:

Code: Select all

root@odroid:~# ls -l /media/boot/
total 10404
-rwxr-xr-x 1 root root    9088 Nov  9 17:38 boot.ini
-rwxr-xr-x 1 root root     752 Nov  9 17:40 boot.ini.default
-rwxr-xr-x 1 root root   61525 Aug 24 12:52 exynos5422-odroidxu3-lite.dtb
-rwxr-xr-x 1 root root   62504 Aug 24 12:52 exynos5422-odroidxu3.dtb
-rwxr-xr-x 1 root root   61714 Aug 24 12:52 exynos5422-odroidxu4.dtb
-rwxr-xr-x 1 root root 5577959 Aug 24 12:52 uInitrd
-rwxr-xr-x 1 root root 4871088 Aug 24 12:52 zImage
Now let the XU4/HC1 look for updated packages...

Code: Select all

root@odroid:~# sudo apt-get update
...and let it install these packages:

Code: Select all

root@odroid:~# sudo apt-get upgrade
[lots of the usual messages censored]
During the upgrade, there will be a message that the file /media/boot/boot.ini file was changed. I'm using KDE's terminal emulator, and for some strange reason it did not allow the usual copy&paste of the message, so here is a screenshot:
boot-pkg-update.png
boot-pkg-update.png (17.13 KiB) Viewed 7910 times
Now let's double-check if the files in /media/boot were really changed:

Code: Select all

root@odroid:~# ls -l /media/boot/                                                          
total 10436                                                                                
-rwxr-xr-x 1 root root    9357 Nov  9 17:53 boot.ini                                       
-rwxr-xr-x 1 root root     752 Nov  9 17:40 boot.ini.default                               
-rwxr-xr-x 1 root root    9088 Nov  9 17:53 boot.ini.old                                   
-rwxr-xr-x 1 root root   61381 Nov  9 17:58 exynos5422-odroidxu3-lite.dtb                  
-rwxr-xr-x 1 root root   62360 Nov  9 17:58 exynos5422-odroidxu3.dtb                       
-rwxr-xr-x 1 root root   61714 Nov  9 17:58 exynos5422-odroidxu4-kvm.dtb                   
-rwxr-xr-x 1 root root   61570 Nov  9 17:58 exynos5422-odroidxu4.dtb                       
-rwxr-xr-x 1 root root 5608333 Nov  9 17:58 uInitrd                                        
-rwxr-xr-x 1 root root 4802304 Nov  9 17:58 zImage
A comparison with the old time stamps shows that each file was touched.

During "apt-get upgrade", a newly available kernel version was not installed, so let's do that now:

Code: Select all

root@odroid:~# sudo apt-get install linux-image-xu3
This will lead to a somewhat scary sounding message. Again, only a screenshot:
kernel-update.png
kernel-update.png (28.67 KiB) Viewed 7910 times
It is important to choose "No" – otherwise, the installation is aborted.

Finally, check if the upgrade of the boot files and the installation of the new kernel were successful: Reboot the board. If things went wrong... ummm... didn't happen to me now (but this is not my first time to move the OS from an SD card to an SSD/HDD – some months ago, I had some problems ;). If you have the recommended USB/UART adapter, you'll get a clue what is wrong. Otherwese… well… double-check the contents of boot.ini and boot.ini.default: a possible error is a typo in the new UUID. Remove the SD card from the XU4/HC1 and check the UUIDs on a laptop/PC/other SBC.

If nothing helps: Start over: Copy the OS image to the SD card, insert the card into the XU4/HC1 etc etc.

User avatar
mad_ady
Posts: 6530
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 163 times
Been thanked: 125 times
Contact:

Re: HC1 - OS on hdd?

Unread post by mad_ady » Fri Nov 10, 2017 6:50 am

I think that the linked guide was published before boot.ini.default was implemented. Anyway, solid advice.
One way to test that boot.ini.default works is to reconfigure the bootini package (which will behave like an update):

Code: Select all

$ sudo dpkg-reconfigure bootini

User avatar
odroid
Site Admin
Posts: 32130
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 119 times
Been thanked: 292 times
Contact:

Re: HC1 - OS on hdd?

Unread post by odroid » Fri Nov 10, 2017 9:55 am


adeuring
Posts: 46
Joined: Sun Jul 09, 2017 9:50 pm
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by adeuring » Sat Nov 11, 2017 12:33 am

mad_ady wrote:I think that the linked guide was published before boot.ini.default was implemented. Anyway, solid advice.
Right, the guide was probably written before that file existed. But if someone asks today if the root FS can be put onto a disk and this file isn't mentioned, this person is sooner or later led into a failing boot. (Unless they carefully read and understand the warning during the upgrade of the bootini package.)

@odroid, I think the wiki page you mentioned should describe the boot.ini.default too.
One way to test that boot.ini.default works is to reconfigure the bootini package (which will behave like an update):

Code: Select all

$ sudo dpkg-reconfigure bootini
Right – problem is that I repeatedly forget to remember dpkg-reconfigure ;)

mintz
Posts: 27
Joined: Wed Feb 27, 2013 7:19 pm
languages_spoken: english
ODROIDs: ODROID U2
Has thanked: 0
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by mintz » Tue Nov 21, 2017 5:56 am

Thanks guys. I followed all the instructions and advices and it worked out perfectly.
Now that / is relocated to my SSD partition /dev/sda1. Is it safe to empty the old root partition from the SD-card (mmcblk1p2 rootfs) and use it as some extra (slower) storage?

User avatar
mad_ady
Posts: 6530
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 163 times
Been thanked: 125 times
Contact:

Re: HC1 - OS on hdd?

Unread post by mad_ady » Tue Nov 21, 2017 4:47 pm

Sure. Go ahead. Keep only the vfat partition untouched.

eelzter
Posts: 1
Joined: Thu Sep 07, 2017 12:34 am
languages_spoken: english, swedish, japanese
ODROIDs: hc1
Has thanked: 0
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by eelzter » Sat Jul 14, 2018 1:26 am

Hej adeuring! Thank you for a really nice guide how to install OS on the SATA drive!

I was following it and it worked like a charm, however after reboot I noticed my file system was not what I expected. I checked /etc/fstab and was met with the old version!

Then it downed on me; I updated /etc/fstab on the SD-card NOT on the newly created HDD-file system, pretty obvious mistake :roll:

But I think it would be a good idea to add a note in your guide that when editing /etc/fstab it should be the one on your new HDD, not your old SD-card!

dinge
Posts: 2
Joined: Wed Sep 11, 2019 10:01 pm
languages_spoken: english
ODROIDs: HC2
Has thanked: 1 time
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by dinge » Wed Sep 11, 2019 10:04 pm

adeuring wrote:
Fri Nov 10, 2017 5:34 am
Great guide adeuring! This helped me a lot!

I have one question, I used a Odroid HC2 with a 4TB drive but it only shows 2TB.
What is the best way to partition the drive to 4TB and in which step of your guide should I do this?

Thank you in advance!

InsideOut
Posts: 2
Joined: Sun May 13, 2018 4:02 pm
languages_spoken: english
ODROIDs: HC2
Has thanked: 0
Been thanked: 1 time
Contact:

Re: HC1 - OS on hdd?

Unread post by InsideOut » Thu Sep 12, 2019 9:24 pm

dinge wrote:
Wed Sep 11, 2019 10:04 pm

Great guide adeuring! This helped me a lot!

I have one question, I used a Odroid HC2 with a 4TB drive but it only shows 2TB.
What is the best way to partition the drive to 4TB and in which step of your guide should I do this?

Thank you in advance!
I have the same configuration as yours, except I have 1, 4TB partition. My partition table is GPT.

dinge
Posts: 2
Joined: Wed Sep 11, 2019 10:01 pm
languages_spoken: english
ODROIDs: HC2
Has thanked: 1 time
Been thanked: 0
Contact:

Re: HC1 - OS on hdd?

Unread post by dinge » Thu Sep 12, 2019 9:38 pm

InsideOut wrote:
Thu Sep 12, 2019 9:24 pm
dinge wrote:
Wed Sep 11, 2019 10:04 pm

Great guide adeuring! This helped me a lot!

I have one question, I used a Odroid HC2 with a 4TB drive but it only shows 2TB.
What is the best way to partition the drive to 4TB and in which step of your guide should I do this?

Thank you in advance!
I have the same configuration as yours, except I have 1, 4TB partition. My partition table is GPT.
So you also didn't have found a solution yet?

InsideOut
Posts: 2
Joined: Sun May 13, 2018 4:02 pm
languages_spoken: english
ODROIDs: HC2
Has thanked: 0
Been thanked: 1 time
Contact:

Re: HC1 - OS on hdd?

Unread post by InsideOut » Fri Sep 13, 2019 8:21 pm

dinge wrote:
Thu Sep 12, 2019 9:38 pm

So you also didn't have found a solution yet?
Refer to my last post I have 1, 4TB partition on a 4TB hard disk.

Code: Select all

root@hc2-1:/home/peter# fdisk /dev/sda

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sda: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: FD5C49BF-02F8-4493-9A5A-FFCB5FA26A85

Device     Start        End    Sectors  Size Type
/dev/sda1   2048 7814035455 7814033408  3.7T Linux filesystem
These users thanked the author InsideOut for the post:
dinge (Fri Sep 13, 2019 10:41 pm)

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 3 guests