How to resurrect my /home partition

Hi. I’ve just installed a new openSUSE 11.1 on a new / root partition and a new /home partition. I kept the old / root and /home partitions.

Through some accident I’ve lost the old /home partition and I badly want it back. The missing partition is shown in the screenshot of Gparted, as the “unalloacted” 19.99 Gb space between sda5 and sda6. It used to be my old /home partition and it used to occupy sda6. Then it fell off the file table and all the partition numbers changed and the drive was unbootable – a mess, but now I can at least boot into the new install of openSUSE and can see the wreckage of the old sda6 as “unallocated”.

http://opensuse.swerdna.org/forumpics/shot1.png

So the question is “how to put the unallocated 19.99 Gb portion back into the file table as an ext3 partition so I can rescue the data”?

Thanks
swerdna

Use fdisk and assign it a partition number that covers exactly the blocks occupied by that area, and set the type to Linux. Then you can mount it. It doesn’t matter if the partitions are not in order of increasing block number. You might get a warning from fdisk, that’s all.

deleted, too risky

Or better yet, here’s fdisk. What would be the correct CLI command to do the job? I don’t want to practice at this stage because the data are too important.


suse111g:/home/john # fdisk -l

Disk /dev/sda: 163.9 GB, 163928604672 bytes
255 heads, 63 sectors/track, 19929 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x12911290

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          64      514048+   6  FAT16
/dev/sda2              65        1370    10490445   83  Linux
/dev/sda3            1371        3825    19719787+  83  Linux
/dev/sda4   *        3826       19008   121957447+   f  W95 Ext'd (LBA)
/dev/sda5            3826        4081     2048287   82  Linux swap / Solaris
/dev/sda6            6691        9301    20972826   83  Linux
/dev/sda7            9302       11912    20972826   83  Linux
/dev/sda8           11913       14523    20972826   83  Linux

if that does not work try this. TestDisk - CGSecurity
It has saved my data in the past

Work out the start and end tracks (my guess is 4082,6690), then use the n command to create a new partition (will be inside extended), giving it the start and end tracks, then use the t command to set the type to Linux. If it works, you can mount it RO. It doesn’t destroy anything at this point, only if you write to the partition is any change made to the data. fdisk only works on the partition table, not on the data.

Exactly as ken_yap says. Do not forget the w command to write to disk and exit.

fdisk is realy the best for this. Works on all Unixes/Linux.

OK, that went well, sort of. I now have the lost space as a Linux type 83 by using fdisk with the “n” to create. It asked me a bunch of questions and default allocated the unallocated space to sda9. Spo here’s the fdisk entry for sda:

Disk /dev/sda: 163.9 GB, 163928604672 bytes
255 heads, 63 sectors/track, 19929 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x12911290

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          64      514048+   6  FAT16
/dev/sda2              65        1370    10490445   83  Linux
/dev/sda3            1371        3825    19719787+  83  Linux
/dev/sda4   *        3826       19008   121957447+   f  W95 Ext'd (LBA)
/dev/sda5            3826        4081     2048287   82  Linux swap / Solaris
/dev/sda6            6691        9301    20972826   83  Linux
/dev/sda7            9302       11912    20972826   83  Linux
/dev/sda8           11913       14523    20972826   83  Linux
/dev/sda9            4082        6690    20956761   83  Linux

When I try to mount the partition I get this error message:

suse111g:/home/john # mount -t ext3 -o ro /dev/sda9 /mnt/sda9

mount: wrong fs type, bad option, bad superblock on /dev/sda9,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

dmesg | tail then says this:

VFS: Can’t find ext3 filesystem on dev sda9.

What’s the go now, any ideas?

The next step will be to try a file check. Since the superblock is reported as being bad, you may need to try alternative superblock like this:

e2fsck -b 8193 /dev/sda9

However as the manpage mentions, the blocksize determines the required offset values, so this needs to be determined first.

For filesystems with 1k blocksizes, a backup superblock can be found at block
8193; for filesystems with 2k blocksizes, at block 16384; and for 4k blocksizes, at
block 32768.

A simple way to get the superblock positions for your device partition is to use

mke2fs -n /dev/sda9

This will just ‘fake’ the creation of the file system, without actually writing anything, but the superblock positions (and other parameters) will be reported. It will probably be like this with 4kb block size:

Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Then you should be able to use the e2fsck command with one of these alternative superblocks.

Thanks. I got this:

suse111g:/home/john # mke2fs -n /dev/sda9
mke2fs 1.41.1 (01-Sep-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 5239190 blocks
261959 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

So I ran this:

suse111g:/home/john # e2fsck -b 32768 /dev/sda9
e2fsck 1.41.1 (01-Sep-2008)
e2fsck: Bad magic number in super-block while trying to open /dev/sda9

The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>

and similarly for 98304. Do I proceed and do it again and again with the others (163840 etc…)?

I would. Its worth a go.

It might also be a good idea to backup whatever data is on this parition if you can with

dd if=/dev/sda9 of=/<usb deivce or large similar>/data

*Make sure backup device partition is big enough to do the job of course.

Thanks guys I tried the esfsck for various superblocks. No luck. So next I tried tom_enos’s suggestion: testdisk (which is in the openSUSE 11.1 repos). testdisk could find no superblocks but it did find the files and I was able to copy out the important work I’d been doing recently from working directories on the old Desktop.

So thanks one and all. Saved again!

What I suspect happened is that the partition used to start lower down the disk and the initial blocks have been overwritten. Perhaps by the extended partition header or something else. So really the rescue you did was the only way out.

This happened because I wanted to burn a copy of openSUSE DVD. But on my new install I ran into the “DVD won’t work for users” bug. OK I hunted that down and fixed it. Then I got the message that Brasero wouldn’t copy the DVD because of copyright? So I installed stuff by the “restricted formats” howto. Still some problem or other. So I booted up my windowsxp partition to use the commercial nero burning software. That gave “not enough disk space” for the temporary iso image.

So here came the damage: I made a 10 Gb NTFS partition at the end of the drive temporarily, burned the DVD copy, and then deleted the partition. That microsoft process had somehow knocked out my old sda6 home partition.

So brickbats to Novell and their policy of crippling their multimedia software. And brickbats to microsoft for their partitioner that takes liberties.

Yeah, too bad about the DVD permission breakage. It’s one of the annoying things about 11.1. I’m puzzled that brasero gave that message though.

This is one of the never-ending disaster stories.

I have all the important data forensically restored from tha bad partition, plus also nicely backed up on a fresh /dev/sdc that I installed alongside my other drives. And a cron job and script to re-backup the important data regularly.

Quite proud of myself really for doing the automation and making sure disaster doesn’t strike again.

AND THEN I get a message from the Smart drive monitoring utilty that the newly installed /dev/sdc is failing. So I rescue tha data again and replace the drive again! It doesn’t seem to end rotfl!

Buy yourself a lottery ticket :slight_smile:

i actually believe there is a problem with the S.M.A.R.T. stuff (a
conspiracy of hardware sellers perhaps??)

i say that because i have been getting scary popups like:

Your hard disk drive is failing. S.M.A.R.T. message: Device :
/dev/sda, 4294967294 [Currently unreadable (pending) sectors | Offline
uncorrectable sectors]

been getting the above for weeks (while the smart docs say to expect
failure within 24 hours of notice)…yet if i “sudo smartctl -a
/dev/sda” all is well…


brassy

Well, I packed us off to the gold coast casino for the night, based on your recommendation :wink:
Conrad Jupiters Website - Home
A fine meal, invest some funds and wait for the return, and in-house movie, breakfast by the sea, shopping at the village at HarbourTown – that will help me get over the trauma!