You are not logged in.

#1 2021-04-12 18:33:31

pierric
Member
Registered: 2021-04-12
Posts: 11

installing Arch to a USB key - kernel not able to mount filesystem

Hi,

I'm new to Arch, having used mostly Debian-based Linux systems in the past (and not an expert even on those), and I've installed an Arch system on a VirtualBox machine on my computer currently running Windows. All fine until there.

Then I thought, wouldn't it be nice if I could have a lightweight Arch system on a USB key (in fact a microSD card inside an adapter), that I could boot into from both my desktop and my laptop (hoping the laptop's hardware is supported enough...)? Also, using BTRFS, because this is new to me and I get excited easily. And so I tried. But it proved much more difficult than I thought.

I followed the ArchWiki guidelines to get a system running on a USB key, using both BIOS and EFI partitions (I'm happy to focus on EFI only from now on), and GRUB, but ran into issues. I've solved the first ones, but maybe they can reveal what I did wrong in the first place. So here's roughly what happened:
- first time I booted it, I got dropped into a GRUB shell, with no menu. On the plus side, the EFI booting seems to work. I realized there was no menu entry despite running grub-mkconfig after grub-install because there was no kernel image in my /boot folder. I'm not sure why, but this was fixed by using pacman -Syu linux from the arch-chrooted USB (I had started the install with pacstrap, so expected a kernel to be there).
- then, grub-mkconfig was able to generate a menu. It was quite wrong though, in that it was referring to hard drives as they are in my virtual machine, and it's not the same when I boot the USB key from the physical machine. I was getting kernel panic errors due to it not being able to mount. No big deal, I looked at what I had in grub when booting, and updated the menu entries correspondingly: (hd1,gpt4) became (hd0,gpt4).
- still no luck though. I realized the kernel options referred to root=/dev/sdb4 -- I thought, again,  this might actually be /dev/sda4 or something else when booting, so I'll use a UUID. I found out the early stage kernel does not support filesystem UUID, so I used a PARTUUID (I didn't do that for the part that says "search" because it seems to be explicitly set up to search for an FS UUID, so I assume it's safe to leave it -- grub IS able to see those)
- at this stage this is my menu entry in grub

menuentry 'Arch Linux' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-7c8b813a-2328-4736-ada3-c7bc6de07529' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod btrfs
	set root='hd0,gpt4'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4  7c8b813a-2328-4736-ada3-c7bc6de07529
	else
	  search --no-floppy --fs-uuid --set=root 7c8b813a-2328-4736-ada3-c7bc6de07529
	fi
	echo	'Loading Linux linux ...'
	linux	/root/boot/vmlinuz-linux root=PARTUUID=794df4f7-6989-4d98-b39e-ba10b51c3ccb rw rootflags=subvol=root  loglevel=5
}

- and at this stage, I was still getting the error

VFS: Unable to mount root fs unknown-block (0,0)

Note that earlier, when the disk reference was wrong, it was picking some other values than 0,0; it switched to 0,0 when I fixed the above (either when starting to used hd0, or maybe only after the UUID thing, I'm not sure)

- I realized that I don't have an initrd/initramfs (and despite trying to read the wiki about these things I'm still confused about it, though I do understand the one I need is probably the thing that allows mounting some hardware early enough for the root filesystem to then be mounted). So I pacman -Syu initramfs , and I choose booster, because I've read it's lightweight and fast and I'm easy to impress. Repeating some steps (I suppose it was reinstalling grub), there's a booster-linux.img file there. Or maybe it was there all the time but just not included in the grub menu, I'm not sure. Either way, I add the line initrd /root/boot/booster-linux.img to the menu entry. Now when I boot I see this (OCR'd from a photo):

