LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Fdisk..removed wrong partition...help please (https://www.linuxquestions.org/questions/linux-newbie-8/fdisk-removed-wrong-partition-help-please-455547/)

air4time 06-16-2006 08:51 PM

Fdisk..removed wrong partition...help please
 
Short of it
My second drive had 3 partitions

1st was Freebsd
2nd was Swap(Linux)
3rd but was 4th primary (Linux) for disk space
Hard drive still had like 10 gig free(unused)

I am using a modified Slackware 10.2 (linux kernel 2.6). I was tring Freebsd. But decided to use the space for Linux since has been months since I used Freebsd. So KNOW IT ALL ME went to Fdisk and removed "3" and added "3" only problem was 3 was Linux not Freebsd and I reset 3rd to use all space available. I had over 10 gig worth of stuff there. I caught it right after reboot. have not done anything to the second drive(/dev/hdb) since. Did run "gpart" but it said this
"
root@dadslinux:/home/dad# ./gpart.linux /dev/hdb

Begin scan...
Possible partition(*BSD disklabel), size(14998mb), offset(0mb)
Possible partition(Windows NT/W2K FS), size(17249mb), offset(14998mb)

* Warning: short read near sector(78165171), 64512 bytes instead of 66048. Skipping...
End scan.

Checking partitions...
Partition(FreeBSD/NetBSD/386BSD): primary
Partition(OS/2 HPFS, NTFS, QNX or Advanced UNIX): primary
Ok.

Guessed primary partition table:
Primary partition(1)
type: 165(0xA5)(FreeBSD/NetBSD/386BSD)
size: 14998mb #s(30716217) s(63-30716279)
chs: (0/1/1)-(1023/15/63)d (0/1/1)-(30472/7/63)r

Primary partition(2)
type: 007(0x07)(OS/2 HPFS, NTFS, QNX or Advanced UNIX)
size: 17249mb #s(35326928) s(30716280-66043207)
chs: (1023/15/63)-(1023/15/63)d (30472/8/1)-(65519/0/56)r

Primary partition(3)
type: 000(0x00)(unused)
size: 0mb #s(0) s(0-0)
chs: (0/0/0)-(0/0/0)d (0/0/0)-(0/0/0)r

Primary partition(4)
type: 000(0x00)(unused)
size: 0mb #s(0) s(0-0)
chs: (0/0/0)-(0/0/0)d (0/0/0)-(0/0/0)r
"
I am lost. have no ideal what to do. I do not know the exact size of the partition I deleted either.

Thanks in advance
Lonnie

syg00 06-16-2006 10:59 PM

Are you sure you're talking about the right disk ???.
I don't use gpart, but looking at that, something is screwy. Part2 is x'07' - that is NTFS (generally); a Linux swap partition would be x'82'.

If you have a Knoppix disk handy try "testdisk".

AwesomeMachine 06-16-2006 11:25 PM

OK, there are 512 bytes per disk sector. Look up your hard drive model number and find either the number of partitionable sectors, or the total number of usable bytes. Say you get usable bytes:

total bytes - 66043207 * 512 = total bytes left on disk / 512 = total sectors left on disk / 255 / 63 = total cylinders left on disk. Drop the decimal fraction of cylinders and keep the whole number. Don't round up. That integer is the how much partitionable space is left on the disk. The fraction of a cylinder is called surplus sectors, and can't be used for data because partitions have to contain whole cylinders. So, if you have 23,457.32654 cylinders: 23457 * 255 * 63 = total partitionable sectors - 10 GB of empty space / 512 = sectors that were inside free space before you deleted part 3 = about how many sectors were in part 3. With fdisk you can begin a partition by sector. You NTFS part ends at 66043207. So, you do the necessary calcs, start at sector 66043208 and tell fdisk how big to make it, and what type it is. All the data is still there. The partition entry is in sector 1 only. It is 16 bytes long. You just have to tell fdisk how to put those 16 bytes of sector 1 back about the way they were. If the new part is a little big it's ok.

air4time 06-17-2006 08:46 AM

Thanks syg00 for tring to help

"Are you sure you're talking about the right disk ???."
Yes it is the right one.

"I don't use gpart, but looking at that, something is screwy. Part2 is x'07' - that is NTFS (generally); a Linux swap partition would be x'82'."
Not sure why but that is what it came up with. I will have to check into that after I fix the mistake I did.

"If you have a Knoppix disk handy try "testdisk"."
Using "testdisk" right now but this is the second time tonight and so far no luck. Although it did see the old NTFS that was on here.
Update think it found them will have to reboot and see.


Thanks AwesomeMachine for your help

I must admit I did not understand most of what you wrote but I promise I will try to understand it.Right now need to reboot the pc think "Testdisk" found the missing partition.

One more question just in case. Freebsd works and has not been booted for a while now. If this does not work would "Freebsd" have some info that may help? Like the partition in question size? maybe even the starting and stoping points? Just a thought.

Thanks again I will post back after reboot.

Lonnie

air4time 06-17-2006 09:02 AM

Update
Testdisk did in fact recover the deleted partition but I am redoing it cause I did know understand at the end I in facted deleted the the other 2 partitions. See it asked if you want to write to the partition table the found partition but I did not relaze it only would write the one "I" marked so having to go do it all over again. I will remove the freebsd one but only after I make sure I have the deleted on back.Since "Freebsd" may have some info in it that may help.

Thanks everyone for your help not only the ones who responded but for all the people here who have responded in other post. I have in the past 20 hrs or so read a whole lot of posts on here and it was very helpful.

Lonnie

air4time 06-17-2006 05:19 PM

Sorta fixed but now "/dev/hdb2" is some how missed up??
 
Long story short got back everything but had to make it primary3 instead of 2. Not sure what happend but when I looked into the /dev/ it had hdb2 as a dir not like the others. Removed it and renamed hdb20 to hdb2 but did not work. here is what I get now
"
root@dadslinux:/home/dad# mkfs /dev/hdb2
mke2fs 1.38 (30-Jun-2005)
mkfs.ext2: No such device or address while trying to determine filesystem size
root@dadslinux:/home/dad#"

also if this helps
"
root@dadslinux:/home/dad# ls -l /dev/hdb2
brw-rw---- 1 root disk 3, 84 2002-06-09 19:27 /dev/hdb2
root@dadslinux:/home/dad# ls -l /dev/hdb1
brw-rw---- 1 root disk 3, 65 2006-06-17 20:57 /dev/hdb1
root@dadslinux:/home/dad# ls -l /dev/hdb4
brw-rw---- 1 root disk 3, 68 2006-06-17 22:02 /dev/hdb4
root@dadslinux:/home/dad# ls -l /dev/hdb3
brw-rw---- 1 root disk 3, 67 2006-06-17 20:57 /dev/hdb3
root@dadslinux:/home/dad# "

also
"Disk /dev/hdb: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 1912 15358108+ a5 FreeBSD
/dev/hdb3 3500 4865 10972395 83 Linux
/dev/hdb4 1913 3499 12747577+ 83 Linux

Partition table entries are not in disk order

Command (m for help): "

Thanks in advance

Lonnie

PS everything is working fine now but would like to know what or how to fix in case I need to one day.

syg00 06-17-2006 07:45 PM

If everything is working right, your memory of the original partitions was wrong.
Otherwise you would have had to update fstab for the "new" arrangement of the partitions.
Also don't worry about the partitions being out of (cylinder) order; consider that an informational messge rather than a warning.

Nothing to fix - another rescue for testdisk.

air4time 06-17-2006 08:41 PM

true...but
 
Thanks syg00

"Otherwise you would have had to update fstab for the "new" arrangement of the partitions."
I did modified fstab.

"Also don't worry about the partitions being out of (cylinder) order; consider that an informational messge rather than a warning."
Problem is not that they are not in order it is I can not put one in the 2 spot?

"Nothing to fix - another rescue for testdisk."
It save me alot of time.

Thanks Lonnie

syg00 06-17-2006 08:52 PM

The disk is full - that is why you can't add any more partitions.
Reduce the size of one and see what happens.

air4time 06-17-2006 09:14 PM

"The disk is full - that is why you can't add any more partitions.
Reduce the size of one and see what happens."

Ok maybe a little more detail is needed here. Even with over 20 gig free NO partition can be set to the "primary 2". Some how the "/dev/hdb2" got corrupted and my fix(deleteing it and renaming another) did not work. Before I did this I tried reboots, shutdowns having more then one partitions nothing worked . That is when I discovered the "/dev/hdb2" was corrupted. I do not know enough to replace the bad "/dev/hdb2" or even where it came from. Before I deleted it , it was a dir not a link(or what ever it is). Hope this helps better describe what is going on. And as always thanks I have been using some form of Linux for years but not til I started using "Slackware" did I start learning so much.

Lonnie

syg00 06-17-2006 09:32 PM

Mmmm - you create partitions from something like fdisk. I don't understand your use of {NO partition can be set to the "primary 2"}.
Just create partition(s), and let them create where they may. After a reboot, then you can attempt a mkfs on it.

Leave /dev alone - it'll (should) look after itself.
Haven't used Slack in a while - what is Pat shipping with 10.2 ???. Has he finally moved to 2.6 kernel as default, and is he using devfs or udev ???.
You might have to start a thread in the Slack forum for some more relevant responses if this continues as a problem.

air4time 06-17-2006 09:53 PM

" Mmmm - you create partitions from something like fdisk. I don't understand your use of {NO partition can be set to the "primary 2"}.
Just create partition(s), and let them create where they may. After a reboot, then you can attempt a mkfs on it."

Fdisk had no problem with putting it to primary 2 after reboot fdisk still showed everything as ok. But when I went to mkfs it complained about it not being a device block(or something like that) After I was able to put any where but primary 2 I looked into the /dev and seen "/dev/hdb2" was a directory but none of the other ones was. So I deleted the directory and rebooted. Then it said no such device(or something like that). I then deleted the partition with fdisk, rebooted then added again still no luck. My best guess is I did something to "/dev/hdb2" sometime and just now caught it. I need to know how to restore it.

"Haven't used Slack in a while - what is Pat shipping with 10.2 ???. Has he finally moved to 2.6 kernel as default, and is he using devfs or udev ???"
2.4 but comes with 2.6.something but unsupported and ver 10.2 is latest I think. As for devfs or udev not sure.

Which one are you(syg00) using?

"You might have to start a thread in the Slack forum for some more relevant responses if this continues as a problem."
Not sure if it is realated to Slackware, think maybe a user problem lol but if you think it would help I will do that.

Thanks Lonnie


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