Operating System - Linux
1820619 Members
1843 Online
109626 Solutions
New Discussion юеВ

Whacked the /usr filesystem with inadvertant lvreduce. Any way to recover?

 
Steven E. Protter
Exalted Contributor

Whacked the /usr filesystem with inadvertant lvreduce. Any way to recover?

Was reducing a series of file systems on a centos 5.4 box.

LVM

Instead of
resize2fs
lvreduce

I ran the commands in the wrong order and reduced first. The OS gave me a chance to not do it, but I was in robot mode and did not listen.

Now I get I/O errors all over the place on /usr

Filesystem at /dev/vg00/lvol3 is mounted on /usr; on-line resizing required
On-line shrinking from 26214400 to 2621440 not supported.

The lvm command produce errors.

Is the system a lost cause or can I recover it?

How?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
5 REPLIES 5
Steven E. Protter
Exalted Contributor

Re: Whacked the /usr filesystem with inadvertant lvreduce. Any way to recover?

All the lvm commands produce bus errors.

I have a backup of /usr available.

Thinking how to fix this without an OS reinstall.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
ManojK_1
Valued Contributor

Re: Whacked the /usr filesystem with inadvertant lvreduce. Any way to recover?

Hi,

Do you have enough space to create one more partition?

Try to reboot and go in to the single user mode.

Create a new lv and mount it to /usr and restore your /usr backup.

Change the fstab to mount the new lv as /usr.

Reboot the server.

Manoj K
Thanks and Regards,
Manoj K
Vitaly Karasik_1
Honored Contributor

Re: Whacked the /usr filesystem with inadvertant lvreduce. Any way to recover?

ManojK suggested good way; another option may be to boot from a rescue disk and try lvextend on the same volume - I mean to return this LV to its original size.
Steven E. Protter
Exalted Contributor

Re: Whacked the /usr filesystem with inadvertant lvreduce. Any way to recover?

The fix:

1) Installed via console a new OS to another partition, as you suggested, though before I looked back here.
2) Volume groups were sensed by the install. used vgcan next.
3) lvscan
4) mount the damaged /usr file system to verify the data was there.
5) umount the file system
6) e2fsck the file system
7) lvextend the logical volume back to hits original size.
8) mount it to check again.
9) umount (probably not necessary)
10) e2fsck again
11) resize2fs to desired size
12) lvreduce to same size
12) mount and check again.
13) fix /etc/fstab to remove the logical volume and file system I used to install the OS (It was mostly empty, one backup fs).
14) mounted /boot of the original install as /boot
15) mount /dev/sda1 /boot
16)grub-install --root-directory /boot /dev/sda
17) reboot and verify system functionality.

Lucky. No data lost.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: Whacked the /usr filesystem with inadvertant lvreduce. Any way to recover?

Change:
16)grub-install --root-directory /boot /dev/sda

to

16)grub-install --root-directory / /dev/sda


SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com