Find the answer to your Linux question:
Results 1 to 9 of 9
Hello all, I have attempted a resize of my /home partition and root partition using GParted form the PartedMagic live CD, but half way GParted crashed. I've got my /home ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User Daan's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    323

    Unhappy Restore Debian Lenny after failed partion resize?


    Hello all,

    I have attempted a resize of my /home partition and root partition using GParted form the PartedMagic live CD, but half way GParted crashed. I've got my /home backed up, so no there's no irreplaceable data lost, however, I would like to keep my root partition as it saves me time if I can restore it. Now, when I am in PartedMagic, GParted shows the two Linux partitions at /dev/sda7 (root) and /dev/sda5 (/home). I can mount them too.
    Code:
    root@PartedMagic:/# cat etc/mtab  
    tmpfs / tmpfs rw,size=180M 0 0
    /dev/sda7 /usr/media/disk ext3 rw,nosuid,nodev,uhelper=hal 0 0
    /dev/sda5 /usr/media/disk-1 ext3 rw,nosuid,nodev,uhelper=hal 0 0
    The contents of /dev/sda7 looks ok:
    Code:
    root@PartedMagic:/# ls /usr/media/disk 
    bin/            initrd.img@     opt/            sys/
    boot/           initrd.img.old@ proc/           tmp/
    cdrom@          lib/            root/           usr/
    dev/            lost+found/     sbin/           var/
    etc/            media/          selinux/        vmlinuz@
    home/           mnt/            srv/            vmlinuz.old@
    The /dev/sda5 looks messed up. The home directories of the users (and one other) look like files in stead of directories
    Code:
    root@PartedMagic:/# ls /usr/media/disk-1/ -l -h
    ?r-S-----T 6927 58840597 -8946045     2.0G Aug  9  1951 daan
    ?--x--S--- 42124 15291168 98207935     3.8G Feb 12  1971 dreedle
    drwx------    2 root     root         4.0k Dec 21 20:43 lost+found/
    ?rw----r-x 28124 -2068650 -1581063     3.1G May  3  1976 old_ubuntu_root_directory
    root@PartedMagic:/# file /usr/media/disk-1/daan
    /usr/media/disk-1/daan: ERROR: setuid sticky invalid mode 0165400
    Even with the messed up /home I would say I can log in in safe mode as root in my Debian Lenny that is on /dev/sda7. I tried that, but GRUB did not give a menu and gave me "Error 22" in stead. Back in PartedMagic, I ran grub:
    Code:
        GNU GRUB  version 0.97  (640K lower / 3072K upper memory)
    
     [ Minimal BASH-like line editing is supported.  For the first word, TAB
       lists possible command completions.  Anywhere else TAB lists the possible
       completions of a device/filename. ]
    
    grub> find /boot/grub/stage1 
     (hd0,6)
    
    grub> root (hd0,6)
     Filesystem type is ext2fs, partition type 0x83
    
    grub> setup (hd0)
     Checking if "/boot/grub/stage1" exists... yes
     Checking if "/boot/grub/stage2" exists... yes
     Checking if "/boot/grub/e2fs_stage1_5" exists... yes
     Running "embed /boot/grub/e2fs_stage1_5 (hd0)"...  17 sectors are embedded.
    succeeded
     Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,6)/boot/grub/stage2 /boot/grub/menu.lst"... succeed
    ed
    Done.
    
    grub>
    Now a reboot and at least I got the GRUB menu. However, when I chose the Debian safe mode entry I got error 22, this time with a more specific complaint about that it couldn't find /dev/sda7 !

    I've tried TestDisk. It gives the following after a Analyze
    Code:
    TestDisk 6.11-WIP, Data Recovery Utility, July 2008
    Christophe GRENIER <grenier@cgsecurity.org>
    http://www.cgsecurity.org
    
    Disk /dev/sda - 120 GB / 111 GiB - CHS 14593 255 63
    Current partition structure:
         Partition                  Start        End    Size in sectors
    
     1 * HPFS - NTFS              1   0  1  3409 254 63   54765585
     2 P HPFS - NTFS          13370 179 58 14390  13 23   16375808 [HP_RECOVERY]
     3 P HPFS - NTFS          14390 143 26 14593  33 32    3254272 [OS_TOOLS]
     4 E extended              3410   0  1 13369 254 63  160007400
    Logical partition must not be bootable
     5 L Linux                 5002   0  1 11408 253 63  102928392
       X extended             13092   0  1 13369 254 63    4466070
     6 L Linux Swap           13092   1  1 13369 254 63    4466007
       X extended              3410   0  2  5001 254 63   25575479
     7 L Linux                 3410   2  1  5001 254 63   25575354
    
    
    
    
    *=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
    [Quick Search]  [ Backup ]
                                Try to locate partition
    This looks consistent with what GParted shows, except that there sda5 is shown as being bootable (it used to contain an Ubuntu install, if that matters). After backing up the partition list and continuing with a Quick Search, TestDisk suggests
    Code:
    TestDisk 6.11-WIP, Data Recovery Utility, July 2008
    Christophe GRENIER <grenier@cgsecurity.org>
    http://www.cgsecurity.org
    
    Disk /dev/sda - 120 GB / 111 GiB - CHS 14594 255 63
         Partition               Start        End    Size in sectors
    * HPFS - NTFS              0   1  1  6684   0 52  107378449
    P Linux                 6685   1  1 13091 254 63  102928392
    P Linux Swap           13092   1  1 13369 254 40    4465984
    L HPFS - NTFS          13370 179 58 14390  13 23   16375808 [HP_RECOVERY]
    L HPFS - NTFS          14390 143 26 14593  33 32    3254272 [OS_TOOLS]
    
    
    
    
    
    
    
    
    Structure: Ok.  Use Up/Down Arrow keys to select partition.
    Use Left/Right Arrow keys to CHANGE partition characteristics:
    *=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
    Keys A: add partition, L: load backup, T: change type, P: list files,
         Enter: to continue
    EXT3 Large file Sparse superblock, 52 GB / 49 GiB
    So here there is only one Linux partion (besides the swap). I can browse it with TestDisk, and it contains a mixture of my /home, /, and the / of my old Ubuntu directory. Messy, something I don't want! I can load the backed up partition list, but things dont get better. Partions are listed twice, no thanks.
    Code:
    TestDisk 6.11-WIP, Data Recovery Utility, July 2008
    Christophe GRENIER <grenier@cgsecurity.org>
    http://www.cgsecurity.org
    
    Disk /dev/sda - 120 GB / 111 GiB - CHS 14594 255 63
         Partition               Start        End    Size in sectors
    * HPFS - NTFS              0   1  1  6684   0 52  107378449
    * HPFS - NTFS              1   0  1  3409 254 63   54765585
    L Linux                 3410   2  1  5001 254 63   25575354
    L Linux                 5002   0  1 11408 253 63  102928392
    P Linux                 6685   1  1 13091 254 63  102928392
    P Linux Swap           13092   1  1 13369 254 40    4465984
    L Linux Swap           13092   1  1 13369 254 63    4466007
    L HPFS - NTFS          13370 179 58 14390  13 23   16375808 [HP_RECOVERY]
    L HPFS - NTFS          14390 143 26 14593  33 32    3254272 [OS_TOOLS]
    
    
    
    
    Structure: Bad. Use Up/Down Arrow keys to select partition.
    Use Left/Right Arrow keys to CHANGE partition characteristics:
    *=Primary bootable  P=Primary  L=Logical  E=Extended  D=Deleted
    Keys A: add partition, L: load backup, T: change type, P: list files,
         Enter: to continue
    NTFS, 54 GB / 51 GiB
    I am lost. Does anybody have any advice about how to restore my Debian Lenny?
    OS's I use: Debian testing, Debian stable, Ubuntu, OpenSuse 12.1, Windows 7, Windows Vista, Windows XP

  2. #2
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,042
    My suggestion is chroot into your Debian install using a live CD and then re-run grub from Debian. I found strange things happened with Debian grub ... example here. You may find that the root partition is fine ... just the version of grub will not load it.

    I have also found in the past partition resize which has worked but grub will still not run without being re-setup.

    Ed: I'd abandon the testdisk changes until after the grub re-install. The first part of your post suggested to me the root partition was intact and only grub needed to be fixed.
    It looks as though the home partition resize is the one that failed.

  3. #3
    Linux User Daan's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    323
    This is the first time I used chroot and I'm not sure what it does.

    Code:
    root@PartedMagic:~# chroot /usr/media/disk/
    PartedMagic:/# ls
    bin    dev   initrd.img      lost+found  opt   sbin	sys  var
    boot   etc   initrd.img.old  media	 proc  selinux	tmp  vmlinuz
    cdrom  home  lib	     mnt	 root  srv	usr  vmlinuz.old
    PartedMagic:/# ls /boot/grub/
    default        fat_stage1_5  menu.lst~		stage1
    device.map     jfs_stage1_5  minix_stage1_5	stage2
    e2fs_stage1_5  menu.lst      reiserfs_stage1_5	xfs_stage1_5
    PartedMagic:/# grub
    Probing devices to guess BIOS drives. This may take a long time.
    and

    Code:
        GNU GRUB  version 0.97  (640K lower / 3072K upper memory)
    
           [ Minimal BASH-like line editing is supported.   For
             the   first   word,  TAB  lists  possible  command
             completions.  Anywhere else TAB lists the possible
             completions of a device/filename. ]
    
    grub> find /boot/grub/stage1 
    
    Error 15: File not found
    
    grub>
    Without chroot I still get the (hd0,6), as above.

    I'll try an other live CD and see what happens
    OS's I use: Debian testing, Debian stable, Ubuntu, OpenSuse 12.1, Windows 7, Windows Vista, Windows XP

  4. #4
    Linux User Daan's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    323

    Smile I've been stupid... :)

    OK, so I got GRUB's error message wrong. It says it can't find hd(0,7) when I try too boot Debian. It shouldn't look for that! The correct place is (hd0,6) as we saw above. Using the 'e' option in the GRUB menu and then editing two lines of the entry and then 'b' for boot got me into my Debian.

    Silly me. Well, at least I got introduced to chroot.
    OS's I use: Debian testing, Debian stable, Ubuntu, OpenSuse 12.1, Windows 7, Windows Vista, Windows XP

  5. #5
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,042
    Example chroot for Arch for grub re-install here
    ... sure you get the general idea ...

    If you find the reinstall of grub does not work direct from the live CD then chroot to your Debian install and try from there ...

    Have you got things working again now ?

  6. #6
    Linux User Daan's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    323
    Quote Originally Posted by Jonathan183 View Post
    Have you got things working again now ?
    Well, more or less. I did get to login into my Debian in safe mode. I even got to see the familiar Gnome login screen at some point (but did not login because I did not restore my home directories yet).

    Thing is that the number of my Debian root partition keeps changing, and seems different in different places. This is the menu.lst I used to boot into Debian (I edited with some search&replace actions):

    Code:
    # menu.lst - See: grub(8), info grub, update-grub(8)
    #            grub-install(8), grub-floppy(8),
    #            grub-md5-crypt, /usr/share/doc/grub
    #            and /usr/share/doc/grub-legacy-doc/.
    
    ## default num
    # Set the default entry to the entry number NUM. Numbering starts from 0, and
    # the entry number 0 is the default if the command is not used.
    #
    # You can specify 'saved' instead of a number. In this case, the default entry
    # is the entry saved with the command 'savedefault'.
    # WARNING: If you are using dmraid do not change this entry to 'saved' or your
    # array will desync and will not let you boot your system.
    default		0
    
    ## timeout sec
    # Set a timeout, in SEC seconds, before automatically booting the default entry
    # (normally the first entry defined).
    timeout		5
    
    # Pretty colours
    color cyan/blue white/blue
    
    ## password ['--md5'] passwd
    # If used in the first section of a menu file, disable all interactive editing
    # control (menu entry editor and command-line)  and entries protected by the
    # command 'lock'
    # e.g. password topsecret
    #      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
    # password topsecret
    
    #
    # examples
    #
    # title		Windows 95/98/NT/2000
    # root		(hd0,0)
    # makeactive
    # chainloader	+1
    #
    # title		Linux
    # root		(hd0,1)
    # kernel	/vmlinuz root=/dev/hda2 ro
    #
    
    #
    # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST
    
    ### BEGIN AUTOMAGIC KERNELS LIST
    ## lines between the AUTOMAGIC KERNELS LIST markers will be modified
    ## by the debian update-grub script except for the default options below
    
    ## DO NOT UNCOMMENT THEM, Just edit them to your needs
    
    ## ## Start Default Options ##
    ## default kernel options
    ## default kernel options for automagic boot options
    ## If you want special options for specific kernels use kopt_x_y_z
    ## where x.y.z is kernel version. Minor versions can be omitted.
    ## e.g. kopt=root=/dev/hda1 ro
    ##      kopt_2_6_8=root=/dev/hdc1 ro
    ##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
    # kopt=root=/dev/sda6 ro
    
    ## default grub root device
    ## e.g. groot=(hd0,0)
    # groot=(hd0,5)
    
    ## should update-grub create alternative automagic boot options
    ## e.g. alternative=true
    ##      alternative=false
    # alternative=true
    
    ## should update-grub lock alternative automagic boot options
    ## e.g. lockalternative=true
    ##      lockalternative=false
    # lockalternative=false
    
    ## additional options to use with the default boot option, but not with the
    ## alternatives
    ## e.g. defoptions=vga=791 resume=/dev/hda5
    # defoptions=quiet
    
    ## should update-grub lock old automagic boot options
    ## e.g. lockold=false
    ##      lockold=true
    # lockold=false
    
    ## Xen hypervisor options to use with the default Xen boot option
    # xenhopt=
    
    ## Xen Linux kernel options to use with the default Xen boot option
    # xenkopt=console=tty0
    
    ## altoption boot targets option
    ## multiple altoptions lines are allowed
    ## e.g. altoptions=(extra menu suffix) extra boot options
    ##      altoptions=(single-user) single
    # altoptions=(single-user mode) single
    
    ## controls how many kernels should be put into the menu.lst
    ## only counts the first occurence of a kernel, not the
    ## alternative kernel options
    ## e.g. howmany=all
    ##      howmany=7
    # howmany=all
    
    ## should update-grub create memtest86 boot option
    ## e.g. memtest86=true
    ##      memtest86=false
    # memtest86=true
    
    ## should update-grub adjust the value of the default booted system
    ## can be true or false
    # updatedefaultentry=false
    
    ## should update-grub add savedefault to the default options
    ## can be true or false
    # savedefault=false
    
    ## ## End Default Options ##
    
    title		Debian GNU/Linux, kernel 2.6.26-1-686
    root		(hd0,5)
    kernel		/boot/vmlinuz-2.6.26-1-686 root=/dev/sda6 ro quiet
    initrd		/boot/initrd.img-2.6.26-1-686
    
    title		Debian GNU/Linux, kernel 2.6.26-1-686 (single-user mode)
    root		(hd0,5)
    kernel		/boot/vmlinuz-2.6.26-1-686 root=/dev/sda6 ro single
    initrd		/boot/initrd.img-2.6.26-1-686
    
    title		Debian GNU/Linux, kernel 2.6.26-1-486
    root		(hd0,5)
    kernel		/boot/vmlinuz-2.6.26-1-486 root=/dev/sda6 ro quiet
    initrd		/boot/initrd.img-2.6.26-1-486
    
    title		Debian GNU/Linux, kernel 2.6.26-1-486 (single-user mode)
    root		(hd0,5)
    kernel		/boot/vmlinuz-2.6.26-1-486 root=/dev/sda6 ro single
    initrd		/boot/initrd.img-2.6.26-1-486
    
    title		Debian GNU/Linux, kernel 2.6.24-1-686
    root		(hd0,5)
    kernel		/boot/vmlinuz-2.6.24-1-686 root=/dev/sda6 ro quiet
    initrd		/boot/initrd.img-2.6.24-1-686
    
    title		Debian GNU/Linux, kernel 2.6.24-1-686 (single-user mode)
    root		(hd0,5)
    kernel		/boot/vmlinuz-2.6.24-1-686 root=/dev/sda6 ro single
    initrd		/boot/initrd.img-2.6.24-1-686
    
    ### END DEBIAN AUTOMAGIC KERNELS LIST
    
    # This is a divider, added to separate the menu items below from the Debian
    # ones.
    title		Other operating systems:
    root
    
    
    # This entry automatically added by the Debian installer for a non-linux OS
    # on /dev/sda1
    title		Windows Vista Business
    root		(hd0,0)
    savedefault
    makeactive
    chainloader	+1
    
    
    ## This entry automatically added by the Debian installer for a non-linux OS
    ## on /dev/sda2
    #title		HP Recovery
    #root		(hd0,1)
    #savedefault
    #makeactive
    #chainloader	+1
    So that is (hd0,5) or sda6. I hope it will stay as it is now!

    Booting into Debian gives a serious error message about a corrupt superblock on /dev/sda5. I got the suggestion to run e2fsck -b 8193 <device> but doing that just gives the same error message.
    Code:
    root@PartedMagic:~# cat /media/disk/var/log/fsck/checkfs 
    Log of fsck -C -R -A -a 
    Tue Dec 23 01:39:08 2008
    
    fsck 1.41.3 (12-Oct-2008)
    fsck.ext3: Bad magic number in super-block while trying to open /dev/sda5
    /dev/sda5: 
    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>
    
    fsck died with exit status 8
    
    Tue Dec 23 01:39:08 2008
    ----------------
    It says ext2, whereas it is ex3, does that matter?

    I think I can just copy my home directories to my new home partition and it will work, but I dont like this corrupted bad superblock business...

    BTW, thanks for your support, Jonathan!
    OS's I use: Debian testing, Debian stable, Ubuntu, OpenSuse 12.1, Windows 7, Windows Vista, Windows XP

  7. #7
    Linux User Daan's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    323

    Talking Oops...

    OK, sda5 is my swap. I did not update my /etc/fstab yet and that caused the trouble.
    OS's I use: Debian testing, Debian stable, Ubuntu, OpenSuse 12.1, Windows 7, Windows Vista, Windows XP

  8. #8
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    3,042
    I'm guessing you got things sorted now ... without fdisk -l output we would not have know partition structure so its as well you spotted the problem

  9. #9
    Linux User Daan's Avatar
    Join Date
    Aug 2005
    Location
    The Netherlands
    Posts
    323
    Yes, everything is working smoothly as before, with the partition resized as I wanted. What a hassle...

    I never realized that the OS uses fstab for so many things. I would say that when it boots, it knows at least where the root partition is! And he output of the file system checker was just a bit confusing. Made me think there actually was something corrupted.

    But now I know. I just hope somebody else runs into the same problems so that I can help them on these forums.
    OS's I use: Debian testing, Debian stable, Ubuntu, OpenSuse 12.1, Windows 7, Windows Vista, Windows XP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •