LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-24-2024, 09:32 PM   #1
sylphyk
LQ Newbie
 
Registered: Mar 2024
Posts: 3

Rep: Reputation: 0
Multiple-architecture support on a bootable USB storage device.


Hello everyone, it's my first post here, just looking for some advice on setting up an external storage device for two different projects. I believe this thread applies to the Hardware section, but if I'm wrong, feel free to remove. I've copied this text to a file and can repost in the correct section if needed.

For context: found my old Raspberry Pi 2 model B and decided I wanted to get it up and running again. Ordered an SD card for it. SD card shipped then I went out of town for work and I decided on a whim to compile Gentoo on my laptop as I don't have the Pi, but I do have the SD card so I will be booting from that. (Tested and I can boot from it with a LiveCD using my USB card reader, hell it boots a graphical LiveCD faster than Windows on my built in SSD, and leagues faster than the flash drive im about to talk about. Wicked fast SD card, Amazon link not affiliatedhttps://a.co/d/hy6f46e)
Actually, right now, I'm booting systemrescuecd from an old 16gb flash drive and using that to set up my system. I'd prefer to figure it out myself with the minimal install image, but my only Internet connection is Wifi so I have to use that. But for now I plan to build Gentoo on that SD card.

My end goal is to have an SD card I can boot Gentoo on my laptop, or take it out and plug it into my Raspberry Pi and boot into a compatible OS.

I expect a few roadblocks:
The Raspberry Pi's processor (at least for the model I own) locks down the booting process, in short it is basically hard-coded to look for a certain file to boot from. Therefore, a bootloader like Grub is out of the question. However, multi booting is still possible.
My model of Raspberry Pi only supports MBR partition tables, it's not until the Raspberry Pi 4 that they begin to support GUID partition tables. Therefore, my partition scheme is very limited. Also, in regards to the above point, the Pi requires a fat32 filesystem. Not a problem but something worth mentioning.
My Raspberry Pi has an ARM Cortex A7 processor (armv7 architecture), whereas my laptop has an amd64 AMD Ryzen 7 processor. I theorize that due to the above points, if I have those boot files in its own fat32 partition I shouldn't have any issues booting from it.
The Raspberry Pi's various OSs are almost always flashed directly to the SD card from an .img file. Therefore, I need to be able to "flash" without disrupting my Gentoo partitions, or at least figure out how to manually copy the files.

Due to my personal preference in partitioning for Gentoo (separate partitions for boot, root, home, and swap) and due to MBR limit of 4 primary partitions, this doesn't seem to be immediately possible. I believe the raspberry pi only requires a single partition due to the media being flashed to the SD card, but I could be wrong, it might write its own partition table. If not, I'm sure I can figure out how to share the home and swap partitions.
I have a few options and ideas, though.
1. Just compromise and set up only 3 partitions for Gentoo by having one partition for root and home.
2. Idea: Figure out how to have one physical device interpreted by the computer as two separate devices i.e. /dev/sdb and /dev/sdc point to two different partition tables on the *same physical device*. I think this might be possible. You can treat two physical devices as one device (ex: /dev/sdb is two devices). You can set up a hybrid partition table. Surely this is possible.
3. Idea: Set up a hybrid partition table. I don't fully understand this concept yet, but I don't want to try it as it's supposedly "flaky" (as per the warning in the program gdisk), and by the looks of it in my limited amount of research it's just a "mask" allowing MBR-only operating systems to see GPT-labelled partitions -- doesn't sound like what I want to do, but technically it might apply as the Pi board is MBR only (note that I say board here and OS previously, this discrepancy might be important if i try to navigate this path).
4. Idea: flash the SD card with the Pi OS first, then create and format 3 partitions for Gentoo to use, then continue working on my laptop. I've got a feeling this will be the answer, but unfortunately I am still out of town without my Pi.
5. Give up on this concept, finish setting up Gentoo, and when I get an external SSD I will clone the SD card and then start on my Pi project.

If I can set up this SD card to be bootable on both my Raspberry Pi and my laptop, I now have a portable development environment. My goal is to set it up so that I can multiboot the Pi (with multiple OSs for the Pi), have a custom LiveCD so that I can plug into any modern computer, and also have my full Gentoo environment specifically for my laptop.

I guess I don't have much of a single question, but I do want to know if something like this is within the realm of possibility. I think if I were to ask a question, it would be, is it possible to create a multi-bootable USB drive with OSs supporting different processor architectures? Not specific to the Raspberry Pi, but it is relevant as I am limited by it. Also will take full advantage of my ability to document what I'm doing here. I will be updating this with replies to this top post throughout the week with my findings, and I look forward to hearing your ideas and input!

Last edited by sylphyk; 03-24-2024 at 10:23 PM. Reason: Clarification of the question
 
Old 03-25-2024, 12:38 AM   #2
sylphyk
LQ Newbie
 
Registered: Mar 2024
Posts: 3

Original Poster
Rep: Reputation: 0
Update, I've done a bit more research and this is what I'm going to do on Wednesday when I get back home.

I'm going to continue working on Gentoo over the next few days and will make an attempt to manually set up an OS installation for the Pi to make sure this is doable. All the automated solutions for Pi OS installation do is flash an image to an SD card. I just have to understand this and manually set up partitions and move files and it should work the same.
I will extract the contents of an .img or find a zip file. Both are available, I believe I've done this before because I remember Tiny Core Linux for the Pi came as a zip file.
Format a 32gb partition of the SD card to fat32. Format the rest according to my preferences for Gentoo:
sda1: swap
sda2: root ext4
-- free space, equal to the size of sda3 --
sda3: home ext4
sda4: rpi 32gb fat32
I believe the Pi should be able to see other formatted partitions other than the fat32, so I should be able to share the home partition with the Pi's partition. In foresight of what I'm going to explain next, I am going to plan to keep the Pi's own home folder and just mount the laptop's home partition in an easily accessible folder.
The reason for the free space is so that if in the future I decide to add another partition for another OS (for my Live CD, perhaps), I can grow the root partition to fit all of the possiable contents of /home, then resize to fill all space except what I need for the other OS.
It's a 256gb SD card, and I don't plan to store a whole lot on it other than operating system files with some space for persistence. I would eventually get an external SSD for other file storage. I need one for gaming, anyways, the laptop's SSD is only 512gb, doesn't leave room for more than 1 triple-A game because I've also got all of my creative work on there.
Really trying to get organized as I'm trying to rekindle my love for computer science and possibly pursue it as a new career path. I can't stand programming and development in modern Windows and I want to get this purpose-built creative work environment set up so that I can focus when it's time to focus. My goal is streamlined versatility ;D
 
Old 03-25-2024, 08:19 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,710

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
You only need two partitions for the Pi i.e. /boot which is FAT usually the first partition and /(root) which is a linux filesystem like ext4. With a MBR drive you can have more then four partitions using an extended partition. The Pi's GPU is the first stage bootloader which then loads bootcode.bin and start.elf. I don't believe the MBR boot section is used so in theory you could install grub. There is no reason (as far as I know) the x86 boot files can not be in the same partition. While this is an interesting project I would be reluctant to constantly switch in/out the sdcard and flash memory does have limited number of writes.

A possible better idea would be to use a USB drive, you would need separate partition for /root maybe /home and a shared development environment between the two operating systems and the Pi's /boot would still be on the sdcard. You do need a powered hub.
 
Old 03-25-2024, 11:16 PM   #4
sylphyk
LQ Newbie
 
Registered: Mar 2024
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you for the input, Michael, that's very enlightening. I just posted a question about that in the official Pi forums (as my question here is not necessarily about the Pi).

I was afraid I needed more partitions for the Pi, and I really wanted to avoid using extended partitions -- but if I must, I guess it won't hurt considering the 4th primary partition is the one I dedicated to the Pi, I will just split it into two extended partitions.

I don't really *need* persistence, but for the time being until I really get this setup going I will allow for it. Eventually I'd want a read-only set of systems on this SD card and rely on the storage space on whatever host machine I plug it into.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
confused over terminology of internal storage and SD card storage - howto encrypt the 128GB of internal storage lgtrean Linux - Mobile 3 12-27-2021 01:27 AM
confused over terminology of internal storage and SD card storage - howto encrypt the 128GB of internal storage (2nd try) lgtrean Linux - Mobile 1 12-24-2021 12:45 PM
what is 'architecture' in 'binary for an architecture'?multiple architecture support? wagaboy Linux - Newbie 2 07-10-2010 11:18 AM
USB drive not working properly, read only device? (USB key storage device) Arodef Linux - Hardware 14 01-01-2010 07:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 01:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration