LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Hidden data between MBR and first partition? (https://www.linuxquestions.org/questions/linux-hardware-18/hidden-data-between-mbr-and-first-partition-727558/)

Completely Clueless 05-21-2009 10:22 AM

Hidden data between MBR and first partition?
 
Hi all,

There's an option box to check in the Clonezilla backup disk to save what is described as the "hidden data between MBR and first partition?" At the risk of appearing ignorant (not something that's ever bothered me here) what exactly is the nature of this so-called "hidden data" and how much space does it take up?

tia,

cc.

Valery Reznic 05-22-2009 12:10 AM

Quote:

Originally Posted by Completely Clueless (Post 3548242)
Hi all,

There's an option box to check in the Clonezilla backup disk to save what is described as the "hidden data between MBR and first partition?" At the risk of appearing ignorant (not something that's ever bothered me here) what exactly is the nature of this so-called "hidden data" and how much space does it take up?

tia,

cc.

In some sense the unit HDD are "built" from is cylinder.
On each disk (or using fdisk command) you can see how many cylinders disk has.

MBR is sector 0 in cylinder 0.
Any partition is start (and end) on the cylinder boundary.
So, even if your first partition started in the cylinder 1,
all but sector 0 if the cylinder 0 are lost. Or hidden.
if your first partition started from say cylinder 10, then all data in the cylinders 1-9 will be lost/hidden too

syg00 05-22-2009 12:35 AM

To be more specific, there are 62 sectors between the MBR and the first partition. Yes, that's a "track" worth, not a cylinder worth on modern disks, but sector 63 is considered the start of cylinder 1. And for a "classic DOS-style" partition table, the first partition needs to start here for historical reasons.
lilo has saved data into the sector(s) following the MBR for ages - grub also often uses them now (any boot virus worth the name would also use these sectors).

Completely Clueless 05-22-2009 05:26 AM

Quote:

Originally Posted by syg00 (Post 3548950)
To be more specific, there are 62 sectors between the MBR and the first partition. Yes, that's a "track" worth, not a cylinder worth on modern disks, but sector 63 is considered the start of cylinder 1.

So is this first "track" known as "track 0"? In Acronis, there's a puzzling option which refers to saving the data in "track 0" so that refers to the first 62 sectors which obviously includes the MBR in sector 1?

Another thing: I believe there's the so-called 'magic number' (x0055 if I recall correctly) which signifies the end of the MBR. Is there a similar signature for the start of the first partition or is its start position simply 'taken for granted' by the O/S?

jschiwal 05-22-2009 07:19 AM

I have wondered myself if this area was used by some copy protection schemes. In Linux & XP, you can pretty much bank that the first partition will start on sector 63 (512 bytes * 53). You can use this to mount the first partition of an drive image backup:
losetup -fs imagefile.img -o $((512*53))
And this may come in handy if you accidently ruined your MBR partition table.

My toshiba laptop starts the first partition at 2046 for some reason. I don't know if this is Toshiba's doing or has to do with Vista.

Also keep in mind that there are other partition schemes. You might want to look up MBR in Wikipedia if you want to further your knowledge.

pixellany 05-22-2009 07:50 AM

The area in the first 63 sectors can be used for other boot code, also. For example, I think GRUB puts stage 1.5 and 2 in the area after the MBR. In any case, you do not need to back up areas outside the partitions.

I don't think partitions start or end with any signatures or "magic numbers". The partition table tells the system where they are.

And what is the purpose of the MBR "signature" (0x55AA)? I have no clue.

syg00 05-22-2009 08:31 AM

The signature indicated a valid disk. Earlier versions of [cs]fdisk would refuse to open a disk that lacked these bytes. Maybe the DOS fdisk as well, I don't know.

These bytes exist in the first sector of (each) logical partition as well BTW.

pixellany 05-22-2009 09:31 AM

Quote:

Originally Posted by syg00 (Post 3549327)
These bytes exist in the first sector of (each) logical partition as well BTW.

Right!! Because an extended partition--and each logical partition--are part of a linked list in which each one has a partition table. In a sense, each logical partition is structured as a disk.

Completely Clueless 05-23-2009 06:54 AM

Quote:

Originally Posted by pixellany (Post 3549389)
Right!! Because an extended partition--and each logical partition--are part of a linked list in which each one has a partition table. In a sense, each logical partition is structured as a disk.

Indeed. And likewise, there's a /boot/grub directory in every Linux partition that uses Grub, each with its own menu.lst file! My main desktop runs 5 different distros and unfortunately, the Grub auto config routine of the latest install all too often incorrectly re-writes/augments the prior-existing menu.lst entries, giving rise to boot menu nightmares.

I've also had it so when I change the "default 0" to "default 7" to boot from sda8 instead of sda1, Grub ignores it and still boots the first partition regardless. Anyone else had this?

syg00 05-23-2009 07:04 AM

Quote:

Originally Posted by Completely Clueless (Post 3550149)
Indeed. And likewise, there's a /boot/grub directory in every Linux partition that uses Grub, each with its own menu.lst file! My main desktop runs 5 different distros and unfortunately, the Grub auto config routine of the latest install all too often incorrectly re-writes/augments the prior-existing menu.lst entries, giving rise to boot menu nightmares.

Maybe you should set up a "master" system, and only install grub on the later systems to the root partition - then chainload them all.
Or use something like gag which does the same thing.
Quote:

I've also had it so when I change the "default 0" to "default 7" to boot from sda8 instead of sda1, Grub ignores it and still boots the first partition regardless. Anyone else had this?
This has nothing to do with the partitions, merely the entries in the boot menu (count the "title" lines).

Completely Clueless 05-23-2009 08:33 AM

Well I'm posting my menu.lst file herewith. Let's face it: we can all use a laugh now and again. If anyone has a longer and/or more confusing one, I'd like to see it. Perhaps we could start a competition!


Code:

# menu.lst - See: grub(8), info grub, update-grub(8)
#            grub-install(8), grub-floppy(8),
#            grub-md5-crypt, /usr/share/doc/grub
#            and /usr/share/doc/grub-legacy-doc/.

## default num
# Set the default entry to the entry number NUM. Numbering starts from 0, and
# the entry number 0 is the default if the command is not used.
#
# You can specify 'saved' instead of a number. In this case, the default entry
# is the entry saved with the command 'savedefault'.
# WARNING: If you are using dmraid do not change this entry to 'saved' or your
# array will desync and will not let you boot your system.
default                0

## Graphical boot menu location
gfxmenu=/boot/gfxmenu/default.message

## timeout sec
# Set a timeout, in SEC seconds, before automatically booting the default entry
# (normally the first entry defined).
timeout                10

# Pretty colours
color cyan/blue white/blue

## password ['--md5'] passwd
# If used in the first section of a menu file, disable all interactive editing
# control (menu entry editor and command-line)  and entries protected by the
# command 'lock'
# e.g. password topsecret
#      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
# password topsecret

#
# examples
#
# title                Windows 95/98/NT/2000
# root                (hd0,0)
# makeactive
# chainloader        +1
#
# title                Linux
# root                (hd0,1)
# kernel        /vmlinuz root=/dev/hda2 ro
#

#
# Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST

### BEGIN AUTOMAGIC KERNELS LIST
## lines between the AUTOMAGIC KERNELS LIST markers will be modified
## by the debian update-grub script except for the default options below

## DO NOT UNCOMMENT THEM, Just edit them to your needs

## ## Start Default Options ##
## default kernel options
## default kernel options for automagic boot options
## If you want special options for specific kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
##      kopt_2_6_8=root=/dev/hdc1 ro
##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
# kopt=root=/dev/sda1 ro

## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,0)

## should update-grub create alternative automagic boot options
## e.g. alternative=true
##      alternative=false
# alternative=true

## should update-grub lock alternative automagic boot options
## e.g. lockalternative=true
##      lockalternative=false
# lockalternative=false

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

## should update-grub lock old automagic boot options
## e.g. lockold=false
##      lockold=true
# lockold=false

## Xen hypervisor options to use with the default Xen boot option
# xenhopt=

## Xen Linux kernel options to use with the default Xen boot option
# xenkopt=console=tty0

## altoption boot targets option
## multiple altoptions lines are allowed
## e.g. altoptions=(extra menu suffix) extra boot options
##      altoptions=(single-user) single
# altoptions=(recovery mode) single

## controls how many kernels should be put into the menu.lst
## only counts the first occurence of a kernel, not the
## alternative kernel options
## e.g. howmany=all
##      howmany=7
# howmany=all

## should update-grub create memtest86 boot option
## e.g. memtest86=true
##      memtest86=false
# memtest86=true

## should update-grub adjust the value of the default booted system
## can be true or false
# updatedefaultentry=false

## should update-grub add savedefault to the default options
## can be true or false
# savedefault=false

## ## End Default Options ##

title                Linux Mint x64 Edition, kernel 2.6.27-7-generic
root                (hd0,0)
kernel                /boot/vmlinuz-2.6.27-7-generic root=/dev/sda1 ro quiet splash
initrd                /boot/initrd.img-2.6.27-7-generic
quiet

title                Linux Mint x64 Edition, kernel 2.6.27-7-generic (recovery mode)
root                (hd0,0)
kernel                /boot/vmlinuz-2.6.27-7-generic root=/dev/sda1 ro single
initrd                /boot/initrd.img-2.6.27-7-generic

title                Linux Mint x64 Edition, memtest86+
root                (hd0,0)
kernel                /boot/memtest86+.bin
quiet

### END DEBIAN AUTOMAGIC KERNELS LIST

# This is a divider, added to separate the menu items below from the Debian
# ones.
title                Other operating systems:
root


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda5.
title                Debian GNU/Linux, kernel 2.6.26-1-amd64 (on /dev/sda5)
root                (hd0,4)
kernel                /boot/vmlinuz-2.6.26-1-amd64 root=/dev/sda5 ro quiet
initrd                /boot/initrd.img-2.6.26-1-amd64
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda5.
title                Debian GNU/Linux, kernel 2.6.26-1-amd64 (single-user mode) (on /dev/sda5)
root                (hd0,4)
kernel                /boot/vmlinuz-2.6.26-1-amd64 root=/dev/sda5 ro single
initrd                /boot/initrd.img-2.6.26-1-amd64
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda6.
title                Slackware Linux (Slackware 12.2.0) (on /dev/sda6)
root                (hd0,5)
kernel                /boot/vmlinuz-generic-2.6.27.7 root=/dev/sda6
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda6.
title                Slackware Linux (Slackware 12.2.0) (on /dev/sda6)
root                (hd0,5)
kernel                /boot/vmlinuz-generic-smp-2.6.27.7-smp root=/dev/sda6
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda6.
title                Slackware Linux (Slackware 12.2.0) (on /dev/sda6)
root                (hd0,5)
kernel                /boot/vmlinuz-huge-2.6.27.7 root=/dev/sda6
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda6.
title                Slackware Linux (Slackware 12.2.0) (on /dev/sda6)
root                (hd0,5)
kernel                /boot/vmlinuz-huge-smp-2.6.27.7-smp root=/dev/sda6
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda7.
title                MEPIS at sda7, newest kernel (on /dev/sda7)
root                (hd0,6)
kernel                /boot/vmlinuz root=/dev/sda7 nomce quiet splash vga=791
initrd                /boot/initrd.img
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda7.
title                MEPIS at sda7, kernel 2.6.27-1-mepis-smp (on /dev/sda7)
root                (hd0,6)
kernel                /boot/vmlinuz-2.6.27-1-mepis-smp root=/dev/sda7 nomce quiet splash vga=791
initrd                /boot/initrd.img-2.6.27-1-mepis-smp
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda7.
title                PClinuxOS on sda1 (on /dev/sda7)
root                (hd0,6)
kernel                /boot/vmlinuz BOOT_IMAGE=linux root=UUID=ade8b470-f9a1-4063-b93f-7dd4b6fec99f acpi=on resume=UUID=c25c21be-57df-42ad-9aaf-f4636247c3e3 splash=silent vga=788
initrd                (hd0,0)/boot/initrd.img
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda7.
title                MEMTEST (on /dev/sda7)
root                (hd0,6)
kernel                /boot/memtest86+.bin 
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda8.
title                Linux Mint x64 Edition, kernel 2.6.27-7-generic (on /dev/sda8)
root                (hd0,7)
kernel                /boot/vmlinuz-2.6.27-7-generic root=/dev/sda8 ro quiet splash
initrd                /boot/initrd.img-2.6.27-7-generic
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda8.
title                Linux Mint x64 Edition, kernel 2.6.27-7-generic (recovery mode) (on /dev/sda8)
root                (hd0,7)
kernel                /boot/vmlinuz-2.6.27-7-generic root=/dev/sda8 ro single
initrd                /boot/initrd.img-2.6.27-7-generic
savedefault
boot


# This entry automatically added by the Debian installer for an existing
# linux installation on /dev/sda8.
title                Linux Mint x64 Edition, memtest86+ (on /dev/sda8)
root                (hd0,7)
kernel                /boot/memtest86+.bin 
savedefault
boot



All times are GMT -5. The time now is 06:15 PM.