Re: [lfs-support] help, i hosed my windows partition

2013-03-13 Thread tilmanbregler
Hi everybody,

Thanks for all the advice, so far.

@Pierre:

I'll give that a go, if all else fails. Somehow, removing the linux
partition seems a bit scary, especially after my recent experience :)

@akh:

I'm afraid the disk cloning is not an option. My computer is a laptop,
and it's the only one i got, atm, so I can't really attach the disk to
another computer. Also, it's 500GB and i don't have another disk that
size.

@Aleksander:

Hm, that doesn't sound too hopeful. To be honest, i don't need
Windows, desperately, and I'm worried i'll screw up my linux
partition, as well. I think I should probably read up a bit more on
partitions and take it from there. Who knows, maybe it's even time to
start from scratch...

Thanks again,

Tilman
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page


Re: [lfs-support] help, i hosed my windows partition

2013-03-10 Thread Pierre Labastie
Le 10/03/2013 10:33, tilmanbregler a écrit :
 Hi,

 so this is a bit emberassing, and I appreciate if you say this is
 nothing to do with you. I have this dual boot Ubuntu 12.04/Windows 7
 setup. And to make room for th LFS partitions i decided to shrink the
 Windows 7 partition.

 [...]
   This is how my
 partition table looks, atm:

   sudo fdisk -l

 Disk /dev/sda: 750.2 GB, 750156374016 bytes
 255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 4096 bytes
 I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 Disk identifier: 0x05b005af

 Device Boot Start End Blocks Id System
 /dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
 /dev/sda3 206848 1465147391 732470272 5 Extended
 /dev/sda5 1024004096 1449783295 212889600 83 Linux
 /dev/sda6 1449785344 1465147391 7681024 82 Linux swap / Solaris


Well, so which is your Ubuntu partition: /dev/sda5?
It seems that there is a NTFS partition at /dev/sda1. What is it?
I thought Windows needed only one partition, but maybe
it is not true.
Anyway, you could try two things:
1) Shrink the first partition by one sector (this involves
shrinking first the filesystem), then remove the extended partition
and recreate it starting at 206847 (this involves removing first
/dev/sda5-6 and recreating them afterwards, at the same sectors of course,
see 2) below for something slightly more detailed).
Then recreate the Windows partition starting at 206848.
2) Remove first the extended partition /dev/sda3. This involves removing
/dev/sda5 and 6, too,
so you might loose your linux systems if something goes wrong.
Of course, keep a track of the sectors of those partitions...
-Create a primary partition (/dev/sda2) for the NTFS system starting at
206848 and with a size enough to contain your Windows system.
-Recreate the extended partition starting just after /dev/sda2
and extending to the end of the disk.
-Recreate logical partitions /dev/sda5 and 6 with the same sectors as 
before.
-Cross fingers and write the table to disk (well, instead
of crossing fingers, think long before you do, print the partition table
and double check everything. As long as you do not
type 'w', you cannot screw things more than they are...)

Remember, all of this may fail for just one typo!

Regards and good luck
Pierre
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page


Re: [lfs-support] help, i hosed my windows partition

2013-03-10 Thread akhiezer
 Date: Sun, 10 Mar 2013 09:33:39 +
 From: tilmanbregler tilmanbreg...@gmail.com
 To: lfs-support@linuxfromscratch.org
 Subject: [lfs-support] help, i hosed my windows partition

.
.

 so this is a bit emberassing, and I appreciate if you say this is
 nothing to do with you. I have this dual boot Ubuntu 12.04/Windows 7
 setup. And to make room for th LFS partitions i decided to shrink the
 Windows 7 partition.

.
.
 206848. Any ideas how i can do that, or get back my windows partition,
 otherwise?

 Thanks in advance,

 Tilman



The following is just about the first step - making a backup - and not about 
the subsequent recovery steps.


In situations like this, it's a good idea to, as a zeroeth step: stop, do 
nothing to/with/for/on the disk for the time being, and think things through; 
don't take 'lunges' at it, or you run a quickly-escalating risk of being drawn 
(further) into the quicksand.

Ideally, and before any further other operations on the disk, get a clone of it 
and verify that the clone is an accurate copy: that way, you have a 
backup/snapshot of your present state, that you can fall back on if necessary 
(at which stage you'd make a clone of the clone before proceeding, and so on).

For making the clone, you will ideally need a spare additional disk that is 
empty and/or that you are OK to overwrite, and whose capacity is larger than 
the Ubuntu/'Win' disk.

Ideally, take the present Ubuntu/'Win' disk and the 'spare additional disk', 
attach each as a dumb disk to another machine, and use dd to make the clone: 
but be very careful and clear about source and target disks, and dd usage - 
especially those common usages that will **WIPE** out your target disk - , and 
so on through the usual list of caveats, including that you want the 
'another machine' to treat the Ubuntu/'Win' disk as a dumb disk, and not try to 
do anything fancy or 'automated' to the disk. 

If that's really not possible then can you attach the 'spare additional disk' 
to the original machine, boot into Ubuntu from the Ubuntu/'Win' disk, and use 
dd from there. Again, the same list of warnings c apply here as above. NB that 
this is a less-ideal situation than the one above, as here the Ubuntu/'Win' is 
not playing an 'inert'/'passive' role, because here you're booting from it.

Once you have done the clone, test it (the clone) by trying to boot Ubuntu from 
it: ideally connect it to the original machine in place of the original 
Ubuntu/'Win' disk (temporarily, for the purposes of the test), connected in 
exactly the same way (same ports, etc). If/when you get to the login prompt, 
just login and do a graceful shutdown of the machine. You might also want to 
verify similarly that it will boot in another machine - or at least can be 
mounted and find/cat/ls works ok in another machine. But don't do anything 
beyond that - you don't want to be changing the clone (other than perhaps the 
login and command-history being recorded).

If you don't have a 'spare additional disk' at all, then perhaps if possible 
consider obtaining one: it should be larger than the Ubuntu/'Win' disk, else 
you'd have to juggle a lot, with the risk of confusion and 
foot-shooting/branch-sawing.

If you do have a 'spare additional disk' but can't afford to wipe it, then be 
aware that dd can write its output to an ordinary file. You'd still need to 
have enough spare space to write the clone-image file: else you're back to the 
stage of obtaining a suitable disk that has got enough space for making the 
clone. But you really must be careful, in this scenario, to not wipe the disk: 
you're, in this scenario, writing dd's output to an ordinary file in the 
filesystem of the 'spare additional disk'. And you've got some juggling and 
extra steps to do in verifying - or later using - the clone.

Best, overall, to have a 'spare additional disk' that you can wipe and that is 
larger than the original Ubuntu/'Win' disk.

Proceed with caution and deliberation. Keep a clear picture of what disks are 
where, what is on them at each stage, etc. Keep a clear picture of what you're 
doing: else back off for a bit until you do; again, don't take lunges at 
situations like this.



hth,

akh





--
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page


Re: [lfs-support] help, i hosed my windows partition

2013-03-10 Thread Aleksandar Kuktin
On Sun, 10 Mar 2013 09:33:39 +
tilmanbregler tilmanbreg...@gmail.com wrote:
 
 [snip]
 
  sudo fdisk -l
 
 Disk /dev/sda: 750.2 GB, 750156374016 bytes
 255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
 Units = sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 4096 bytes
 I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 Disk identifier: 0x05b005af
 
 Device Boot Start End Blocks Id System
 /dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
 /dev/sda3 206848 1465147391 732470272 5 Extended
 /dev/sda5 1024004096 1449783295 212889600 83 Linux
 /dev/sda6 1449785344 1465147391 7681024 82 Linux swap / Solaris
 
 Ideally, i'd like to create the ntfs partition starting at sector
 206848. Any ideas how i can do that, or get back my windows partition,
 otherwise?
 
 Thanks in advance,
 
 Tilman

In short, what you wish to do is impossible, as such.

The standard issue PC partition table has only four slots for
partitions, called physical partitions. In the case more partitions
are needed, the last partition gets subpartitioned. The subpartition
table is kept at the start of the fourth partition. These subpartitions
are called virtual partitions.

So you are unable to make the NTFS partition start at 206848 presumably
because that is the first sector of where the virtual partition table is
being kept.

If you did at one point write a 5-partition table to the disk, with the
NTFS partition starting beyond sector 206848, with the content between
the end of /dev/sda1 and the start of NTFS partition being unaccounted
for, I am afraid that the start of your NTFS partition (and, by
extension, NTFS filesystem) has been nuked.

If, on the other hand, you did not write a 5-partition layout to the
disk, it is still possible for the resizing of the NTFS filesystem to
have hosed your Windows. This possibility has to do with bootloaders
and the way they find later stages. Because the Master Boot Record of
either the entire disk or just a partition is very, very small, the
very first stage of the bootloader also has to be very small which
translates into the bootloader being very dumb. This stupidity is
normaly worked around by having the first stage of the bootloader seek
a preprogrammed sector on the disk, loading the second stage of the
bootloader contained therein and passing control to it. What this means
is that once the first stage of the bootloader gets written into the
MBR, the file containing the second stage Must. Not. Be. Touched.
Otherwise, the first stage will not be able to find it. [See footnote
for aditional words of I-leaned-this-the-hard-way-just-like-you-now
wisdom.] It is entirely possible that during the resizing of the NTFS
the resizing program moved the second stage bootloader.


Footnote: In the case bootloader is single-stage, like LILO is, the
  system operates in a similar way. Instead of searching for
  the second stage bootloader, LILO is searching a specific
  array of disk sectors for the Linux kernel. For this reason,
  in every case that the kernel gets changed, LILO has to be
  rewritten into the MBR so that the new kernel can be found.

Footnote.2: You know, it may be possible to get around this problem by
writing the contents of the new file into the old file.
((cat newfile  oldfile) instead of (cp newfile oldfile))
However, the contents would have to be of the same length
and you would have to rely on the filesystem to not move
the files around (I think ext3 does move files (reallocate
the sectors for the file) in this case but ext2 does not
move them; ext3 can be changed into ext2 by turning off the
journal).

-- 
You don't need an AI for a robot uprising.
Humans will do just fine.
 --Skynet
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page


Re: [lfs-support] help, i hosed my windows partition

2013-03-10 Thread Aleksandar Kuktin
One other thing, although it qualifies as a false hope: it just may be
possible, at least theorethically, to recover most or all of the
contents of the NTFS partition. So if you did manage to nuke the few
starting sectors of your NTFS partition, do not lose hope just yet -
unless the damage hit a critical part of the filesystem (which is very
likely - it did hit the start of the partition, after all), it should be
possible to extract most or even all files and directories. Although
there are no guarantees - a part of some file could have been written
over, or a directory may have lost some or all of its contents.

Note that this method relies on having either a library or a program
available that can perform the appropriate functions. I do not know of
any that exist right now, especially for NTFS, but if you have
something very important that you have not backed up somewhere else,
maybe either look around for such a program or keep on to the image file
of the damaged filesystem (partiton) until such a program gets written
(because it eventually will).

-- 
You don't need an AI for a robot uprising.
Humans will do just fine.
 --Skynet
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/lfs/faq.html
Unsubscribe: See the above information page