LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-30-2016, 08:45 AM   #1
bangorme
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Rep: Reputation: Disabled
Reformatting LVM partitions


I'm trying to recover a bricked Fedora upgrade. fdisk -l from rescue gives me this (in part):

Quote:
Disk /dev/mapper/vg_cpe--76--178--212--156-lv_root
Disk /dev/mapper/vg_cpe--76--178--212--156-lv_home
Disk /dev/mapper/vg_cpe--76--178--212--156-lv_swap
I want to format everything but the /home portion. What would be the command for accomplishing this? BTW, this is an LVM partition.

Thanks.
 
Old 06-30-2016, 09:02 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Pretty poor post with minimal detail.

In such circumstances, the appropriate answer would appear to be "mkfs".
 
Old 06-30-2016, 04:43 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
Hello and welcome to LQ.

Not sure I'd play too much with fdisk and for sure not trying to fix a system from rescue but formatting.

I might be tempted to first remove/copy /home off using a live media. Then install as you wish.

It may be possible that some distro's know that you want to upgrade and it may try to keep /home correctly.

If you want to save data then make a backup now.
 
Old 07-01-2016, 12:14 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by bangorme View Post
I'm trying to recover a bricked Fedora upgrade. fdisk -l from rescue gives me this (in part):
Code:
Disk /dev/mapper/vg_cpe--76--178--212--156-lv_root
Disk /dev/mapper/vg_cpe--76--178--212--156-lv_home
Disk /dev/mapper/vg_cpe--76--178--212--156-lv_swap
I want to format everything but the /home portion. What would be the command for accomplishing this? BTW, this is an LVM partition.
Looks like LVM, yes. Do you see the volume group? The vgs command should show it. Let's assume you do see it.

Do you want to reformat the logical volumes or do you want to remove them?
In the former case, mkfs <volume name as above>
In the latter case, lvremove <volume name as above>. Then you can use the space that was freed for other things.

Alternative: Mount the home volume, backup everything on it, and repurpose the entire disk, for example pvcreate -ff (from memory).
 
Old 07-01-2016, 10:02 AM   #5
bangorme
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
Looks like LVM, yes. Do you see the volume group? The vgs command should show it. Let's assume you do see it.

Do you want to reformat the logical volumes or do you want to remove them?
In the former case, mkfs <volume name as above>
In the latter case, lvremove <volume name as above>. Then you can use the space that was freed for other things.

Alternative: Mount the home volume, backup everything on it, and repurpose the entire disk, for example pvcreate -ff (from memory).
Thanks. So would this be the proper command if I I wanted to format the /root section?

Quote:
mkfs -t ext4 /dev/mapper/vg_cpe--76--178--212--156-lv_root
Or, do I have to format/remove the entire group using the group number (vg_cpe-76-178-212-156)? If I have to remove the entire group, then we're talking a fresh install.
 
Old 07-01-2016, 10:46 AM   #6
bangorme
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
Hello and welcome to LQ.

Not sure I'd play too much with fdisk and for sure not trying to fix a system from rescue but formatting.

I might be tempted to first remove/copy /home off using a live media. Then install as you wish.

It may be possible that some distro's know that you want to upgrade and it may try to keep /home correctly.

If you want to save data then make a backup now.
The Fedora distribution seems to be broken when trying to rescue, particularly LVM partitions. It is supposed to (according to the Fedora documentation) allow you to install over the old /root from the live media. However, all it does is try to use free space in the partition to create another one to install on.

BTW, the problem occurred when updating from Fedora 23 to 24. The kernel is 4.55-300.fc24.x86_64.
 
Old 07-01-2016, 06:48 PM   #7
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,980

Rep: Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624Reputation: 3624
I see I assumed too much. You really did mean format.

A few linux distro's make it kind of a hassle to install over a broken system I agree. You end up having to get rid of the old install fully sometimes.
 
Old 07-01-2016, 08:16 PM   #8
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
If you simply want to get rid of the LVM structures on that disk, try
Code:
pvremove -ff /dev/whateverdevice
where whateverdevice is the disk device on which your logical volumes reside. Something like /dev/sdc1. If you don't know what it might be, use lsblk to find out. For example:
Code:
$ lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0 53.3G  0 disk
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 52.8G  0 part
  ├─centos-root 253:0    0 33.3G  0 lvm  /
  ├─centos-swap 253:1    0  3.1G  0 lvm  [SWAP]
  └─centos-home 253:2    0 16.3G  0 lvm  /home
sr0              11:0    1 1024M  0 rom
shows that logical volumes centos-root, centos-swap and centos-home are on /dev/sda2.

Note that the -ff option is dangerous: If you provide the wrong device, you risk destroying important data.
 
Old 07-01-2016, 09:58 PM   #9
bangorme
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
If you simply want to get rid of the LVM structures on that disk, try
Code:
pvremove -ff /dev/whateverdevice
where whateverdevice is the disk device on which your logical volumes reside. Something like /dev/sdc1. If you don't know what it might be, use lsblk to find out. For example:
Code:
$ lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0 53.3G  0 disk
├─sda1            8:1    0  500M  0 part /boot
└─sda2            8:2    0 52.8G  0 part
  ├─centos-root 253:0    0 33.3G  0 lvm  /
  ├─centos-swap 253:1    0  3.1G  0 lvm  [SWAP]
  └─centos-home 253:2    0 16.3G  0 lvm  /home
sr0              11:0    1 1024M  0 rom
shows that logical volumes centos-root, centos-swap and centos-home are on /dev/sda2.

Note that the -ff option is dangerous: If you provide the wrong device, you risk destroying important data.
So in your example, would you have to remove all of sda2, or could you just remove centos-root?
 
Old 07-01-2016, 10:47 PM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by bangorme View Post
The Fedora distribution seems to be broken when trying to rescue, particularly LVM partitions. It is supposed to (according to the Fedora documentation) allow you to install over the old /root from the live media. However, all it does is try to use free space in the partition to create another one to install on.
Very unlikely. More likely you don't understand the process, which admittedly isn't that intuitive.
I just tested F21 install (all I had handy) on a Mint 17 machine that had root and swap on LVM in a LUKS container. Anaconda found the separate EFI and /boot standard partitions as well as an "Unknown". Expanding the "Unknown" showed the LUKS container which it requested the passphrase for. From there I was able to resize both root and swap - note I couldn't rename the vg or lv; probably because they were active. No big deal for me as I wasn't proceeding with the install - but the re-partitioning was accepted.
 
Old 07-02-2016, 07:26 AM   #11
bangorme
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Very unlikely. More likely you don't understand the process, which admittedly isn't that intuitive.
I just tested F21 install (all I had handy) on a Mint 17 machine that had root and swap on LVM in a LUKS container. Anaconda found the separate EFI and /boot standard partitions as well as an "Unknown". Expanding the "Unknown" showed the LUKS container which it requested the passphrase for. From there I was able to resize both root and swap - note I couldn't rename the vg or lv; probably because they were active. No big deal for me as I wasn't proceeding with the install - but the re-partitioning was accepted.
Well, then please go over to the Fedora thread I've got going and resolve it within Anaconda. So far, no one there has been able to figure it out and the documentation hasn't even been written yet for this feature. But I'm not interested in Anaconda here, I'm looking for a generic Linux solution.
 
Old 07-02-2016, 07:39 AM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Quote:
Originally Posted by bangorme View Post
But I'm not interested in Anaconda here, I'm looking for a generic Linux solution.
Hmmm - interesting attitude for a Fedora (re-)install. Maybe you should do more testing, rather than me/us.
I had already seen your fedoraforum post.
 
