Welcome! Log In Create A New Profile

Advanced

separate boot partition

Posted by papazol 
separate boot partition
June 18, 2012 11:54AM
I'm not shure that forum I should use but I have a problem with creating a separate boot partition on debian.

So I installed debian with doozan script on my usb mass storage. mount it on my pc, created an ext2 partition as the first one on it, moved all /boot stuff there, created a symlink ln -s . boot (so uBoot can find all the stuff in a boot directory on the first partition), created a second partition as ext4, moved all / stuff there, edited /etc/fstab like this:

/dev/sda1 /boot ext2 ro 0 0
/dev/sda2 / ext4 noatime 0 1
/dev/sda3 none swap sw 0 0
tmpfs /tmp tmpfs defaults 0 0

created the third swap partition. put the mass storage on dockstar, tried to boot it. failed.

how to do it right?
Re: separate boot partition
June 18, 2012 12:51PM
I'm not 100% sure it will work like that w/ a standard kernel. My guess is probably not.

UBoot reads ext2/3 just fine, but I'm pretty sure it won't be able to read the rootfs (and thus the modules in /lib) from your ext4 sda2.

Without some kind of custom kernel (w/ built-in {ie. non-modulized} ext4 support) I don't think it would work.

If you do keep that layout (which IIRC is actually the default layout for the Debian (official, not Jeff's) Installer, you'll need to adjust your UBoot env to look for the uImage &uInitrd and rootfs in their respective homes.

=====================================================
Re: separate boot partition
June 18, 2012 01:22PM
Quote

created a symlink ln -s . boot (so uBoot can find all the stuff in a boot directory on the first partition)

That won't work, as you found out. You can't use symlinks in bootloaders.

You need to modify the Uboot environment to boot from a separate boot partition. Jeff's environment will not boot from a separate boot partition without modification, just like a standard distro Grub config would not boot from a partition if that is not the default. If the kernel is in a partition, and not a directory of another partition, then you don't need a directory path in front of the kernel name, right? Just change "/boot/uImage" to "/uImage" everywhere you see it ONLY in the usb_* lines. That change alone "should" work without any other modifications. Don't change the other lines.

Make sure you make a backup of your environment before making changes. It would also be wise have access to the Uboot serial or netconsole in case the device will not boot. It is easy to mess up the environment if you are editing it from the Uboot console, as there is usually not enough room to display some lines. It is easier and safer to export the environment, edit it, and then import it back in. You can do that easily with the latest Uboot available here. The devices can't be bricked, but it is easy to make them unbootable to the point where you need to get to the Uboot console to get it to load the kernel again.

You can edit the environment from Linux using fw_printenv/fw_setenv. But if you don't feel comfortable editing the environment do not do it, as there is really no need to have a separate boot partition. I do, but the reason is that I wanted to keep my partition layout from my other machines, and that I wanted to learn about Uboot. Jeff's Uboot environment and scripts can do impressive things. Once you understand how Uboot works it is simple to make it do what you want. It is a good learning experience. So go for it, but make sure you can get back to where you were if the changes don't work.

Hope that helps.
Re: separate boot partition
June 18, 2012 01:33PM
Quote

I'm not 100% sure it will work like that w/ a standard kernel. My guess is probably not.

@davy

Yeah. It works. Ext4 is backwards compatible to ext2. Uboot works from ext4 just fine. His kernel would have to be VERY old not to support ext4. But even if it didn't it would still see it as ext3/ext2 depending on how old it was. Using as native ext4 is another story. You need at least 2.6.28 for that. But I would hope that if he is planning to use a separate boot partion that he at least has the latest sid kernel, if not the sheeva-with linux one. . .

His problem is that he is using using the stock Uboot environment from here. As you suggested it needs to be changed to work from a separate boot partition.

Funny, we were both responding at the same time. Papazol is getting some good support on this topic!
Re: separate boot partition
June 18, 2012 02:10PM
gnexus Wrote:
-------------------------------------------------------
>
Quote

I'm not 100% sure it will work like that w/
> a standard kernel. My guess is probably not.
>
>
> @davy
> Using as native ext4 is another story. You need at least
> 2.6.28 for that. But I would hope that if he is
> planning to use a separate boot partion that he at
> least has the latest sid kernel, if not the
> sheeva-with linux one. . .
>

%^| ... I must have been thinking about this : http://lists.denx.de/pipermail/u-boot/2011-December/113368.html ... which is _still_ not in mainline U-Boot, but something like this will be in within 6 months or so...

TTYTT, I think that I'd never tried it myself, but had heard that it wouldn't work, but never tried it for myself.

After himming and hawing a bit here... I now see this : http://forum.doozan.com/read.php?2,198,1237#msg-1237

Maybe it now does actually work? Maybe it has always worked, save for journaling?

=====================================================



Edited 1 time(s). Last edit at 06/18/2012 02:22PM by davygravy.
Re: separate boot partition
June 18, 2012 02:48PM
With Jeff's UBoot setup, the only UBoot env change needed to boot a 2-partition USB boot drive is usb_init, which is used to identify the location of the rootfs. I did this a while ago:
http://forum.doozan.com/read.php?2,5461,6465#msg-6465

As gnexus said, there is really no need to use 2 partition solution, if the only purpose is to get around the power outage problem. I don't use this setup any more.
Re: separate boot partition
June 18, 2012 04:41PM
Quote

Maybe it now does actually work? Maybe it has always worked, save for journaling?

Thought so at the time. But davy got me thinking since he's pretty sharp on Uboot ;)

I know mounting ext4 as ext3 (and converting from ext3 to 4) works fine. I was thinking that ext4 was also compatible with ext2, and since that is what Uboot uses it would work. I was also thinking that I was using ext4 on my Go Flex's. But turns out that is currently only for the /home partition, which is mounted by the kernel. I can't remember if I ever tried Uboot with ext4 as root or boot personally. So I decided to first just attempt to mount ext4 as ext2:
# blkid
/dev/sda7 TYPE="ext4"
# mount -t ext2 /dev/sda7 /mnt/misc
mount: wrong fs type, bad option, bad superblock on /dev/sda7,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so

So you can't mount ext4 as ext2 (I would think that it would work if you disabled journaling, but the kernel devs probably knew better, and were afraid people would more easily corrupt the filesystem if it was mounted as ext2).

Interestingly, I now learned by responding to this thread that that ext3 can be mounted as ext4 with no conversion and improved performance! So thanks for starting this thread. I responded because I thought people should know that a using a separate boot partition is easily possible with Uboot, even if is a bit pointless. I prefer that myself, however, as it make the system more robust and easier to administrate. The robustness issue of a separate /boot is basically nullified by use of an Initrd, however. That, the added complexity, and the fact that most non-Linux users are unfamiliar with the use of multiple mounted partitions, is the reason it is mostly no longer used. But I use it, and I learned something new in this thread!

Anyway, it is pointless to use ext4 for the boot partition. Many people still use ext2 for that as journaling is not really needed for a r/o filesystem and a fsck takes a split second. Most embedded systems use a raw partition for the kernel. So the big question is if Uboot can use ext4 for the root. The kernel would already be loaded then. So wouldn't it be responsible for mounting the ext4 root? I know Android uses ext4 root and Uboot, but I think the kernel is already loaded by that point and responsible for mounting the root.

I will give a ext4 rootfs a try on my GoFlex's later. It is much better anyway. I have recently been converting to ext4 on all my systems. But it is a slow process as I prefer to reformat rather than convert them. Right now the GoFlex's are compiling A10 kernels. So I can't try ext4 on their rootfs just yet.

Maybe somebody else can give more input? Is anybody using an ext4 rootfs?

If an ext4 rootfs works, but Uboot needs ext2 or 3 to boot, that may be a really good reason to have a separate boot partition!

Edit:
Learned of something else at Arch also E4Rat - improve system boot times



Edited 1 time(s). Last edit at 06/18/2012 04:48PM by gnexus.
Re: separate boot partition
June 18, 2012 04:48PM
I used ARMedSlack and although I don't use the 2 partition solution any more, it is the recommended partitioning scheme in the ARMedSlack installation instructions. The instruction recommends the following scheme:

/dev/sda1 /boot 100MB ext2
/dev/sda2 swap
/dev/sda3 / ext4 "or your choice"

This requires a uboot enviroment argumemnt of:

bootargs_root 'root=/dev/sda3 waitforroot=10 rootfs=ext4'

Also, I'm not sure of the need for the symlink that papazol is using.
Re: separate boot partition
June 18, 2012 06:24PM
So thanks guys for responses. I fought that I have to change some bootloader options. If I boot from NAND I cant use fw_printenv. there is no fw_printenv in /usr/sbin/fw_printenv, so I made an another new usb drive debian installation, played with environment options and after some time boot successfully.

you have to change with fw_setenv that variables:
usb_scan_1=usb=0:1 dev=sda2
usb_scan_2=usb=1:1 dev=sdb2
usb_scan_3=usb=2:1 dev=sdc2
usb_scan_4=usb=3:1 dev=sdd2
usb_rootfstype=ext4


so that uses the second partition for root. the symlink in the /boot (ln -s . boot) directory is still important, but if you adapt the usb_boot environment variable it will be unnecessary.
ok, that's all.
retabell
Re: separate boot partition
June 19, 2012 03:02AM
Quote

Maybe it now does actually work? Maybe it has always worked, save for journaling?

still worked with kernel 2.6.32

Quote

If an ext4 rootfs works, but Uboot needs ext2 or 3 to boot, that may be a really good reason to have a separate boot partition!

as far i remember uboot needs ext2 to boot the kernel, (the "older" uboot)

i have created a native ext4 rootfs-partition on an other machine and copied the Installation (tarball)

created a symlink to the boot-partion,
edit /etc/fstab
setup the env

a snippet
usb_rootfstype=ext4
usb_root=/dev/sda3
usb_custom_params=root=/dev/sda3

/dev/sda1               1         510     4096543+  83  Linux
/dev/sda2             511         575      522112+  82  Linux swap / Solaris
/dev/sda3             576       60801   483765345   83  Linux

Note this Installation is 1,5 years old
Re: separate boot partition
June 20, 2012 07:30AM
Quote

If I boot from NAND I cant use fw_printenv

Your fw_env.config configuration is incorrect. The file is located in /etc.

You need the following settings to get it to work for Jeff's Uboot:

# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.

# for Marvell Kirkwood
# (get cpu info in /proc/cpuinfo):
#  Hardware     : Marvell eSATA SheevaPlug Reference Board (temp arcNumber until GoFlex Net kernel)

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
#/dev/mtd0              0x0000          0x20000         0x20000

# Dockstar offsets:
/dev/mtd0               0xc0000         0x20000         0x20000

As you can see from the file the address of the environment has changed from 0x0000 to 0xc0000. That is why the command does not work. It works from Linux in any rootfs you have (NAND, USB, SATA) as long as the config is correct.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: