Rescue-Key Installer - Advanced Format drives + alignment

Got problems with your B2 or B3? Share and get helped!
Post Reply
Stryker
Posts: 55
Joined: 17 Oct 2013, 11:03

Rescue-Key Installer - Advanced Format drives + alignment

Post by Stryker » 03 Jan 2014, 17:47

I own a B3 which I bought used with a 2TB WD Green harddrive.
Early on I switched that drive with a 3TB WD Red, installed the 3TB-Bootloader-Fix and went on using the underlying debian squeeze without the excito-apps.
After encountering some limitations because of the old kernel, I switched to a custom image with a newer debian wheezy (MouettE's: http://forum.excito.net/viewtopic.php?f=7&t=4477)
But by now a problem has arisen, which is probably related to the default installation by Rescue-key:

Incorrect alignment
I realised that my root-partition was not correctly aligned to 4K-Sector boundaries.
My 3TB WD Red uses 4K-Sectors internally, but still exposes 512 Byte logical sectors to the filesystem.
In order to reduce the number of internal writes, you should align your partitions in such a way, that their starting sector (or block/LBA) is a multiple of 8. (512*8 = 4096).
Instead the first (root) partition starts at sector 34, right after the GPT-Header, which leads me to the next issue...

The secondary GPT-Header is destroyed
GPT has two Headers (which contains the partition table), see https://en.wikipedia.org/wiki/GUID_Partition_Table
While the primary header is stored at the beginning, the secondary header is located at the very end of the drive. Its use is for restoring the primary one, in case it gets corrupted.
Problem is, that probably the Installer overwrites the secondary GPT-Header with the swap-Partition.

Here is how this probably happened:
The Installer first creates the ext2/3 root-partition with a size of 10GB starting from sector 34 right after the end of the GPT-header (which ends at sector 33).
This is probably due to the installer not respecting either the Multiple-of-8-rule or the standard 1-MiB-MBR-Gap (which is equal to 2048 sectors) almost every modern partitioning tool uses.
Afterwards it creates a small lvm-physical-volume-partition (+ maybe swap) and then extends its size to the maximum of the drive, thereby killing the secondary GPT-header.

This has also lead to me not being able reformat manually, since
  1. Gparted crashes when I try to read the device on a different computer via a SATA-to-USB-adaptor with the aforementioned corrupt-secondary-Header error.
  2. I would probably have to rewrite the bootloader, when I make changes to the partitions (e.g. delete and recreate one).
Do you have any suggestions, what I can do to
  • get a correctly aligned root-partition
  • restore the secondary GPT-Header at the end of the drive

Stryker
Posts: 55
Joined: 17 Oct 2013, 11:03

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by Stryker » 04 Jan 2014, 12:06

Small update:

The gdisk-tool (fdisk for GPT) is able to recognize my drive without crashing.
It also suggests rebuilding the secondary header and verify my disk.
Here is what I plan to do:
  1. Rebuild secondary GPT-Header
  2. Delete the lvm-partition (home), I will do that in-system after boot
  3. Make sure the swap-partition has the correct size and is positioned right before the backup-header
  4. Move the root-partition (ext3) so it is correctly aligned, either at sector 40 or at 2048 (1MiB)
What I do not know is:
  • How does the bootloader (U-Boot) identify the boot-partition where the kernel lies?
  • Can I just copy the backed-up filesystem after I recreated the root-partition or should I have made a copy with dd, which directly copies blocks instead of files?

MouettE
Site admin
Posts: 264
Joined: 06 Oct 2011, 19:45

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by MouettE » 04 Jan 2014, 12:28

Stryker wrote: What I do not know is:
  • How does the bootloader (U-Boot) identify the boot-partition where the kernel lies?
There should be no problem with U-Boot. It reads the partition table and loads boot files from the first partition of the first disk (ie /dev/sda1).
Stryker wrote:
  • Can I just copy the backed-up filesystem after I recreated the root-partition or should I have made a copy with dd, which directly copies blocks instead of files?
Don't bother with dd. From rescue, create a tar, re-organize your disk, format the new root partition and untar.

Stryker
Posts: 55
Joined: 17 Oct 2013, 11:03

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by Stryker » 04 Jan 2014, 17:55

Thx a lot for your help.

e2: I will put this in front.
The machine boots regularly now. Alignment and GPT-headers are correct.
Just do not switch to a ext4-filesystem as root, since apparently the U-Boot cannot handle that.
So I will summarize for future readers, who might want to repartition the root-fs due to mis-alignment:
  • Use the USB-Rescue-Key in "INSTALL=0"-mode to boot a live system
  • Backup your root-fs (and home) into a tarball (keeps permissions!) on a (second) USB-drive.
    Yes, just "copy" (and zip) your files into a .tar archive, it works. That is what the installer does too..
  • Make sure root can connect via ssh in case you disable/destroy the /home partition.
  • Connect the harddrive to a regular SATA-port of a different machine (with a screen preferrably) and do your partitioning-magic.
  • Unpack your backed-up root-fs to the new partition.
    Remember to modify the /etc/fstab, in case you have changed the file-system type (ext2->ext3) or deleted other partitions.
  • The B3's bootloader automatically boots from the first partition on the drive (ext4 does not work, but ext2/3 do)
---------------------------------

original Post:
Stryker wrote:You just won't believe me, what happened next...
After you have told me, that UBoot just boots from the first partition on the drive, I went on with reformatting.
I have deleted all partitions and rebuilt the secondary header.

But afterwards gdisk claimed my 3TB drive only has a capacity of ~740GB.
Using the e command to move the secondary header to the end of the drive did not fix the issue...
I then zapped the GPT-Information so that neither MBR nor GPT were present on the drive.
But running gdisk again to write a fresh GPT just returned the same results as before.

What I realise is, that 740GB is approx. the size of a single platter of which there are four on a 3TB device.
I already managed to solve this issue. The perpetrator was my SATA-to-USB-Adaptor, which apparently has difficulties with modern (AF) harddrives.
I plugged the device to my desktops internal SATA-Controller and everything was fine again.
Layout as follows:

Code: Select all

sdaX  start   end     size    fstype        info

-     0       2047    1MiB    empty         GPT + (MBR-Gap)
1     2048    X       10GiB   ext4          root-fs
(2)   X+1     Y       ~2,7TB  unformatted   lvm/home
3     Y+1     -34     1GiB    swap          swap
-     -33     -1      ~17KiB  blocked       secondary GPT header
I modified /etc/fstab so the unformatted lvm is not being mounted and sda1 is being mounted as ext4 instead of 3.

When trying to boot the newly partitioned OS on the drive, the LED unfortunately stays purple.
I wonder if it that is due to me choosing ext4 as the fstype for root, which U-Boot might not be able to handle..
Or, as I suspected, U-Boot does use something else to identify the boot-partition.
I heard that some bootloaders need the boot-partition to be within the first 1024 sectors...

edit:
When I boot the Rescue-System, parted can see the partitions and recognizes the ext4-fs.
But I cannot mount it. I get a "no such device" error when explicitly stating its type and "Invalid argument" otherwise.

Stryker
Posts: 55
Joined: 17 Oct 2013, 11:03

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by Stryker » 05 Jan 2014, 19:12

The only thing kind of wrong now is, that the B3 takes a very long time to boot.
At first I thought something was wrong with it...

Do you happen to have some insight as to why it takes longer to boot after I configured a new lvm-setup?
Do I have to set special parameters? I think I mirrored the settings from before..

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by johannes » 09 Jan 2014, 17:05

..following this with interest. You could always get a serial console, to find out what it does during boot?

http://wiki.excito.org/wiki/index.php/S ... cess_on_B3
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

Stryker
Posts: 55
Joined: 17 Oct 2013, 11:03

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by Stryker » 09 Jan 2014, 18:22

..well, let me explain a bit here:
How long does it usually take for the B3 to boot into normal operation mode (purple -> blue LED)?

I estimate about 2 minutes until the device is ready, which I think is longer than before.
It might also be, that this is the normal bootup time and I just did not realize this until now.

I know how to solder and might be able to borrow the necessary equipment, but sadly I am not willing to turn my B3 apart again after it finally operates normally.
I am very busy right now with my bachelor's thesis and I don't have the time right now, to disassemble it again.

e: While I have you here, I think that you should add the information I collected to the "Re-installing B1/B2/B3"-Wiki-article.
(how to manually format a drive, "installing" (copy) an B3-Image to the disk)

Ubi
Posts: 1547
Joined: 17 Jul 2007, 09:01

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by Ubi » 10 Jan 2014, 01:00

Sometimes booting takes more time when the disks need to be checked. This information is present in dmesg

johannes
Posts: 1469
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Re: Rescue-Key Installer - Advanced Format drives + alignmen

Post by johannes » 10 Jan 2014, 02:27

Stryker wrote: e: While I have you here, I think that you should add the information I collected to the "Re-installing B1/B2/B3"-Wiki-article.
(how to manually format a drive, "installing" (copy) an B3-Image to the disk)
You are very welcome to write your own wiki article about this topic, and I could link to it from the installer article? I'd like to keep the original article clean and simple since many people using it are not techies, this might scare them. :)
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)

Post Reply