You are not logged in.

#1 2009-09-05 08:53:17

spektre
Member
From: Sweden
Registered: 2009-05-24
Posts: 31

Can I cancel fdisk partitiontable write next reboot?

I accidentally fdisked sdb instead of sda.
Deleted every partition, made a new partition with type empty and (w)rote.
It said, something like "file system is still in use by kernel, will write table at next boot"
I thought, but sda wasn't even mounted... wait... sdb!?
sdb contains (contained) root, swap, boot and home mount points and partitions.

I'm still on the system, it's still up and running. I'm thinking I should probably be able to stop this write from happening, or is the damage already done?

Thankful for any tips, hopefully before a random power-out-without-reason.

Yours truly, paniced guy. tongue

Offline

#2 2009-09-05 09:15:33

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: Can I cancel fdisk partitiontable write next reboot?

The damage is already done.  The partition table has been written to the disk, but the kernel won't see this until the next reboot.  Copy anything you want or need somewhere while you still can, if possible.

Offline

#3 2009-09-05 09:22:43

spektre
Member
From: Sweden
Registered: 2009-05-24
Posts: 31

Re: Can I cancel fdisk partitiontable write next reboot?

The wireless network to my laptop and the other disk in the stationary is working furiously as it is smile
Very well, serves me right for contemplating installing windows. That's actually the reason I was going to clear the other hard drive in the first place. Need it for school.
Oh the irony, hehe.

Offline

#4 2009-09-05 09:34:16

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Can I cancel fdisk partitiontable write next reboot?

The partition table has been rewritten, but your filesystems and files are still intact. If you can remember the size(s) of the partititions on sda, just use fdisk to recreate the original partition table. If you can't remember them, you could try gpart.

Offline

#5 2009-09-05 11:56:10

spektre
Member
From: Sweden
Registered: 2009-05-24
Posts: 31

Re: Can I cancel fdisk partitiontable write next reboot?

gpart seems to recognize the boot and swap partitions correctly, as they are ext2 and Linux swap.
It can't find the ext3 home and ReiserFS root though.

dev(/dev/sdb) mss(512) chs(30401/255/63)(LBA) #s(488392065) size(238472mb)

Begin scan...
Possible partition(Linux ext2), size(125mb), offset(0mb)
   type: 131(0x83)(Linux ext2 filesystem)
   size: 125mb #s(256976) s(63-257038)
   chs:  (0/1/1)-(15/254/62)d (0/1/1)-(15/254/62)r
   hex:  00 01 01 00 83 FE 3E 0F 3F 00 00 00 D0 EB 03 00

Possible partition(Linux swap), size(3906mb), offset(125mb)
   type: 130(0x82)(Linux swap or Solaris/x86)
   size: 3906mb #s(8000368) s(257040-8257407)
   chs:  (16/0/1)-(513/254/61)d (16/0/1)-(513/254/61)r
   hex:  00 00 01 10 82 FE BD 01 10 EC 03 00 70 13 7A 00

This is my #df output:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sdb3             39060816   6746840  32313976  18% /
none                   1037208       132   1037076   1% /dev
none                   1037208         0   1037208   0% /dev/shm
/dev/sdb1               124427     13380    104623  12% /boot
/dev/sdb4            197850596  90391432  97408900  49% /home
/dev/sda1            153834852  97355588  48664848  67% /mnt/sda

Also, the friendly output of #fdisk -> p

Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0000d003

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       30401   244196001    0  Empty

This should be enough to rebuild the partition table, shouldn't it?
I would appreciate a second oppinion on how to make this work, because I'm a bit confused... I remember making the boot partition 128MB, but gpart states 125MB. I'm also very sure that I gave the swap part 4096MB... Could've been 4000MB though.
sdb3 (root) was 20,000MB and sdb4 (home) rest of the disk.

I've actually entered a mode where I just think this is interesting, I'm even going to have a class in file system analysis and recovery later this semester so I figure the random number god intended for this to happen. wink

Edit:
I have a feeling this could be helpful too...
# cat /proc/partitions

major minor  #blocks  name
8       16  244198584 sdb
8       17     128488 sdb1
8       18    4000185 sdb2
8       19   39062047 sdb3
8       20  201005280 sdb4

What I'm confused about is that fdisk takes sizes in cylinders and I have the sizes mostly in bytes or blocks...

Last edited by spektre (2009-09-05 13:14:40)

Offline

Board footer

Powered by FluxBB