0.110678] x86/cpu: SGX disabled by BIOS
0.118513) prd_set_huge: Cannot satisfy [mem Oxe0000000-0xe02000001 with a huge-page mapping due to MTRR override.
0.7988201 ata1.00: supports DRM functions and may not be fully accessible
0.8092251 ata1.00: supports DRM functions and may not be fully accessible

and nothing else, though loglevel is 5. I have no idea if what I attempted with the initrd/booster thing is completely wrong, or just missing some extra touch.

At this point I don't know how to continue, as I'm in way over my head, with my nonexistent knowledge of the kernel and the booting process (though it was interesting until this point despite the failure). Rather than giving up and defaulting to a ready-made Linux-on-a-USB ready-made solution, I'd love it if someone could unblock me and allow me to continue on my quest for a portable, lightweight, entirely customized Arch Linux!

I realize I haven't provided lots of details, but I'm not sure which ones to add, so feel free to ask me!

Many thanks in advance!
Pierric.

Offline

#2 2021-04-13 00:50:27

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 696

Re: installing Arch to a USB key - kernel not able to mount filesystem

From my own experience on installing into an USB key.

1- Always use a fallback image, aka: remove autodetect and don't bother creating a fallback image since the default one is complete.
2- Don't depend on autogeneration for the bootloader, either write it manually to make it independent on the state of the hardware or use a more simpler bootloader that only cares about a config file and local files. syslinux and systemd-boot for BIOS/UEFI respectively like archiso is a smart choice

You'll need 2 and just in case make sure you are taking care of 1.

You can definitely use GRUB for both BIOS and UEFI, I have done it once, but you'll need to do the grub.cfg by hand to make it failsafe.

...

Note that I'm not the best at this, I may not be 100% right.


My reposSome snippets

Heisenberg might have been here.

Offline

#3 2021-04-13 02:14:54

jonno2002
Member
Registered: 2016-11-21
Posts: 684

Re: installing Arch to a USB key - kernel not able to mount filesystem

its no different to installing to a hdd/ssd , just follow the installation guide and treat the usb stick as a hdd/ssd and when it comes time to install grub just use the "--removable" flag.

i just did it quickly and here is a rough outline of how it goes:

plugged usb stick into my arch machine and ran:

cfdisk -z /dev/sdd

made 3 partitions:

/dev/sdd1 UEFI (50mb)
/dev/sdd2 SWAP (8gb)
/dev/sdd3 LINUX FILESYSTEM (20gb)

then did the following:

mkfs.fat -F 32 /dev/sdd1
mkswap /dev/sdd2
mkfs.ext4 /dev/sdd3
mount /dev/sdd3 /mnt
mkdir -p /mnt/boot/efi
mount /dev/sdd1 /mnt/boot/efi/
pacstrap /mnt base linux linux-firmware vim
genfstab -U /mnt >> /mnt/etc/fstab 
nvim /mnt/etc/fstab (corrected UUID for swap partiton, was set to my system swap instead of the usb swap)
arch-chroot /mnt

ln -sf /usr/share/zoneinfo/Foo/Bar /etc/localtime
hwclock --systohc
vim /etc/locale.gen 
locale-gen 
vim /etc/locale.conf
vim /etc/hostname
vim /etc/hosts
mkinitcpio -P
passwd
pacman -S grub
grub-install --target=x86_64-efi --efi-directory=/boot/efi --removable
grub-mkconfig -o /boot/grub/grub.cfg
reboot

and it works perfect, easy as that

Offline

#4 2021-04-13 08:00:30

pierric
Member
Registered: 2021-04-12
Posts: 11

Re: installing Arch to a USB key - kernel not able to mount filesystem

Hi, and thanks for your reply.

I believe what I did is similar (except for choosing btrfs over ext4 just because), with one exception: I didn't use mkinitcpio because the installation guide says
Creating a new initramfs is usually not required, because mkinitcpio was run on installation of the kernel package with pacstrap.

That said, something must have gone wrong before that since I had apparently no kernel installed (at least not in /boot).

I'd love to debug the situation I'm in and fix it, but it might be simpler to start from scratch, so I might do that soon...

Cheers
Pierric.

Offline

#5 2021-04-13 17:31:15

Roken
Member
From: South Wales, UK
Registered: 2012-01-16
Posts: 1,251

Re: installing Arch to a USB key - kernel not able to mount filesystem

Not to a USB key, but I have an NvME drive in an external USB enclosure designed to be portable, and for the most reliable portable setup I've noted a couple of things:

GRUB is not ideal - and will fail on some systems. Use syslinux, instead.
You need to reconfigure /etc/mkinitcpio.conf to move 'block' and 'keyboard' hooks before 'autodetect'.

You can do the basic install via virtualbox by passing the physical drive/USB to the VM (https://superuser.com/questions/495025/use-physical-harddisk-in-virtual-box has a decent walk through for this), which will isolate that drive and prevent accidentally over writing any other drives. It will aslo write the drive for real, rather than a drive image. Follow the Arch Wiki to install (don't even think about the new install script - do it properly). Once you have a system booting in the VM, you should be able to boot the same system for real by selecting the drive at BIOS as boot, and continue to install how you want to your heart's content.

Last edited by Roken (2021-04-13 17:32:27)


Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus Prime B450 Plus, 32Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (1 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703

Offline

#6 2021-04-13 17:37:26

pierric
Member
Registered: 2021-04-12
Posts: 11

Re: installing Arch to a USB key - kernel not able to mount filesystem

Hi !

And sorry Gaky999, I had missed your reply! That said it seems systemd-boot doesn't support btrfs so for now I'll stick with grub.
I've restarted the process, following again the steps as described by jonno2002, except for creating the fs as btrfs and updating the hd1 values to hd0 in the grub config. The mkinitcpio definitely did something, as I know have a regular and a fallback initramfs.
However now I get a new variation of disk not found, both when leaving grub's UUID-based parameters for the kernel and when replacing that with PARTUUID. Here's what I see now:

mount: /new_root: can't find PARTUUID=xxxxx (copying this manually this time so skipping the actual id!)
You are now being dropped into an emergency shell.
sh: can't access tty: job control turned off.
[rootfs ]#

And there I can't do a thing because my keyboard doesn't even turn on (num lock light is off even if I hit num lock)

Any hints? when installing linux-firmware I got warnings that some firmware could be missing. Could it be linked?

Thanks,
Pierric.

Offline

#7 2021-04-13 17:49:59

pierric
Member
Registered: 2021-04-12
Posts: 11

Re: installing Arch to a USB key - kernel not able to mount filesystem

Thank you Roken, I will look into your inputs -- trying the mkinitcpio stuff first while still working on the current setup, and short of success there I might try to use the USB key as a VM's main drive (rather than passing the USB key as a USB key to the VM I'm installing from.

Offline

#8 2021-04-13 17:55:19

Roken
Member
From: South Wales, UK
Registered: 2012-01-16
Posts: 1,251

Re: installing Arch to a USB key - kernel not able to mount filesystem

Not a problem. I had to re-familiarise myself with the process only last week, after migrating my portable Arch to the NvME. Copying the old drive failed, but there were some issues with the install anyway, so figured I'd just do a clean install.

The way I described works as a portable install which should boot on any PC/Laptop capable of USB boot. For extra added value, you can install amd-ucode and intel-ucode.

For info, the mkinitcpio changes ensure that you can find the boot drive and that your keyboard will work. Without them. you can get exactly the symptoms in your original post (related to the 'block' hook).


Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus Prime B450 Plus, 32Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (1 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703

Offline

#9 2021-04-15 07:35:55

pierric
Member
Registered: 2021-04-12
Posts: 11

Re: installing Arch to a USB key - kernel not able to mount filesystem

Hi,

Just to mention that the mkinitcpio.conf trick now did, as explained by Roken. Instead of moving autodetect, I removed it altogether (seeing the comments in the file that suggested it might be best to do that for a USB install). I was then able to boot and log in!

Thanks again for the help.
Pierric.

Offline

Board footer

Powered by FluxBB