View previous topic :: View next topic |
Author |
Message |
kimux n00b
Joined: 25 Mar 2013 Posts: 17
|
Posted: Sun Dec 29, 2019 2:02 am Post subject: zfs on linux. System failed to boot |
|
|
My English is not good. The following content is translated through Google. If it looks strange, I can only say sorry.
I had difficulty installing Gentoo using ZFS file system. System failed to boot. I don't know what I did wrong or missed. Can someone help me?
Select start genoo from grub menu
Information displayed on the screen:
Code: | >> Genkernel 4.0.9
>> Activating mdev ...
>> Loading modules
:: Loading from virtio:
:: Loading from hyperv:
:: Loading from nvme:
:: Loading from sata:
:: Loading from scsi:
:: Loading from pata:
:: Loading from usb:
:: Loading from firewire:
:: Loading from waitscan:
:: Loading from lvm:
:: Loading from dmraid:
:: Loading from fs:
:: Loading from crypto:
>> Importing ZFS pool rpool ...
!! rpool/ROOT/gentoo is not a filesystem
!! rpool/ROOT/gentoo is not a filesystem
Very multi-line
.....
!! Block device ZFS=rpool/ROOT/gentoo is not a valid root device ...
!! Could not find the root block device in ZFS=rpool/ROOT/gentoo.
!! Please specify another value or:
!! - press Enter for the same
!! - type "shell" for a shell
!! - type "q" to skip ...
root block device(ZFS=rpool/ROOT/gentoo) ::
|
Liveusb for Ubuntu 19.10 using rufus
I have two hard drives.The first hard disk has win10 installed. It has an ESP partition, so I didn't assign an ESP partition to the second hard disk,
and then delete all the partitions of the whole hard disk
Code: | parted /dev/sdb
(parted)mklabel gpt
(parted)p
Model: ATA ST3250310AS (scsi)
Disk /dev/sdb: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
(parted)q |
Then I created a ZFS pool on the whole hard disk
Code: | zpool create -f -d -o ashift=12 -o cachefile=/tmp/zpool.cache -O normalization=formD -O atime=off -O xattr=sa -m none -R /mnt/gentoo rpool /dev/disk/by-id/ata-ST3250310AS_6RY3HCB1 |
I feel strange: the hard disk is automatically divided into two partitions. The first partition is /dev/sdb1, which uses all the space in front. The second partition is /dev/sdb9, which has only 8m space
But I didn't care. I think it might be the result of ZFS automatic management
Code: | zfs create -o mountpoint=none -o canmount=off rpool/ROOT
zfs create -o mountpoint=/ rpool/ROOT/gentoo
zfs create -o mountpoint=/home rpool/HOME
zfs create -o mountpoint=none -o canmount=off rpool/GENTOO
zfs create -o sync=disabled -o mountpoint=/var/cache/distfiles rpool/GENTOO/distfiles
zfs create -V 4G -b $(getconf PAGESIZE) -o logbias=throughput -o sync=always -o primarycache=metadata -o com.sun:auto-snapshot=false rpool/swap
mkswap -f /dev/zvol/rpool/swap
swapon /dev/zvol/rpool/swap |
Then Code: | zpool set bootfs=rpool/ROOT/gentoo rpool |
Code: | zpool status
pool: rpool
state: ONLINE
status: Some supported features are not enabled on the pool. The pool can
still be used, but some features are unavailable.
action: Enable all features using 'zpool upgrade'. Once this is done,
the pool may no longer be accessible by software that does not support
the features. See zpool-features(5) for details.
scan: none requested
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
ata-ST3250310AS_6RY3HCB1 ONLINE 0 0 0
errors: No known data errors |
Code: | zfs list
NAME USED AVAIL REFER MOUNTPOINT
rpool 4.25G 220G 176K none
rpool/GENTOO 352K 220G 176K none
rpool/GENTOO/distfiles 176K 220G 176K /mnt/gentoo/var/cache/distfiles
rpool/HOME 176K 220G 176K /mnt/gentoo/home
rpool/ROOT 392K 220G 176K none
rpool/ROOT/gentoo 216K 220G 216K /mnt/gentoo
rpool/swap 4.25G 225G 108K - |
Then start to install Gentoo. Everything is OK
This is my kernel .config file,I don't think it's a kernel problem, because this kernel can start the system normally on the ext4.
https://github.com/kimuxer/kernelconfig/blob/master/config
The only difference is that install into the kernel directory (for static installations) in https://wiki.gentoo.org/wiki/zfs
Code: | env EXTRA_ECONF='--with-spl=/usr/src/linux --enable-linux-builtin --with-spl-obj=/usr/src/linux' ebuild /var/db/repos/gentoo/sys-fs/zfs-kmod/zfs-kmod-0.8.2.ebuild clean configure
root #(cd /var/tmp/portage/sys-fs/zfs-kmod-0.8.2/work/zfs-kmod-0.8.2/ && ./copy-builtin /usr/src/linux) |
According to ZOL wiki, ZFS kmod 0.8 contains SPL, so I didn't use it in the above build [--with-spl=/usr/src/linux --with-spl-obj=/usr/src/linux]
I've also tried not to use static installation, but the result is the same and I can't boot
Use genkernel to create an initramfs
Code: | hostid > /etc/hostid
genkernel initramfs --no-clean --no-mountboot --makeopts=-j9 --kernel-config=/usr/src/linux/.config --zfs
/etc/default/grub
GRUB_CMDLINE_LINUX="dozfs real_root=ZFS=rpool/ROOT/gentoo" |
fstab
Code: | UUID=XXXX-XXXX /boot/EFI vfat noauto,defaults,noatime 1 2
/dev/zvol/rpool/swap none swap defaults 0 0 |
Code: | rc-update add zfs-import sysinit
rc-update add zfs-mount sysinit |
Code: | grep 'insmod zfs' /boot/grub/grub.cfg
insmod zfs
ls /boot/grub/*/zfs.mod
/boot/grub/x86_64-efi/zfs.mod |
/boot/grub/grub.cfg
Code: |
grub-mkconfig -o /boot/grub/grub.cfg
menuentry "Gentoo" {
linux /ROOT/gentoo@/boot/vmlinuz root=ZFS=rpool/ROOT/gentoo ro dozfs real_root=ZFS=rpool/ROOT/gentoo
initrd /ROOT/gentoo@/boot/initramfs.img
} |
I tried to change the parameters(All kinds of combinations have tried...)
Code: | linux /ROOT/gentoo/@/boot/vmlinuz root=ZFS=rpool/ROOT/gentoo ro dozfs real_root=ZFS=rpool/ROOT/gentoo
linux /ROOT/gentoo@/boot/vmlinuz root=ZFS=rpool/ROOT/gentoo ro
linux /ROOT/gentoo@/boot/vmlinuz root=rpool/ROOT/gentoo ro dozfs real_root=ZFS=rpool/ROOT/gentoo
|
Last edited by kimux on Tue Dec 31, 2019 4:03 am; edited 1 time in total |
|
Back to top |
|
|
kimux n00b
Joined: 25 Mar 2013 Posts: 17
|
Posted: Sun Dec 29, 2019 3:41 am Post subject: |
|
|
https://github.com/szorfein/Gentoo-ZFS/wiki/7.kernel
I see a sentence at the bottom of this page
It's important to keep the same version than archlinux for the install else grub will not recognize the filesystem.
The ZFS version of Ubuntu 19.10 is 0.8.1
And I installed version 0.8.2
Is that the reason? |
|
Back to top |
|
|
12101111 n00b
Joined: 01 Nov 2019 Posts: 2
|
Posted: Tue Dec 31, 2019 5:37 am Post subject: |
|
|
genkernel don't works for me either. (ZFS 0.8.2, Linux5.4)
I use a simple script in initramfs instead.
Code: |
#!/bin/sh
rescue_shell() {
echo "Something went wrong: $1. Dropping to a shell."
busybox --install -s
exec ash
}
mkdir -p dev/pts proc run sys
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devtmpfs devtmpfs /dev
echo 0 > /proc/sys/kernel/printk
echo "Import ZFS pool"
export ZPOOL_IMPORT_UDEV_TIMEOUT_MS=0
zpool import -Naf
echo "Mount data/gentoo/* dataset"
mount.zfs data/gentoo /mnt/root || rescue_shell "Failed to mount data/gentoo"
mount.zfs data/gentoo/usr /mnt/root/usr || rescue_shell "Failed to mount data/gentoo/usr"
mount.zfs data/gentoo/var /mnt/root/var || rescue_shell "Failed to mount data/gentoo/var"
mount.zfs data/gentoo/var/cache /mnt/root/var/cache || rescue_shell "Failed to mount data/gentoo/var/cache"
echo "Clean up"
umount /sys
umount /proc
echo "Switch root and execute init"
exec switch_root /mnt/root /sbin/init
rescue_shell "Failed to run /sbin/init"
|
I use legacy mountpoint here because this zfs pool also contains a FreeBSD install.
It works except openrc don't show anything and drop me to login screen directly.
All files in initramfs
Code: |
.
├── bin
│ ├── busybox
│ └── sh -> busybox
├── dev
│ ├── console
│ ├── null
│ ├── tty
│ ├── tty0
│ ├── tty1
│ └── zero
├── etc
├── init
├── lib
│ ├── ld-musl-x86_64.so.1
│ ├── libblkid.so.1
│ ├── libcrypto.so.1.1
│ ├── libnvpair.so.1
│ ├── libssl.so.1.1
│ ├── libtirpc.so.3
│ ├── libudev.so.1
│ ├── libuuid.so.1
│ ├── libuutil.so.1
│ ├── libz.so.1
│ ├── libzfs.so.2
│ ├── libzfs_core.so.1
│ └── libzpool.so.2
├── linuxrc -> /bin/busybox
├── mnt
│ └── root
├── proc
├── root
├── sbin
│ ├── blkid
│ ├── fsck.zfs
│ ├── mount.zfs
│ ├── zdb
│ ├── zfs
│ └── zpool
├── sys
├── tmp
└── var
|
|
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54300 Location: 56N 3W
|
Posted: Tue Dec 31, 2019 9:43 am Post subject: |
|
|
12101111,
If your initrd fails, it drops you into the busybox shell.
Do the contents of /dev /proc and /sys look OK?
Hmm, you don't set a PATH in your initrd, so how does the script know that
Code: | mkdir -p dev/pts proc run sys | actually means Code: | /bin/busybox mkdir ... |
Likewise all your other commands as they are not in /
Either set a PATH or use /full/path/to_command everywhere in the init script. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
kimux n00b
Joined: 25 Mar 2013 Posts: 17
|
Posted: Tue Dec 31, 2019 11:53 am Post subject: |
|
|
Today, I compile the kernel completely using genkernel and generate initramfs.
Code: | genkernel kernel --no-mountboot |
Code: | echo 'sys-fs/zfs-kmod ~amd64' > /etc/portage/package.accept_keywords/zfs
echo 'sys-fs/zfs ~amd64' >> /etc/portage/package.accept_keywords/zfs
emerge zfs |
Code: | genkernel all --no-mountboot --zfs --bootloader=grub2 --callback="emerge @module-rebuild" |
After half an hour.. the compilation is finished. At the end, it automatically reemerges zfs-kmod
Then run grub-mkconfig
reboot
Succeed
I use this initramfs to guide my manually compiled kernel. Unable to boot again . So there must be something wrong with my kernel.
I may have removed some important things when configuring the kernel
I'm going to try configuring only device drivers |
|
Back to top |
|
|
Whissi Retired Dev
Joined: 12 Jan 2011 Posts: 222
|
Posted: Tue Dec 31, 2019 5:37 pm Post subject: |
|
|
FYI: You don't need Code: | --callback="emerge @module-rebuild" | with genkernel-4 anymore. There's an own command-line parameter for that (enabled by default). _________________ Regards,
Whissi |
|
Back to top |
|
|
kimux n00b
Joined: 25 Mar 2013 Posts: 17
|
Posted: Thu Jan 02, 2020 3:23 am Post subject: |
|
|
Thank you for yours reply
The problem is not that it can't be started
I'm trying to make my built kernel and initramfs bootable instead of using the kernel generated by genkernel
The kernel compiled automatically by genkernel has 1800 + modules... Too many. I can't stand it
I want to use Ubuntu 19.10 or calculate Linux's config to compile a bootable kernel first, and then slowly reduce it
I hope it's worth it.It's a big project for me |
|
Back to top |
|
|
jfp Guru
Joined: 08 Jul 2007 Posts: 326 Location: Virginia, USA
|
Posted: Thu Jan 02, 2020 2:32 pm Post subject: |
|
|
If you use genkernel with all defaults, it will supply a kernel config that has many modules. Remember that genkernel, by default, builds a kernel that could be booted on many different computers. However, you can prevent genkernel from doing that. It just takes some updates to the genkernel configuration file.
The genkernel configuration file is: /etc/genkernel.conf
The two items in genkernel.conf that you need to change are:
MRPROPER="no" # the default is yes and causes genkernel to run "make mrproper" This is the real culprit because mrproper deletes /usr/src/linux/.config
CLEAN="no" # The default is "yes" and cause genkernel to run "make clean". make clean is not a problem, but I prefer to make my own decision on whether to run it
For details on what these two items do:
Code: | cd /usr/src/linux && make help |
Plus, since you are using a rootfs on zfs, you would want to set this option as well:
ZFS="yes"
Once you update /etc/genkernel.conf, you can now configure you own /usr/src/linux/.config without genkernel overwriting it with "it's" .config
The sequence like this is now possible and you can start getting rid of modules that you don't need or want.
Please note the genkernel messages about .config below.
Code: | NAShost /usr/src/linux # make xconfig
<removed a bunch of warnings and other useless messages from make xconfig that don't matter>
#
# configuration written to .config
#
NAShost /usr/src/linux # genkernel all
* Gentoo Linux Genkernel; Version 4.0.1
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: all
* Working with Linux kernel 4.19.91-gentoo-x86_64 for x86_64
* Using kernel config file '/etc/kernels/kernel-config-4.19.91-gentoo-x86_64' ...
*
* Note: The version above is subject to change (depends on config and status of kernel sources).
* kernel: >> Initializing ...
* >> --no-clean is set; Skipping 'make clean' ...
* >> --no-mrproper is set; Skipping 'make mrproper' ...
* >> Will ignore kernel config from '/etc/kernels/kernel-config-4.19.91-gentoo-x86_64'
* in favor of already existing but different kernel config
* found in '/usr/src/linux/.config' ...
* >> Running 'make oldconfig' ...
* >> Compiling 4.19.91-gentoo-x86_64 bzImage ...
* >> Compiling 4.19.91-gentoo-x86_64 modules ...
* >> Installing 4.19.91-gentoo-x86_64 modules (and stripping) ...
* >> Generating module dependency data ...
* >> Compiling out-of-tree module(s) ...
* >> Saving config of successful build to '/etc/kernels/kernel-config-4.19.91-gentoo-x86_64' ...
* initramfs: >> Initializing ...
* >> Appending devices cpio data ...
* >> Appending base_layout cpio data ...
* >> Appending auxilary cpio data ...
* >> Appending blkid cpio data ...
* >> Appending busybox cpio data ...
* >> Appending modprobed cpio data ...
* >> Appending zfs cpio data ...
* >> Appending libgcc_s cpio data ...
* >> Appending modules cpio data ...
* >> Appending linker cpio data ...
* >> Deduping cpio ...
* >> Pre-generating initramfs' /etc/ld.so.cache ...
* >> Compressing cpio data (.xz) ...
* Kernel compiled successfully!
*
* --no-bootloader set; Skipping bootloader update ...
*
* Required kernel parameter:
*
* root=/dev/$ROOT
*
* Where $ROOT is the device node for your root partition as the
* one specified in /etc/fstab
* If you require Genkernel's hardware detection features, you MUST
* tell your bootloader to use the provided initramfs file '/boot/initramfs-4.19.91-gentoo-x86_64.img'.
* WARNING... WARNING... WARNING...
* Additional kernel parameters that *may* be required to boot properly:
* - Add "dozfs" for ZFS volume management support
* and either "root=ZFS" to use bootfs autodetection or "root=ZFS=<dataset>"
* to force booting from a specific dataset
*
* Hostid '30633861' is embedded into initramfs.
* If you will use this initramfs for a different system you MUST set 'spl_hostid=<hostid>' parameter to overwrite embedded hostid!
*
* If importing ZFS pool is slow, add dozfs=cache or dozfs=force to kernel commandline.
* "man genkernel" explains "dozfs" in detail.
*
* With support for several ext* filesystems available, it may be needed to
* add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters.
* Do NOT report kernel bugs as genkernel bugs unless your bug
* is about the default genkernel configuration...
*
* Make sure you have the latest ~arch genkernel before reporting bugs.
NAShost /usr/src/linux # |
_________________ jfp |
|
Back to top |
|
|
Whissi Retired Dev
Joined: 12 Jan 2011 Posts: 222
|
Posted: Thu Jan 02, 2020 7:19 pm Post subject: |
|
|
jfp wrote: | The two items in genkernel.conf that you need to change are:
MRPROPER="no" # the default is yes and causes genkernel to run "make mrproper" This is the real culprit because mrproper deletes /usr/src/linux/.config
CLEAN="no" # The default is "yes" and cause genkernel to run "make clean". make clean is not a problem
[...]
Once you update /etc/genkernel.conf, you can now configure you own /usr/src/linux/.config without genkernel overwriting it with "it's" .config | I think there's a major misunderstanding.
Genkernel will not not arbitrary overwrite/kill user's kernel configuration (see https://github.com/gentoo/genkernel/blob/v4.0.1/gen_configkernel.sh#L128-L169).
The important thing is to understand what kernel configuration genkernel will use.
Imagine you installed =sys-kernel/gentoo-sources-5.4.42 for the first time.
You now have two options:
- In case you didn't disable --save-config feature, chdir into /etc/kernels and copy previous config to new version, say
Code: | cp /etc/kernels/kernel-config-5.4.41-gentoo-x86_64 /etc/kernels/kernel-config-5.4.42-gentoo-x86_64 | When you now start genkernel without any additional command-line arguments, e.g. genkernel will use /etc/kernels/kernel-config-5.4.42-gentoo-x86_64 to build =sys-kernel/gentoo-sources-5.4.42 for the first time.
If you are happy with current running kernel, just call genkernel like Code: | genkernel --kernel-config=/proc/config.gz all | which will cause genkernel to build new kernel using kernel configuration from current running kernel.
In both situations it is totally safe to have mrproper enabled for example.
The problem is that people often forget to specify kernel configuration. Especially when they emerged a new kernel version. In that case, genkernel would notice there is no /etc/kernels/kernel-config-5.4.42-gentoo-x86_64 (sure, because this is the first time you are compiling gentoo-sources-5.4.42...) and would fall back to genkernel's generic configuration which isn't recommended for daily usage (like it's not optimied for your system).
I do not recommend to edit/manage /usr/src/.config on your own (like copying when changing sources). If you do that, you can easily overwrite (lose) your configuration. Like said, set --kernel-config and if you want to make changes, call with for example. This way you always know which kernel configuration will be used... _________________ Regards,
Whissi |
|
Back to top |
|
|
jfp Guru
Joined: 08 Jul 2007 Posts: 326 Location: Virginia, USA
|
Posted: Thu Jan 02, 2020 9:06 pm Post subject: |
|
|
Whissi,
Thanks you very much for correcting my misconceptions!
I think I fell into those misconceptions about a year ago when I first started using genkernel and have simply been using them since they worked for me. I like your explanation and will adjust my practices. _________________ jfp |
|
Back to top |
|
|
|