LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-25-2014, 10:09 AM   #1
chiendarret
Member
 
Registered: Mar 2007
Posts: 307

Rep: Reputation: 16
Copy resize2fs lvreduce lvextend with (or in connection with) a device mapper


Hello:
A most naive question that probably already finds illustration in this forum, but which escaped my search.

Thus, all that I know about device mapper is that it creates a new block device from another one. On such scanty knowledge, I am unable to deal with copy (backup) resize2fs lvreduce lvextend with (or in connection with) a device mapper.

My interest in these affairs is to become able to shink my home partition to elarge my root partition, which has become nearly full following "aptitude upgrading" with a Debian wheezy amd64 raid mirror (two disks) installation:

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg1-root 922M 839M 35M 97% /
udev 10M 0 10M 0% /dev
tmpfs 1.6G 860K 1.6G 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.2G 80K 3.2G 1% /run/shm
/dev/mapper/vg1-home 770G 271G 461G 37% /home
/dev/mapper/vg1-opt 9.1G 3.1G 5.6G 36% /opt
/dev/mapper/vg1-tmp 5.4G 12M 5.1G 1% /tmp
/dev/mapper/vg1-usr 55G 6.4G 46G 13% /usr
/dev/mapper/vg1-var 19G 2.5G 15G 15% /var
none 4.0K 0 4.0K 0% /sys/fs/cgroup


# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/mapper/vg1-root / ext3 errors=remount-ro 0 1
/dev/mapper/vg1-home /home ext3 defaults 0 2
/dev/mapper/vg1-opt /opt ext3 defaults 0 2
/dev/mapper/vg1-tmp /tmp ext3 defaults 0 2
/dev/mapper/vg1-usr /usr ext3 defaults 0 2
/dev/mapper/vg1-var /var ext3 defaults 0 2
/dev/mapper/vg1-swap none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0



Booting from live SystemRescueCD (gentoo), "fdisk -l" shows correctly all devices above, including mapper. Also, "which" commands shows that resize2fs, lvreduce, and lvextend are on the path.

What also worries me, is connecting to my other amd64 boxes at my router. slogin allows to log in as root, but "ls" does not reveal anything in the presumably connected machine.

thanks for advice
chiendarret
 
Old 05-25-2014, 02:19 PM   #2
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
What was the exact login command used? Did it succeed? (Allowing remote login directly to root is generally discouraged, but some people allow it anyway from their local network.) Are you sure you are logged in to the right machine (look at output from "uname -a")?

You can't reduce the size of an ext3 filesystem while it is mounted, so you'll have to boot from separate media (SystemRescueCD is fine) and work on the unmounted filesystem. Details about the device mapper aren't really involved in this. There are several steps to be followed, and things need to be done in the right order. Assuming you want to transfer 5GB from /home to the root directory:
Code:
e2fsck -f /dev/mapper/vg1-home              # resize2fs will insist on this being done first
resize2fs /dev/mapper/vg1-home 760G         # reduce the size by more than enough. I've reduced by 10GB.
lvreduce -L -5G /dev/mapper/vg1-home        # shrink the LV by 5GB -- Note: upper-case "L"
e2fsck -f /dev/mapper/vg1-home              # make sure the filesystem is still OK
If that last e2fsck fails, STOP. You did not shrink the filesystem enough, and now lvreduce has chopped off its tail. You will need to run vgcfgrestore with the appropriate file in /etc/lvm/archive to safely restore the volume group back to its former condition. Simply running lvextend is not safe since there is no guarantee that the LV will get back the same disk blocks it was using before.
Code:
resize2fs /dev/mapper/vg1-home              # expand home filesystem to fill the current size of the LV
e2fsck -f /dev/mapper/vg1-root              # again, resize2fs will insist
lvextend -l +100%FREE /dev/mapper/vg1-root  # enlarge the root LV as much as possible -- Note: lower-case "l"
resize2fs /dev/mapper/vg1-root              # expand root filesystem to fill its LV
See how simple LVM makes all this? No???

Note: It's important to reduce the filesystem initially by more than enough since there may be roundoff errors, and you don't want to risk leaving the filesystem just a little too large for its new, smaller conatiner.
 
Old 05-25-2014, 04:38 PM   #3
chiendarret
Member
 
Registered: Mar 2007
Posts: 307

Original Poster
Rep: Reputation: 16
Quote:
What was the exact login command used? Did it succeed? (Allowing remote login directly to root is generally discouraged, but some people allow it anyway from their local network.) Are you sure you are logged in to the right machine (look at output from "uname -a")?
Booting with default settings, prompt reads

root@sysresccd /root %

"uname -a" gave Linux sysresccd 3.10.95-std420-amd64 #2 SMP etc

I was unable to exit from root and act as user. As root, command

slogin 192.168.x.xx

did not fin the host on the list, aking whether to continue. Being on my network, I gave permission, whereby I was asked the root password on the host, which I gave (and later on changed the passw). The prompt now reads;

roo@tya: ~#

"uname -a" now gave

Linux tya 3.2.0-4-amd64 (which is correct for my wheezy installation). Now, "ls" gave no output.



As to the procedure for shrinking/enlarging, could you please indicate which commands to use to get my home and root saved on another machine on my network (just "tya" above)? I would prefer to have the root saved before shrinking/enlarging (I don't care about my "home" as I maintain the same home on "tya", which is also raid mirror with grub on both disks) but I care about "root". Also, preventing a possible total failure, I do care much about PCIExpress 3, which gives somme acceleration to my simulations on this ivibridge box> I did not take notice how I got that. I should have to rethink from scratch.

thanks
chiendarret

Thanks
francesco
 
Old 06-01-2014, 04:27 PM   #4
chiendarret
Member
 
Registered: Mar 2007
Posts: 307

Original Poster
Rep: Reputation: 16
Solved

Quote:
As to the procedure for shrinking/enlarging, could you please indicate which commands to use to get my home and root saved on another machine on my network (just "tya" above)?
as I got no answer, I managed by myself. With SystemrescueCD

Code:
dd if=/dev/vg1/root | ssh 192.168.#.## dd of=/home/chiendarret/tmp/vg1-root
works fine and is liable to file compression.

chiendarret
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] device-mapper: remove ioctl on failed: Device or resource busy jheengut Linux - Kernel 1 10-23-2013 08:38 AM
LVM lvreduce and lvextend azurtem Linux - Server 11 10-17-2013 01:13 PM
lvreduce/lvextend vs lvresize drManhattan Linux - Newbie 2 06-04-2012 01:03 AM
mkrescue Fatal: device-mapper: only linear boot device supported Molly Slackware 5 01-06-2009 04:35 PM
device mapper / multipath creating extra device, won't let me talk to the one i want chakkerz Linux - Server 1 03-16-2008 05:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:17 PM.

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