Find the answer to your Linux question:
Results 1 to 6 of 6
Hello, I am new to Linux, so forgive me for my questions I have this partition table: DF.jpg I thought the /dev/sda4 is wrongly set so I removed it, but ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2013
    Posts
    2

    Update partition table using fdisk


    Hello, I am new to Linux, so forgive me for my questions

    I have this partition table:

    DF.jpg

    I thought the /dev/sda4 is wrongly set so I removed it, but then after which all other partions sda5, sda6, and sda7 were also removed. Those partitions are where the /var, /home and swap are mounted.

    df-h.jpg

    The partition is like this now:

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 1305 10482381 83 Linux
    /dev/sda2 1306 40468 314576797+ 83 Linux
    /dev/sda3 40469 53522 104856255 83 Linux

    If I reboot the server, the new partition table will take effect, and the /var and /home will be lost.

    Is there a way I can undo, or maybe redo the partition table to have the same as before (before removing /dev/sda4 ?)


    Disk /dev/sda: 896.9 GB, 896998047744 bytes
    255 heads, 63 sectors/track, 109053 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 1305 10482381 83 Linux
    /dev/sda2 1306 40468 314576797+ 83 Linux
    /dev/sda3 40469 53522 104856255 83 Linux
    /dev/sda4 53523 109053 446052757+ 5 Extended
    /dev/sda5 53523 61877 67111506 82 Linux swap / Solaris
    /dev/sda6 61878 68404 52428096 83 Linux
    /dev/sda7 68405 71015 20972826 83 Linux

    Will appreciate your feedback.

    Thanks a lot!

  2. #2
    Linux Newbie
    Join Date
    Jan 2013
    Posts
    116
    Check if the partition information still stored in the Kernel with

    Code:
    cat /proc/partitions
    and create new partitions as exact same size that was first and then mount to their directories.

  3. #3
    Just Joined!
    Join Date
    Jun 2013
    Posts
    2
    Hi NixSavy,

    This is the results:
    Code:
    [root@smpfcdmntrdbdev ~]# cat /proc/partitions
    major minor  #blocks  name
    
       8     0  875974656 sda
       8     1   10482381 sda1
       8     2  314576797 sda2
       8     3  104856255 sda3
       8     4          1 sda4
       8     5   67111506 sda5
       8     6   52428096 sda6
       8     7   52428096 sda7
       8     8   20972826 sda8
    How will I create the new partitions?
    Will appreciate if you specify the steps by steps.
    Thanks.

    Quote Originally Posted by NixSavy View Post
    Check if the partition information still stored in the Kernel with

    Code:
    cat /proc/partitions
    and create new partitions as exact same size that was first and then mount to their directories.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Jan 2013
    Posts
    116
    Your partition was not wrong, 4th partition was extended partition and the others 5th - 8th were the logical partitions. So when you deleted extended partition then the logical partitions also deleted. Partition information still stored in the Kernel, so go ahead with to and create new extended partition with same size and then create other logical partitions with same size that was before delete and then mount with their mount points and check your data should available.

    You can also go though ubuntu-users - need to restore deleted partitions, system still running URL I hope it will help you

  6. #5
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,729
    It looks like I am a bit late and hopefully, OP has recovered partitions.
    Anyways, testdisk is the best tool in that kind of situation. Install testdisk and recover partition table before restart. testdisk is available in sources/repositories of almost all distros.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  7. #6
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    Location
    London, England
    Posts
    471
    As others have mentioned, the extended partition contained the other partitions which you wiped out when you deleted the extended partition. However, if you find yourself in this situation where you've accidentally deleted a partition, then the solution is simple: recreate the partition. The partition may no longer exist, but the filesystem and the data on the disk do; if you recreate your partitions exactly as they were -- without a single byte of difference -- then you'll be able to mount the contained filesystem.

    I created 2 logical partitions in an extended partition, which I felt would be a suitable example. Each of these partitions then had files put on to it and had their MD5 hashes taken to verify the data once the partitions were recovered. Note that the new partitions are exactly as they were when I started.

    Code:
    root@wintermute # fdisk /dev/sdc
    
    Command (m for help): p
    
    Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
    81 heads, 63 sectors/track, 382818 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1            2048  1953525167   976761560    5  Extended
    /dev/sdc5            4096     8392703     4194304   83  Linux
    /dev/sdc6         8394752    29366271    10485760   83  Linux
    
    Command (m for help): d
    Partition number (1-6): 1
    Partition 1 is deleted
    
    Command (m for help): w
    
    --------------------------------------------------------------------------------
    
    root@wintermute # fdisk -l /dev/sdc
    
    Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
    255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
       Device Boot      Start         End      Blocks   Id  System
    
    --------------------------------------------------------------------------------
    
    root@wintermute # fdisk /dev/sdc
    
    Command (m for help): n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): e
    Partition number (1-4, default 1): 
    Using default value 1
    First sector (2048-1953525167, default 2048): 
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-1953525167, default 1953525167): 
    Using default value 1953525167
    Partition 1 of type Extended and of size 931.5 GiB is set
    
    Command (m for help): n
    Partition type:
       p   primary (0 primary, 1 extended, 3 free)
       l   logical (numbered from 5)
    Select (default p): l
    Adding logical partition 5
    First sector (4096-1953525167, default 4096): 
    Using default value 4096
    Last sector, +sectors or +size{K,M,G} (4096-1953525167, default 1953525167): +4G
    Partition 5 of type Linux and of size 4 GiB is set
    
    Command (m for help): n
    Partition type:
       p   primary (0 primary, 1 extended, 3 free)
       l   logical (numbered from 5)
    Select (default p): l
    Adding logical partition 6
    First sector (8394752-1953525167, default 8394752): 
    Using default value 8394752
    Last sector, +sectors or +size{K,M,G} (8394752-1953525167, default 1953525167): +10G
    Partition 6 of type Linux and of size 10 GiB is set
    
    Command (m for help): w
    
    --------------------------------------------------------------------------------
    
    root@wintermute # fdisk -l /dev/sdc
    
    Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
    81 heads, 63 sectors/track, 382818 cylinders, total 1953525168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1            2048  1953525167   976761560    5  Extended
    /dev/sdc5            4096     8392703     4194304   83  Linux
    /dev/sdc6         8394752    29366271    10485760   83  Linux
    
    --------------------------------------------------------------------------------
    
    root@wintermute # mount /dev/sdc5 /mnt
    root@wintermute # cd /mnt
    root@wintermute # ls
    513.full.pdf  Almanac-Issue5.pdf		    Linux-101-Hacks.pdf			    Triplehorn.pdf  md5sum.txt
    54ovr.pdf     Fiber.Optics.Technician's.Manual.pdf  O_Reilly - Cisco IOS in a Nutshell.pdf  lost+found	    netattacks.pdf
    root@wintermute # md5sum -c md5sum.txt 
    513.full.pdf: OK
    54ovr.pdf: OK
    Almanac-Issue5.pdf: OK
    Fiber.Optics.Technician's.Manual.pdf: OK
    Linux-101-Hacks.pdf: OK
    O_Reilly - Cisco IOS in a Nutshell.pdf: OK
    Triplehorn.pdf: OK
    netattacks.pdf: OK
    root@wintermute # cd
    root@wintermute # umount /mnt
    
    root@wintermute # mount /dev/sdc6 /mnt
    root@wintermute # cd /mnt
    root@wintermute # ls
    2801258077.png	   beauty_and_the_beast_mgs4.png  ethernetlan.png  ipheader.png    lost+found  networknumbers.png  screenshot-today.png  subnet-e1361645334184.png
    batteryscript.png  beauty_and_the_beast_unit.png   ipv6header.png  md5sum.txt  sXIGx.png	   screenshot.png	 vlantrunks.png
    root@wintermute # md5sum -c md5sum.txt 
    2801258077.png: OK
    batteryscript.png: OK
    beauty_and_the_beast_mgs4.png: OK
    beauty_and_the_beast_unit.png: OK
    ethernetlan.png: OK
    ipheader.png: OK
    ipv6header.png: OK
    networknumbers.png: OK
    sXIGx.png: OK
    screenshot-today.png: OK
    screenshot.png: OK
    subnet-e1361645334184.png: OK
    vlantrunks.png: OK

Posting Permissions

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