LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help deleting old partitions (https://www.linuxquestions.org/questions/linux-newbie-8/help-deleting-old-partitions-4175647189/)

zavmat 01-29-2019 12:00 AM

Help deleting old partitions
 
I have a partition using up 200gb for an outdated kernal. I'm trying to delete it with fdisk but I'm having some trouble. As the thread suggests I'm a total noob to linux. My disk is partitioned into at least five other useless sections and I'm trying to make it all sane again.

Don't get me wrong, I've been enjoying all the craziness, it makes me appreciate my laptop a lot more than I used to. When I was younger I messed around with installing open source bios' on old 3rd party mp3 players that my Dad tortured my sister with (First world problems am I right?). That experience opened my eyes to alternatives to big name brands like Apple and Microsoft that operate with business models that encourages users NOT to learn.

But enough of my life story, let's take a look at the data shall we?

Code:

[madmin@localhost ~]$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Partition number (1-14, default 14): 9

Partition 9 has been deleted.

Command (m for help): sudo fdisk -l
Created a new partition 1 of type 'Linux native' and of size 698.6 GiB.
Created a new partition 2 of type 'Linux swap' and of size 47.1 MiB.
Created a new partition 3 of type 'Whole disk' and of size 698.7 GiB.
Created a new Sun disklabel.
The old gpt signature will be removed by a write command.

Command (m for help):


Command (m for help): m

Help:

  Sun
  a  toggle the read-only flag
  c  toggle the mountable flag

  Generic
  d  delete a partition
  F  list free unpartitioned space
  l  list known partition types
  n  add a new partition
  p  print the partition table
  t  change a partition type
  v  verify the partition table
  i  print information about a partition

  Misc
  m  print this menu
  u  change display/entry units
  x  extra functionality (experts only)

  Script
  I  load disk layout from sfdisk script file
  O  dump disk layout to sfdisk script file

  Save & Exit
  w  write table to disk and exit
  q  quit without saving changes

  Create a new label
  g  create a new empty GPT partition table
  G  create a new empty SGI (IRIX) partition table
  o  create a new empty DOS partition table
  s  create a new empty Sun partition table


Command (m for help): w

The partition table has been altered.
Failed to remove partition 1 from system: Device or resource busy
Failed to remove partition 12 from system: Device or resource busy
Failed to remove partition 13 from system: Device or resource busy
Failed to remove partition 14 from system: Device or resource busy
Failed to add partition 1 to system: Device or resource busy
Failed to add partition 3 to system: Device or resource busy

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.


Brains 01-29-2019 12:10 AM

Quote:

The old gpt signature will be removed by a write command
You need to use Gdisk with GPT drives, not fdisk

mrmazda 01-29-2019 03:26 AM

not fdisk - check
need gdisk - nope
need any partitioning tool that supports gpt - yes, e.g.
PHP Code:

cfdisk
cgdisk
dfsee
gparted
parted
ranish
sfdisk
sgdisk 

and more. Some are available for multiple operating systems using the same interface.

Distro installers commonly incorporate some variation of parted, which is also the basis of gparted, which operates from its own bootable media.

fatmac 01-29-2019 04:57 AM

Just curious, why a sun disklabel(?), if you're having Linux partitions.

Quote:

Created a new Sun disklabel.
The old gpt signature will be removed by a write command.

rknichols 01-29-2019 09:39 AM

Quote:

Originally Posted by zavmat (Post 5954807)
Code:

[madmin@localhost ~]$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
Partition number (1-14, default 14): 9

Partition 9 has been deleted.

Command (m for help): sudo fdisk -l
Created a new partition 1 of type 'Linux native' and of size 698.6 GiB.
Created a new partition 2 of type 'Linux swap' and of size 47.1 MiB.
Created a new partition 3 of type 'Whole disk' and of size 698.7 GiB.
Created a new Sun disklabel.
The old gpt signature will be removed by a write command.


NO, NO, NO!!
When you entered that command shown in red you were already within the fdisk utility, and it interpreted that whole string as some sequence of internal commands. You have now thoroughly scrambled your partition table and have written that scrambled table to the disk. The only reason your system is still running is because the kernel is still using the old table. You will not be able to reboot.

Before doing anything else, run
Code:

cat /proc/partitions
cat /sys/block/sda/sda*/start

and post the result. That will provide information to help in reconstructing the old partitioning.

Reference: https://unix.stackexchange.com/quest...ble-of-dev-sda

dc.901 01-29-2019 11:17 AM

In addition to what rknichols has (in #5), you are trying this on /dev/sda, which is usually what the OS is booted of (this is true a lot of times but perhaps not always).
Are the partitions you are trying to remove on same disk drive OS is running from, or do you have another hard drive in your computer that you are trying to do this on?

zavmat 01-29-2019 01:09 PM

you're right I cannot reboot... i'm sitting at the grub command menu from my live usb as we speak. Keep in mind this is an experimental machine. Is my windows os still safe? I don't have any reclaimable space to install another fedora kernal

rknichols 01-29-2019 01:40 PM

What distribution is on that live USB? What you need now is a bootable medium that includes the testdisk utility, which is the tool of choice for recovering lost partitions.

@dc.901: This is a laptop, which almost certainly has only one disk.

zavmat 01-29-2019 01:43 PM

Fedora 29, I'm booted to the live disk right now

rknichols 01-29-2019 02:04 PM

Quote:

Originally Posted by zavmat (Post 5955093)
Fedora 29, I'm booted to the live disk right now

I just downloaded and booted Fedora 29 Workstation Live, and it does not appear to include testdisk, but that package is available and can be installed. Go ahead and boot that USB drive and select "Try Fedora" from the menu. bring up a terminal and run "su -" to get a root shell (no password needed on the live ISO). From there, once networking is available, you can run "dnf install testdisk".

Further instructions coming once you've done that.

zavmat 01-29-2019 02:17 PM

Error

Code:

[liveuser@localhost ~]$ su -
[root@localhost-live ~]# dnf install testdisk
Fedora Modular 29 - x86_64                      267 kB/s | 1.5 MB    00:05   
Fedora Modular 29 - x86_64 - Updates            2.6 kB/s | 3.4 kB    00:01   
Error: Failed to synchronize cache for repo 'updates-modular'
[root@localhost-live ~]#


rknichols 01-29-2019 02:33 PM

Do you have networking? What is the result from "ping -c1 mirrors.fedoraproject.org" ?

zavmat 01-29-2019 02:54 PM

[root@localhost-live ~]# ping -cl mirrors.fedoraproject.org
ping: bad number of packets to transmit.

rknichols 01-29-2019 02:57 PM

Quote:

Originally Posted by zavmat (Post 5955131)
[root@localhost-live ~]# ping -cl mirrors.fedoraproject.org
ping: bad number of packets to transmit.

That's a digit "1".

zavmat 01-29-2019 03:00 PM

oops my mistate

Code:

[root@localhost-live ~]# ping c1 mirrors.fedoraproject.org
PING  (104.239.198.84) 56(124) bytes of data.

It's connected to the network

Code:

[root@localhost-live ~]# ping c1 mirrors.fedoraproject.org
PING  (104.239.198.84) 56(124) bytes of data.
^C
---  ping statistics ---
420 packets transmitted, 0 received, 100% packet loss, time 461ms

That would suggest it isn't able to reach the download source though, but I'm typing this from the laptop in question

Edit: it's downloading now.


All times are GMT -5. The time now is 11:59 PM.