DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2010-07-18 21:23:14

HamRadio
Member
Registered: 2010-02-03
Posts: 12

Temporarily changing root filesystem

Hi everyone,

I have a DNS-323 with a native Debian Lenny installation as described here with kernel 2.6.32-5-orion5x from here with a raid1 setup (1GB md0 as / and 1,5TB md1 as /home).
I have a working serial port which allows me to run kermit from my desktop pc, having access to (and possibly interacting with) the early u-boot process.
I'd like to mount an usb stick (which is an exact copy of my / md0) as root instead of the usual md0 for maintenance purposes (I'd like to rearrange my partitions), so I have to pass a kernel parameter indicating root=/dev/sdc1 as follows:

Marvell>> printenv bootargs
bootargs=root=/dev/ram console=ttyS0,115200 :::DB88FXX81:egiga0:none

Marvell>> setenv bootargs root=/dev/sdc1 console=ttyS0,115200 :::DB88FXX81:egiga0:none

Marvell>> printenv bootargs
bootargs=root=/dev/sdc1 console=ttyS0,115200 :::DB88FXX81:egiga0:none

However my DNS-323 continues to boot from /dev/md0, even though:

root@nas ~ # cat /proc/cmdline
root=/dev/sdc1 console=ttyS0,115200 :::DB88FXX81:egiga0:none

Anyone knows why?
And anyone can suggest me some way to temporarily boot from an external medium?

Thank you in advance for your answers.

Offline

 

#2 2010-07-26 23:36:25

RoganDawes
Member
Registered: 2010-07-01
Posts: 44

Re: Temporarily changing root filesystem

If you are prepared to wait a little bit, work is under way to enable booting from USB (and the network) in u-boot. Once this is complete, you should be able to flash a new u-boot to your DNS323, and configure it to boot from wherever you want to.

Network support exists already, although the flash chip is not writable as yet. USB and SATA boot should follow within the next month or so.

Offline

 

#3 2010-08-03 12:03:06

HamRadio
Member
Registered: 2010-02-03
Posts: 12

Re: Temporarily changing root filesystem

RoganDawes wrote:

Once this is complete, you should be able to flash a new u-boot to your DNS323, and configure it to boot from wherever you want to.

Hi Rogan,

this is very interesting.
Is there a website to stay up-to-date with this project?

This could let me tell u-boot to boot a kernel which could be on an usb device instead of the usual one.

However my problem remains that the kernel, which is on the mtd chip and which is well booted by u-boot with the right command line parameters, doesn't mount the root filesystem that I indicate in those command line boot parameters...

Thank you.

Offline

 

#4 2010-08-03 12:14:43

RoganDawes
Member
Registered: 2010-07-01
Posts: 44

Re: Temporarily changing root filesystem

HamRadio wrote:

RoganDawes wrote:

Once this is complete, you should be able to flash a new u-boot to your DNS323, and configure it to boot from wherever you want to.

Hi Rogan,

this is very interesting.
Is there a website to stay up-to-date with this project?

This could let me tell u-boot to boot a kernel which could be on an usb device instead of the usual one.

However my problem remains that the kernel, which is on the mtd chip and which is well booted by u-boot with the right command line parameters, doesn't mount the root filesystem that I indicate in those command line boot parameters...

Thank you.

I'm keeping a bit of a log on my progress in the U-Boot page on the DNS-323 wiki, and of course, I'll post here when I have something for others to test.

Offline

 

#5 2010-08-03 13:09:49

melon
Member
Registered: 2010-08-01
Posts: 6

Re: Temporarily changing root filesystem

HamRadio wrote:

I'd like to mount an usb stick (which is an exact copy of my / md0) as root instead of the usual md0 for maintenance purposes (I'd like to rearrange my partitions), so I have to pass a kernel parameter indicating root=/dev/sdc1 as follows:

...

Why don't you try to boot via LABEL=foobar? I just edited /etc/fstab and ran 'update-initramfs -u' and it seemed to work fine.

Code:

LABEL=root   /   ext2   noatime,nodiratime,errors=remount-ro   0   1

Offline

 

#6 2010-08-03 14:02:07

HamRadio
Member
Registered: 2010-02-03
Posts: 12

Re: Temporarily changing root filesystem

melon wrote:

Why don't you try to boot via LABEL=foobar? I just edited /etc/fstab and ran 'update-initramfs -u' and it seemed to work fine.

I don't think it could solve my problem, which is to temporarily change the filesystem mounted as root for maintenance purposes (e.g. changing filesystem type, size, etc. etc.).

I could let LABEL=root in /etc/fstab and then put an ext3 usb stick containing a copy of my root filesystem having itself LABEL=root, but the kernel will still boot from the root on /dev/md0 because I cannot remove the hard drives from the system, nor I can "hot-insert" them after the system has booted...

The problem is that the kernel ignores root=/dev/xxx command line parameter, preferring what is inside conf/param.conf in the initramfs configuration, even though usually command line parameters should have higher priority over those in config files...

Offline

 

#7 2010-08-03 15:05:50

melon
Member
Registered: 2010-08-01
Posts: 6

Re: Temporarily changing root filesystem

OK I see.
But don't you have to enter 'saveenv' after the setenv commands?

Also I've read somewhere that arm based u-boot solutions may ignore bootargs. This is somehow related to the CONFIG_CMDLINE_TAG config option in the u-boot build.

I think you can still get the disks out from the bays and reconfigure your partition layout on a desktop computer.

Last edited by melon (2010-08-03 15:07:15)

Offline

 

#8 2010-08-03 15:23:06

oxygen
Member
Registered: 2008-03-01
Posts: 320
Website

Re: Temporarily changing root filesystem

well the way you are trying to change to root fs is wrong. you just have to change your initrd config.

Offline

 

#9 2010-08-03 19:49:05

HamRadio
Member
Registered: 2010-02-03
Posts: 12

Re: Temporarily changing root filesystem

oxygen wrote:

well the way you are trying to change to root fs is wrong. you just have to change your initrd config.

Why you say this?

Perhaps that way could be not allowed on this system, but I don't think it's wrong:

I've copied the content of my / into an ext3 usb stick, then I rebooted and passed "root=/dev/sdb1" to grub, et voilà: my desktop (running Debian Squeeze) has booted from the usb stick and I can do all maintenance tasks I could need on the normal root fs on /dev/sda.

Try yourself on your machine, it works fine.

Offline

 

#10 2010-08-04 11:05:01

oxygen
Member
Registered: 2008-03-01
Posts: 320
Website

Re: Temporarily changing root filesystem

HamRadio wrote:

Try yourself on your machine, it works fine.

On my laptop yes, on a DNS-323 no, because the initrd is automatically loaded from flash.

Offline

 

#11 2010-08-04 12:21:52

Mijzelf
Member / Developer
Registered: 2008-07-05
Posts: 709

Re: Temporarily changing root filesystem

@Hamradio: Assuming it's possible to boot from usb this way, it could be that the stick is not yet ready at the moment the rootfs has to be loaded. Try adding rootdelay=10 to the commandline.

Offline

 

#12 2010-09-05 18:26:53

HamRadio
Member
Registered: 2010-02-03
Posts: 12

Re: Temporarily changing root filesystem

Hi,

after some holidays I'm still trying to solve this problem.

I've found that the kernel parameter about which is the root device is stored in the file conf/param.conf inside the initramfs tree, and this information is gathered by the script /usr/share/initramfs-tools/hooks/flash_kernel_set_root reading the content of /etc/fstab. flash_kernel_set_root is normally called by update-initramfs, dpkg-reconfigure linux-image-2.6.xx-orion5x, and perhaps /usr/bin/mkimage.
In fact my conf/param.conf contains:
ROOT="/dev/md0"
The script /usr/share/initramfs-tools/hooks/flash_kernel_set_root belongs to the package flash-kernel, which supports not only our DNS-323 but also various other machines. It seems that the bootloader in some machines do not passes a meaningful root device parameter, and in some others it does, or the parameter itself is absent. In our case u-boot configuration contains /dev/ram, a value which perhaps was used by the original firmware, but for our Debian installations it doesn't mean anything, so the script flash_kernel_set_root has to provide a meaningful root device parameter overriding the fake value passed by the bootloader. It finds out the right value extracting it from /etc/fstab.
The script flash_kernel_set_root has a function, root_type() at line 24, which can "override the root device or merely provide a default root device", depending on the machine type. Our machine, the DNS-323 is the third entry, is among those to "override".
So I could solve my problem simply changing "override" with "default" at the relevant line 33 in /usr/share/initramfs-tools/hooks/flash_kernel_set_root and then running update-initramfs or dpkg-reconfigure linux-image-2.6.xx-orion5x.
However, first of all I'd need a good root device default value in the u-boot configuration, certainly not the actual /dev/ram, and this can easily be done (having a working serial port) modifying "bootargs" parameter of the bootloader configuration, and then saving that configuration permanently by issuing the command "saveenv", as can be seen in the u-boot manual. Once I have this "meaningful" value stored as a default, I could occasionally enter another value to boot from another device, e.g. an usb stick.

Too bad that our friends at D-Link has installed u-boot without saveenv command!

In fact these are the only commands available on my DNS-323:

Marvell>> ?
?       - alias for 'help'
bootm   - boot application image from memory
cp      - memory copy
echo    - echo args to console
erase   - erase FLASH memory
loadb   - load binary file over serial line (kermit mode)
md      - memory display
printenv- print environment variables
run     - run commands in an environment variable
setenv  - set environment variables

As you can see saveenv is missing.

So here I am stuck without a way to save the parameters I'd need.
Perhaps I could dd /dev/mtdblock4 (where u-boot configuration is stored) to a file, edit it with an hex editor like ghex2, and then dd it back on /dev/mtdblock4...
I could also install a full version of u-boot, I wonder if anyone has already done it, perhaps there is a package somewhere on the net for our DNS-323 ready to install...

I don't want to risk bricking my nas, anyone has something better to suggest?

Thanks again.

Offline

 

#13 2010-09-05 19:26:43

RoganDawes
Member
Registered: 2010-07-01
Posts: 44

Re: Temporarily changing root filesystem

HamRadio wrote:

Hi,
So I could solve my problem simply changing "override" with "default" at the relevant line 33 in /usr/share/initramfs-tools/hooks/flash_kernel_set_root and then running update-initramfs or dpkg-reconfigure linux-image-2.6.xx-orion5x.
However, first of all I'd need a good root device default value in the u-boot configuration, certainly not the actual /dev/ram, and this can easily be done (having a working serial port) modifying "bootargs" parameter of the bootloader configuration, and then saving that configuration permanently by issuing the command "saveenv", as can be seen in the u-boot manual. Once I have this "meaningful" value stored as a default, I could occasionally enter another value to boot from another device, e.g. an usb stick.

Too bad that our friends at D-Link has installed u-boot without saveenv command!

So here I am stuck without a way to save the parameters I'd need.
Perhaps I could dd /dev/mtdblock4 (where u-boot configuration is stored) to a file, edit it with an hex editor like ghex2, and then dd it back on /dev/mtdblock4...
I could also install a full version of u-boot, I wonder if anyone has already done it, perhaps there is a package somewhere on the net for our DNS-323 ready to install...

I don't want to risk bricking my nas, anyone has something better to suggest?

Thanks again.

In fact, as far as I can see, the version of u-boot bulit by Marvell doesn't actually have a proper place to store the environment, which is why they don't provide saveenv. It seems to me that the environment that is present in the u-boot shell was actually compiled into the u-boot binary, rather than being a product of a saveenv command at some point.

U-Boot 1.1.1 (Feb 26 2009 - 11:33:03) Marvell version: 1.7.3.003

DRAM CS[0] base 0x00000000   size  64MB
DRAM Total size  64MB
Detect phy 1111
[8192kB@ff800000] Flash:  8 MB
Addresses 20M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (20M - 16M): Done
*** Warning - bad CRC, using default environment

And since there is no defined way to update compiled in environment variables, you're basically screwed, unless you take the chance to overwrite some of the unused settings (e.g. tftpboot or nfsroot parameters), and then flash the whole of u-boot back to your board. Of course, you then run the risk of bricking your NAS.

I have been working on building a current mainline u-boot for the DNS323. It works as a chain loaded bootloader, but I have not yet tried to flash it directly to the flash, as I do not have JTAG working just yet. (I now have the parts, so I'll try it eventually :-) ).

If you have the JTAG port set up, either option will work (modifying the vendor u-boot, or trying my mainline based one).

Without JTAG, either are a risk.

The one possibly stupid thing I could suggest is creating a /dev/ram with the major and minor numbers of your dev/md0.

It may be enough to fool things.

Rogan

Offline

 

#14 2010-09-06 11:36:11

jdoering
Member
Registered: 2008-04-10
Posts: 95

Re: Temporarily changing root filesystem

HamRadio,

I don't quite see why labels won't solve your problem; maybe I'm not understanding your use case. I'm booting my DNS-323 from USB using a label rather than a device id. I have a raid1 array that is being started via /etc/init.d/mdadm-raid (in conjunction with /etc/mdadm.conf which defines my array by UUID, again no device ids). As you noted this is configured via /etc/fstab:

Code:

LABEL=storage-root       /               ext3    noatime,errors=remount-ro 0

In my initrd this corresponds to conf/param.conf having this following line (it was autotranslated from the LABEL= syntax by the initramfs scripts):

Code:

ROOT="/dev/disk/by-label/storage-root"

I realize you have a different aim (boot from HD regularly, USB for maintenance). What I don't understand is why you can't just set up a boot based on label (say "dns323-root"). Label you hard drive that way and your usb something else (say "dns323-maint") for normal operation. Then when you want to do maintenance, use e2label to swap the labels, reboot and you should come up from usb. When you're done relabel again with e2label to get back to your normal state.

That avoids the u-boot issue altogether although it does rely on having access to the system for relabeling prior to you maintenance activities. The only detail I'm not 100% clear on is whether or not the initramfs portion assembling your raid array (so it can even check the filesystem label) will have any negative impact on this scenario. My setup doesn't do that at all (I never boot from hard drive) so I haven't played around with that.

-Jeff

Offline

 

#15 2010-10-05 12:54:04

HamRadio
Member
Registered: 2010-02-03
Posts: 12

Re: Temporarily changing root filesystem

jdoering wrote:

I don't quite see why labels won't solve your problem;

You're right,
I've put LABELS into /etc/fstab, updated initrd and it works fine.
However, first I've had to edit line 33 in /usr/share/initramfs-tools/hooks/flash_kernel_set_root as I said before, otherwise the boot process would ignore boot parameters.


RoganDawes wrote:

The one possibly stupid thing I could suggest is creating a /dev/ram with the major and minor numbers of your dev/md0.

It may be enough to fool things.

I've also made this simple udev rule

Code:

SUBSYSTEM=="block", KERNEL=="md0", ATTR{removable}=="0", SYMLINK+="ram"

which makes /dev/ram to be a symlink to my real rootfs.

Other problems are being discussed on the other thread "128MB RAM Upgrade Details" on this forum...

Last edited by HamRadio (2011-03-21 10:54:32)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB