Bring back a deleted partition


 
Thread Tools Search this Thread
Operating Systems Linux Bring back a deleted partition
# 1  
Old 05-29-2009
Bring back a deleted partition

I deleted my partition on a test server and want to
bring back the partition.

I have not rebooted yet, so system is operational.

I have the /proc/partition

Code:
major    minor    #blocks        name
8          0         195359960    sda
8          1         1044224       sda1
8          2         2096482       sda2
8          3         4200997       sda3
8          4         1                sda4
8          5         5245222      sda5
8          6         1044224      sda6
8          7         2096           sda7
8          8         179598667   sda8

the /etc/fstab

Code:
/dev/sda1         swap          swap        pri=42 0 0
devpts             /dev/pts      devpts      defaults 0 0
proc                /proc           proc         defaults 0 0
/dev/sda2        /                 reiserfs     defaults,nosuid 0 0
/dev/sda3        /usr             reiserfs     defaults,nosuid 0 0
/dev/sda5        /var             reiserfs     defaults,nosuid 0 0
/dev/sda6        /suid            reiserfs     defautls 0 0
/dev/sda7        /tmp            reiserfs     defaults,nosuid 0 0
/dev/sda8        /local           reiserfs     defaults,nosuid 0 0

if i do an fdisk -l

Code:
Disk /dev/sda: 200GB  200048599040 bytes
255 heads, 63 sectors/track, 24321 cylinders
units=cylinders of 16065 * 512 = 8225280 bytes

My question is, how do I recreate the same blocks (partition) with fdisk
given this information?

fdisk asks for +size, +sizeK, + sizeM and the blocks never seem to
match no matter how many tries I make?
# 2  
Old 06-02-2009
If you have the /sys filesystem mounted, you're in good shape. Look in /sys/block/sda/sda*/start. These give you your starting block numbers for the each partition... the one the kernel knows about since the last reboot.

When fdisk asks for a number, it's usually a cylinder number, not a block number. To convert block numbers to cylinder numbers, divide by (63*255) -- in your case -- then add one. So I get:
Code:
cat /sys/block/sda/sda*/start
63
257040
17028900
21221865

The starting cylinder numbers are as follows:
Code:
1
17
1061
1322

The ending cylinder numbers should normally be the next starting minus one.
# 3  
Old 06-04-2009
The partition may still work if it ends up larger in the partition table than it was before. This new space will not be available inside it without reformatting but that won't stop it from working for some kinds of partitions. Smaller, of course, would be a big problem...
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Deleted known_hosts file on private server, how do I get it back?

In my ignorance I deleted the known_hosts file on private server. I am not sure what the file type is supposed to be. In general, I have been having problems with ssh and passwords. For some reason, despite having generated a private/public key pair and successfully saving the .pub file onto the... (2 Replies)
Discussion started by: Circuits
2 Replies

2. Red Hat

Bring tape paths back up in Redhat 5.4

Hi Folks, Looking for some assistance here on a Dell server connected to a Dell tape robot with Redhat 5.4 and Netbackup 6.5. Netbackup thinks the tapes are all present and working, but they are not - we lost the internal encryption keys earlier but think that they are reinstated as the... (0 Replies)
Discussion started by: gull04
0 Replies

3. Shell Programming and Scripting

Bring back a file changed with sed

Hello everbody I changed one of my important files with a false sed statement by mistake now I lost my file and I hope I could bring it back what I did was: sed '/^..//' a > myfile myfile should have been another file like b ot something I know I also forgot to place an 's' to the... (5 Replies)
Discussion started by: miriammiriam
5 Replies

4. Solaris

DNS service is in maintenance mode. How to bring it back to online mode?

:confused: when i tried to look the status of DNS-client, it is in maintenance mode..... Please tell me how to bring it back to online mode...PLEASE TELL ME STEP BY STEP.... PLEASE... :wall: (2 Replies)
Discussion started by: vamshigvk475
2 Replies

5. Emergency UNIX and Linux Support

Recover deleted partition

Hi, I have got 2 hdds (2x Seagate 7200.12, 500GB). I had two RAID volumes on them: 1: 100GB RAID0 (strip) 2: ~415GB RAID1 (mirror) due to problems with matrix I removed RAID0 and RAID1 - i thougth that all data from RAID1 would be available. Unfortunately it is not. On 1 disk I set... (7 Replies)
Discussion started by: Chrisdot
7 Replies

6. Solaris

How to bring back/restore root account?

Hi all, I have a problem, when I use script with 'expect', accidentally I was deleted root account by "userdel root". Unfortunately, it works, because no other root user login on it. Solaris document said that root cannot delete root, but in my case it works because it deleted by script, not... (7 Replies)
Discussion started by: joash
7 Replies

7. UNIX for Dummies Questions & Answers

Restoring back a deleted file in unix.

Hi, Can any one tell me how to restore back the deleted file in unix? I know the file name. If i know the inode number of the file does help more to restore back the file? (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

8. UNIX for Dummies Questions & Answers

Bring back removed files

Dear People I have removed some of my files and directories( by using rm and rmdir commands) by mistake. I wish to bring them back. How is it possible?( I am using solaris 2.6) best regards Reza Nazarian:( (2 Replies)
Discussion started by: Reza Nazarian
2 Replies
Login or Register to Ask a Question