LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   after lvreduce reboot now can't read superblock (https://www.linuxquestions.org/questions/linux-newbie-8/after-lvreduce-reboot-now-cant-read-superblock-4175576100/)

scriptkiddy 03-29-2016 03:51 AM

after lvreduce reboot now can't read superblock
 
Originally on my CentOS 7 virtual machine, I created 2 partitions:

sda1 for /boot
sda2 with 1 volume group "centos" with 5 logical volumes:
/
/home
/var
/tmp
swap


I noticed later that I had needed more space from /home lvm. It was 15GB, it was only using 1.5GB, so I decided to reduce it down to 5GB:

Code:

# lvreduce -L 5GB /dev/mapper/centos-home
It said successful so I rebooted.

Upon reboot, I was sent to emergency mode, and noticed /home was not listed under df, so I mounted everything in fstab but received an error:

Code:

#mount -a
mount: /dev/mapper/centos-home: can't read superblock

So I ran an
Code:

# xfs_repair /dev/mapper/centos-home
It gave me same issues about not being able to read the superblock.

Oddly enough, the lvdisplay /dev/mapper/centos-home works and now shows LV Size as 5.00GB down from 15.00GB with all the other information listed...

So how do I fix this issue so I can remount the home logical volume?

SK

syg00 03-29-2016 03:59 AM

Increase the lv to at least the same size as it was - personally I would make it larger if space exists.
Then run a fsck - and hope.

xfs cannot be reduced by command - do some searching before using potentially destructive commands. Backups are never a bad idea also.

michaelk 03-29-2016 06:10 AM

In addition, lvreduce shrinks the volume i.e the container but not the file system. As stated there isn't a way to reduce an xfs file system so you need to copy it first, shrink the volume, make a new file system and the copy data back. Hopefully, you haven't lost any important data.

scriptkiddy 03-29-2016 05:27 PM

Thanks for the info that's really good to know about xfs. No worries about data or backups as this is my play / test lab, I'm only using it to learn for the last few months. I'll remake the volume group with the 5 logical volumes as ext4 and try again. Or is ext4 also limited to a file system that cannot be reduced?

hydrurga 03-29-2016 05:40 PM

Quote:

Originally Posted by scriptkiddy (Post 5523216)
Thanks for the info that's really good to know about xfs. No worries about data or backups as this is my play / test lab, I'm only using it to learn for the last few months. I'll remake the volume group with the 5 logical volumes as ext4 and try again. Or is ext4 also limited to a file system that cannot be reduced?

http://www.microhowto.info/howto/red...ilesystem.html

scriptkiddy 03-29-2016 05:49 PM

Thanks for the link, it was a good read.

I'm curious now though. If resize2fs is the way to resize the file system, and lvreduce doesn't work on xfs, then when would I ever use lvreduce?
The only time I can think of using it would be when I've created a logical volume, but have not yet made the file system. Its like its a tool for someone who has made the LV, then thinks "you know what, that's too big, I'm going to resize it before I make it ext4 file system".

Is that accurate?

hydrurga 03-29-2016 05:57 PM

Quote:

Originally Posted by scriptkiddy (Post 5523226)
Thanks for the link, it was a good read.

I'm curious now though. If resize2fs is the way to resize the file system, and lvreduce doesn't work on xfs, then when would I ever use lvreduce?
The only time I can think of using it would be when I've created a logical volume, but have not yet made the file system. Its like its a tool for someone who has made the LV, then thinks "you know what, that's too big, I'm going to resize it before I make it ext4 file system".

Is that accurate?

You first reduce the size of the filesystem (resize2fs for ext2/3/4).

Then you reduce the size of the underlying block device (lvreduce for LVM logical volumes).

scriptkiddy 03-29-2016 06:04 PM

Ahhh...lightbulb

Thanks for the clarification

hydrurga 03-29-2016 06:17 PM

Quote:

Originally Posted by scriptkiddy (Post 5523234)
Ahhh...lightbulb

Thanks for the clarification

No problem. :) Now you'll see why "lvreduce doesn't work on xfs" didn't make much sense, since lvreduce works on logical volumes and xfs is a filesystem.

The issue with xfs is that there is no ready equivalent to ext's resize2fs (for shrinking anyhow).

syg00 03-29-2016 06:44 PM

In fact lvreduce can also reduce the filesystem - if the filesystem is "sane". IMHO that excludes xfs. Similarly lvextend, but in that case xfs is also catered for.

hydrurga 03-29-2016 07:11 PM

Quote:

Originally Posted by syg00 (Post 5523248)
In fact lvreduce can also reduce the filesystem - if the filesystem is "sane". IMHO that excludes xfs. Similarly lvextend, but in that case xfs is also catered for.

I didn't know that - thanks syg00.

sahruk 11-11-2016 07:02 AM

Hello,
I have the same issue but I need more help.

I reduced home partition using command below:
Code:

[root@sfvm08 mapper]# lvreduce -L 70G /dev/mapper/centos_sfvm03-home
  WARNING: Reducing active and open logical volume to 70.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce home? [y/n]: y
  Size of logical volume centos_sfvm03/home changed from 97.45 GiB (24946 extents) to 70.00 GiB (17920 extents).
  Logical volume home successfully resized.

and as seems I get success message.

after that I increased root partition using command below:
Code:

[root@sfvm08 mapper]# lvextend -r -l+100%FREE /dev/mapper/centos_sfvm03-root
  Size of logical volume centos_sfvm03/root changed from 50.00 GiB (12800 extents) to 77.51 GiB (19842 extents).
  Logical volume root successfully resized.
meta-data=/dev/mapper/centos_sfvm03-root isize=256    agcount=4, agsize=3276800 blks
        =                      sectsz=512  attr=2, projid32bit=1
        =                      crc=0        finobt=0
data    =                      bsize=4096  blocks=13107200, imaxpct=25
        =                      sunit=0      swidth=0 blks
naming  =version 2              bsize=4096  ascii-ci=0 ftype=0
log      =internal              bsize=4096  blocks=6400, version=2
        =                      sectsz=512  sunit=0 blks, lazy-count=1
realtime =none                  extsz=4096  blocks=0, rtextents=0
data blocks changed from 13107200 to 20318208

everything seemed to be fine, but then my home partition died. After reboot, I get into centos rescue mode and per my check, home partition couldn't be mounted.

Tried to repair using command below in rescue mode:
Code:

xfs_repair /dev/mapper/centos_sfvm03-home
but it can't find secondary super block.


unfortunately I don't have any backup and my data is important :(

I need more detailed guide for my case. This is a Virtual Machine and I have access to virtualization environment so I can increase hard disk over VMWare ESXi. Does it harm hard disk? as far as I read over the similar threat, I should increase reduced LV, can someone help me more detail on how to do that?

rtmistler 11-11-2016 07:29 AM

@sahruk,

Hello and welcome to LQ.

Please post your issue in only one thread. Posting your issue once will make it easier for members to help you and will keep the discussion in one place. While I do realize this issue is similar, please use your new thread question for better assistance: http://www.linuxquestions.org/questi...ck-4175593319/


All times are GMT -5. The time now is 05:53 AM.