Old 07-02-2016, 09:29 AM   #13
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
I had no problem making the Fedora 24 installer reformat the swap and root LVs while leaving home alone.
  1. On the INSTALLATION DESTINATION screen, select "I will configure partitioning", then click on "Done".
  2. On the MANUAL PARTIONING screen, below where it says "Or, assign new mount points to existing partitions after selecting them below," click on the "Fedora Linux ..." partition.
  3. Select /home, set the mount point as "/home".
  4. Select /, set the mount point to "/" and put a tic in "Reformat".
  5. Select swap, put a tic mark in "Reformat", then click on "Update Settings"
  6. Click on "Done".
  7. In the "SUMMARY OF CHANGES" verify that fedora-swap and fedora-root will be reformatted, then click on "Accept Changes".
Then let the installation begin. I suggest that any user you create should use a numeric UID different from the one that already exists in /home.
 
Old 07-02-2016, 04:36 PM   #14
bangorme
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
I had no problem making the Fedora 24 installer reformat the swap and root LVs while leaving home alone.
  1. On the INSTALLATION DESTINATION screen, select "I will configure partitioning", then click on "Done".
  2. On the MANUAL PARTIONING screen, below where it says "Or, assign new mount points to existing partitions after selecting them below," click on the "Fedora Linux ..." partition.
  3. Select /home, set the mount point as "/home".
  4. Select /, set the mount point to "/" and put a tic in "Reformat".
  5. Select swap, put a tic mark in "Reformat", then click on "Update Settings"
  6. Click on "Done".
  7. In the "SUMMARY OF CHANGES" verify that fedora-swap and fedora-root will be reformatted, then click on "Accept Changes".
Then let the installation begin. I suggest that any user you create should use a numeric UID different from the one that already exists in /home.
Thank you so much for the great directions rknichols! They were a little different than how I'd tried it in the past on Anaconda, but unfortunately I get the same problem. Everything looks good as I'm doing it. When I press "Done," it goes back to the first screen and has the error message:
Quote:
Not enough space in file systems for the current selection. An additional 4.8 g is needed
So, when I go back to the Manual partitioning screen, it has changed the root partition to 500 M. From the numerous times over the last two weeks I've tried to use Anaconda, I've discovered that 500 M is what is not currently allocated on that disk. Even if I specify 36 G (which is the space in the /root partition), it refuses to use it. This is why that I'm looking here for a way to reformat the /root outside of Anaconda, then hope Anaconda will allow the install on /root.

Thanks for helping.
 
Old 07-02-2016, 05:42 PM   #15
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by bangorme View Post
Thank you so much for the great directions rknichols! They were a little different than how I'd tried it in the past on Anaconda, but unfortunately I get the same problem. Everything looks good as I'm doing it. When I press "Done," it goes back to the first screen and has the error message:
I don't know what is happening, then. I did a Fedora 23 install creating a disk with 1 30G LVM partition containing 3 LVs (12G root, 15G home, 3G swap), then ran the Fedora 24 installer using the steps I described above. It all worked just fine, and I was greeted with a fresh installation with a /home that still held the home directory for the original user. Perhaps whatever is wrong is what bricked your F24 upgrade in the first place.

That "500 GB" sounds like your root partition is getting confused with your separate /boot partition (which I did not use). Is your disk GPT? Mine was MBR partitioned; perhaps that's the difference.
 
  


Reply

Tags
format, lvm, solved



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LVM Partitions are equals to OS partitions? xeon123 Linux - Newbie 1 05-26-2011 06:45 PM
How to multiboot distros from LVM and/or Non-LVM partitions? kennybobby Fedora 2 12-07-2010 06:58 AM
LXer: Back Up (And Restore) LVM Partitions With LVM Snapshots LXer Syndicated Linux News 0 04-17-2007 11:16 AM
how do I add partitions to drives that have Logical Volume (LVM) partitions? The MJ Linux - Software 5 08-17-2006 06:15 PM
Partitions and Reformatting C-Squared Linux - Newbie 4 07-08-2003 05:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration