Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #159710 > unrolled thread
| Started by | ray <ray@aarden.us> |
|---|---|
| First post | 2015-10-24 03:30 +0200 |
| Last post | 2015-10-27 05:10 +0100 |
| Articles | 14 — 5 participants |
Back to article view | Back to linux.debian.user
How to Rezize Partition on LVM ray <ray@aarden.us> - 2015-10-24 03:30 +0200
Re: How to Rezize Partition on LVM Charlie Kravetz <cjk@teamcharliesangels.com> - 2015-10-24 04:40 +0200
Re: How to Rezize Partition on LVM Mario Castelán Castro <marioxcc.MT@yandex.com> - 2015-10-24 04:40 +0200
Re: How to Rezize Partition on LVM Pascal Hambourg <pascal@plouf.fr.eu.org> - 2015-10-24 17:50 +0200
Re: How to Rezize Partition on LVM ray <ray@aarden.us> - 2015-10-25 14:00 +0100
Re: How to Rezize Partition on LVM Pascal Hambourg <pascal@plouf.fr.eu.org> - 2015-10-25 16:00 +0100
Re: How to Rezize Partition on LVM ray <ray@aarden.us> - 2015-10-25 20:10 +0100
Re: How to Rezize Partition on LVM ray <ray@aarden.us> - 2015-10-25 20:30 +0100
Re: How to Rezize Partition on LVM Mario Castelán Castro <marioxcc.MT@yandex.com> - 2015-10-25 20:50 +0100
Re: How to Resize Partition on LVM ray <ray@aarden.us> - 2015-10-26 02:50 +0100
Re: How to Resize Partition on LVM Mario Castelán Castro <marioxcc.MT@yandex.com> - 2015-10-26 03:20 +0100
Re: How to Resize Partition on LVM Pascal Hambourg <pascal@plouf.fr.eu.org> - 2015-10-26 10:00 +0100
Re: How to Resize Partition on LVM Mario Castelán Castro <marioxcc.MT@yandex.com> - 2015-10-26 15:20 +0100
Re: How to Resize Partition on LVM ray <ray@aarden.us> - 2015-10-27 05:10 +0100
| From | ray <ray@aarden.us> |
|---|---|
| Date | 2015-10-24 03:30 +0200 |
| Subject | How to Rezize Partition on LVM |
| Message-ID | <qmVOG-21k-7@gated-at.bofh.it> |
I would like to resize the /home partition but it is mounted, and when umount is run, it errors with 'busy'. System Configuration: I installed jessie on a laptop with one SSD. I used guided partitioning and selected the whole drive with multiple partitions. The /home now takes up 420 GB. I would like to reduce that to 20 GB to make room for another partition. What are the methods reduce this partition?
[toc] | [next] | [standalone]
| From | Charlie Kravetz <cjk@teamcharliesangels.com> |
|---|---|
| Date | 2015-10-24 04:40 +0200 |
| Message-ID | <qmWUp-3Es-3@gated-at.bofh.it> |
| In reply to | #159710 |
On Fri, 23 Oct 2015 18:05:55 -0700 (PDT) ray <ray@aarden.us> wrote: >I would like to resize the /home partition but it is mounted, and when umount is run, it errors with 'busy'. > >System Configuration: >I installed jessie on a laptop with one SSD. I used guided partitioning and selected the whole drive with multiple partitions. The /home now takes up 420 GB. I would like to reduce that to 20 GB to make room for another partition. > >What are the methods reduce this partition? > I have always booted from a live cd or usb to do the resizing. That keeps the partition from being mounted. -- Charlie Kravetz Linux Registered User Number 425914 [http://linuxcounter.net/user/425914.html] Never let anyone steal your DREAM. [http://keepingdreams.com]
[toc] | [prev] | [next] | [standalone]
| From | Mario Castelán Castro <marioxcc.MT@yandex.com> |
|---|---|
| Date | 2015-10-24 04:40 +0200 |
| Message-ID | <qmWUp-3Es-11@gated-at.bofh.it> |
| In reply to | #159710 |
El 23/10/15 a las 20:05, ray escribió:
> I would like to resize the /home partition but it is mounted, and when umount is run, it errors with 'busy'.
>
> System Configuration:
> I installed jessie on a laptop with one SSD. I used guided partitioning and selected the whole drive with multiple partitions. The /home now takes up 420 GB. I would like to reduce that to 20 GB to make room for another partition.
>
> What are the methods reduce this partition?
In order to resize a partition that is on LVM, you must *first* reduce
the size of the filesystem, *then* reduce the size of the logical
volume, to exactly the same size (or the LVM LV bigger than the
filesystem, but that is wasteful and does not make sense). To make sure
that the LVM LV and filesystem are the same size, specify the size to
all tools in bytes to be sure. Instead of using a bigger unit like MB or
MiB. Make the conversion and make it a multiple of 1 MiB, for example,
if you want 400 GB, rounding to the nearest multiple of 1 MiB gives
400000286720 bytes.
To shrink a filesystem, you will need to use a filesystem-specifc tool.
For ext{2,3,4} you can use "resize2fs"; the filesystem needs to be
unmounted in order to make it smaller, but you can make a filesystem
bigger either mounted or unmounted mounted (but this is the opposite you
need in this case).
To resize a logical volume, take a look into the documentation (man
page) of the tool "lvresize".
The only requirement that will cause a minor inconvenience is to have
your partition unmounted. Since you want to resize /home, it will
normally be used by many programs, including your desktop environment;
and therefore there is no trivially easy way to unmount it while using
your graphical environment.
You should be able to boot in single user mode and do the resizing with
/home unmounted. I have not done that in Debian 8 yet (which a different
boot system by default than Debian 7).
You can also boot from a Live CD image of Debian and perform the
resizing from there; however, there is no need to burn the image to an
actual CD, and it is a waste of resources (money and natural resources)
unless it is actually required for a different and good reason. Instead,
put the CD image as a file into your root partition and boot from there
using GRUB. There is plenty of information about how to boot an ISO
image from GRUB in its manual and scattered in the web. For example,
with a very quick search I found this:
<http://xmodulo.com/boot-iso-image-from-grub.html>; do your own research.
A web search will bring more information about resizing in general.
Resizing is a common task when installing operating systems. *I heavily
recommend against using Google.* Google has way too much power and don't
uses it for good (neither it should have that much power in the first
place). For example, DuckDuckGo comes pre-configured in Iceweasel; it
promises to not to track, and it isn't an Internet tyrant (unlike
Google), so consider using it instead.
Standard recommendation of making a backup applies.
[toc] | [prev] | [next] | [standalone]
| From | Pascal Hambourg <pascal@plouf.fr.eu.org> |
|---|---|
| Date | 2015-10-24 17:50 +0200 |
| Message-ID | <qn9eV-4A2-5@gated-at.bofh.it> |
| In reply to | #159710 |
ray a écrit : > I would like to resize the /home partition but it is mounted, and when > umount is run, it errors with 'busy'. > > I used guided partitioning and selected the whole drive with multiple > partitions. The /home now takes up 420 GB. I would like to reduce that > to 20 GB to make room for another partition. Are you talking about plain partitions or LVM logical volumes ? In the subject you mentionned LVM, but in the body you mention only partitions. Regarding your question, this is not the same at all. It is too late now, but here is my advice for future installations using LVM : if you don't plan to use btrfs, don't allocate all the space to the logical volumes, leave some free space for future allocation. Growing an ext2/3/4 filesystem is easy and can be done online (without unmounting it). However online shrinking is only supported with a btrfs filesystem. Some filesystems such as XFS don't even allow offline shrinking. /home can be unmounted only when no process uses it. In practice it means that you cannot be logged in as a regular user (with its home directory in /home) but directly as root, without using 'su' or 'sudo'. In my experience it is not necessary to boot in single user mode or from another system. Just log in as root in a tty console.
[toc] | [prev] | [next] | [standalone]
| From | ray <ray@aarden.us> |
|---|---|
| Date | 2015-10-25 14:00 +0100 |
| Message-ID | <qnt3Y-36r-13@gated-at.bofh.it> |
| In reply to | #159733 |
I would like to than everyone for the input. Here is how it was completed: Boot into GUI mycomp as root # df -h Filesystem Size Used Avail Use% Mounted on /dev/dm-0 8.2G 2.9G 4.9G 38% / udev 10M 0 10M 0% /dev tmpfs 3.2G 9.2M 3.2G 1% /run tmpfs 7.9G 68K 7.9G 1% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup /dev/sda1 236M 46M 178M 21% /boot /dev/mapper/mycomp--vg-var 2.7G 351M 2.2G 14% /var /dev/mapper/mycomp--vg-tmp 360M 2.1M 335M 1% /tmp /dev/mapper/mycomp--vg-home 427G 136M 405G 1% /home tmpfs 1.6G 4.0K 1.6G 1% /run/user/118 tmpfs 1.6G 8.0K 1.6G 1% /run/user/0 root@mycomp:~# resize2fs /dev/mapper/mycomp--vg-home 5G Filesystem at /dev/mapper/mycomp--vg-home is mounted on /home; on-line resizing required resize2fs: On-line shrinking not supported Rebooting into command line interface for root worked, the /home partition was not mounted. --------------------------------------------------------------------------- # lvreduce -L 5G /dev/mapper/mycomp--vg-home WARNING: Reducing active and open logical volume to 5.00 GiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce home? [y/n]: y Size of logical volume mycomp-vg/home changed from 433.32 GiB (110931 extents) to 5.00 GiB (1280 extents). Logical volume home successfully resized
[toc] | [prev] | [next] | [standalone]
| From | Pascal Hambourg <pascal@plouf.fr.eu.org> |
|---|---|
| Date | 2015-10-25 16:00 +0100 |
| Message-ID | <qnuW9-4fF-101@gated-at.bofh.it> |
| In reply to | #159761 |
ray a écrit : > I would like to than everyone for the input. Here is how it was completed: > > Boot into GUI mycomp as root I thought that logging as root was prohibited by GUI display managers. > # df -h > Filesystem Size Used Avail Use% Mounted on (...) > /dev/mapper/mycomp--vg-home 427G 136M 405G 1% /home (...) > root@mycomp:~# resize2fs /dev/mapper/mycomp--vg-home 5G > Filesystem at /dev/mapper/mycomp--vg-home is mounted on /home; on-line resizing required > resize2fs: On-line shrinking not supported You need to unmount /home first. If you're logged as root, it should work. > Rebooting into command line interface for root worked, the /home partition was not mounted. What do you call "command line interface for root" ? Single user mode ? > # lvreduce -L 5G /dev/mapper/mycomp--vg-home > WARNING: Reducing active and open logical volume to 5.00 GiB > THIS MAY DESTROY YOUR DATA (filesystem etc.) > Do you really want to reduce home? [y/n]: y > Size of logical volume mycomp-vg/home changed from 433.32 GiB (110931 extents) to 5.00 GiB (1280 extents). > Logical volume home successfully resized I hope you reran the resize2fs command successfully before doing this. Otherwise you just ruined your /home filesystem.
[toc] | [prev] | [next] | [standalone]
| From | ray <ray@aarden.us> |
|---|---|
| Date | 2015-10-25 20:10 +0100 |
| Message-ID | <qnyQ1-6PP-5@gated-at.bofh.it> |
| In reply to | #159764 |
On Sunday, October 25, 2015 at 10:00:08 AM UTC-5, Pascal Hambourg wrote: > (...) > I thought that logging as root was prohibited by GUI display managers. That is what I have read. But I tried it anyway and found it to work. > (...) > I hope you reran the resize2fs command successfully before doing this. > Otherwise you just ruined your /home filesystem. I did not make a record of that so I am not sure whether I reran resize2fs. This system has been reboot a few times since then and many configurations altered. I haven't noticed a failure.
[toc] | [prev] | [next] | [standalone]
| From | ray <ray@aarden.us> |
|---|---|
| Date | 2015-10-25 20:30 +0100 |
| Message-ID | <qnz9o-6Wn-15@gated-at.bofh.it> |
| In reply to | #159764 |
Now that the /home logical volume has been reduced, I would like to add a partition in the remaining space or reduce the LV's size to fee the unused space and create a new logical volume. Since the existing LV totally occupies the SSD, I don't see how to do this. I would appreciate any suggestions on how to complete this.
[toc] | [prev] | [next] | [standalone]
| From | Mario Castelán Castro <marioxcc.MT@yandex.com> |
|---|---|
| Date | 2015-10-25 20:50 +0100 |
| Message-ID | <qnzsJ-730-9@gated-at.bofh.it> |
| In reply to | #159778 |
El 25/10/15 a las 13:03, ray escribió: > Now that the /home logical volume has been reduced, I would like to add a partition in the remaining space or reduce the LV's size to fee the unused space and create a new logical volume. Since the existing LV totally occupies the SSD, I don't see how to do this. > > I would appreciate any suggestions on how to complete this. It seems like confusing LV with PV. An *LVM group* presents itself to the block devices that contains it as a *physical volume* (PV), in turn, LVM provides *logical volumes* (LV) over which you may place filesystems. Don't confuse those 3 concepts. If you want to make a partition outside LVM, you would have to reduce the LVM physical volume, not the LVM logical volume (which you already did). If you already reduced the filesystem and the logical volume, then there is free space within your LVM volume group; there may be no "free space in the SSD" (space not assigned to any partition or the MBR), but that is how it is supposed to be. The reason to use LVM is to put filesystems in logical volumes within your volume group to get the benefits of logical volume management, not as partitions outside your volume group, because you lose those benefits. You can create logical volumes with "lvcreate". Read the manual! man lvm
[toc] | [prev] | [next] | [standalone]
| From | ray <ray@aarden.us> |
|---|---|
| Date | 2015-10-26 02:50 +0100 |
| Subject | Re: How to Resize Partition on LVM |
| Message-ID | <qnF57-1YJ-5@gated-at.bofh.it> |
| In reply to | #159779 |
Mario,
Thank you for the review.
Yes, there is free space in the LVM. I have gone through the manual many times (today and the last several months) and don't see a method to add a pv or vg. It seems to add a pv, it needs a device. And to add a vg, it needs a pv. How can I add either?
Displaying the resize pv:
# pvdisplay -v -m
DEGRADED MODE. Incomplete RAID LVs will be processed.
Scanning for physical volume names
--- Physical volume ---
PV Name /dev/sda5
VG Name mycomp-vg
PV Size 55.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 14079
Free PE 1695
Allocated PE 12384
(the file system is smaller than the pv)
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 477G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 476.7G 0 part
├─mycomp--vg-root 254:0 0 8.4G 0 lvm /
├─mycomp--vg-var 254:1 0 2.8G 0 lvm /var
├─mycomp--vg-swap_1 254:2 0 31.9G 0 lvm [SWAP]
├─mycomp--vg-tmp 254:3 0 380M 0 lvm /tmp
└─mycomp--vg-home 254:4 0 5G 0 lvm /home
[toc] | [prev] | [next] | [standalone]
| From | Mario Castelán Castro <marioxcc.MT@yandex.com> |
|---|---|
| Date | 2015-10-26 03:20 +0100 |
| Subject | Re: How to Resize Partition on LVM |
| Message-ID | <qnFy9-2nf-3@gated-at.bofh.it> |
| In reply to | #159784 |
According to "man lvm", to add a physical volume to a volume group, the right command is "vgextend" (the name is because you make a volume group (VG) larger by adding more storage space for it, in a new physical volume). To create a new volume group, the command is "vgcreate". But if you want to add a filesystem, you *need not* (and very likely, should not) add a volume group nor a physical volume. What you need is: (1) Create a local volume within your existing volume groups; use lvcreate for that. (2) Make a filesystem with "mkfs.ext4" (or similar, for other filesystem type). (3) Optionally add a corresponding entry in /etc/fstab and mount the new filesystem. A typical structure is this (where "->" means "stored in"); it is not the only possible layout, but it is likely the most common one and seems to be the one you are using: Files -> Filesystem -> LVM LV -> LVM VG -> LVM PV -> Partition -> Disc or SSD The structure is NOT hierarchical, and not all of these arrows represent the same relationship between components. In particular, note that a LVM VG does both grouping and ungrouping: It *takes* storage space from (possibly several) physical volumes, and it *provides* storages space to (possibly several) *logical volumes*. The main information resource are the main pages. Also see <http://www.tldp.org/HOWTO/LVM-HOWTO/index.html>. Do your own research. El 25/10/15 a las 19:22, ray escribió: > Mario, > > Thank you for the review. > > Yes, there is free space in the LVM. I have gone through the manual many times (today and the last several months) and don't see a method to add a pv or vg. It seems to add a pv, it needs a device. And to add a vg, it needs a pv. How can I add either? > > Displaying the resize pv: > # pvdisplay -v -m > DEGRADED MODE. Incomplete RAID LVs will be processed. > Scanning for physical volume names > --- Physical volume --- > PV Name /dev/sda5 > VG Name mycomp-vg > PV Size 55.00 GiB / not usable 3.00 MiB > Allocatable yes > PE Size 4.00 MiB > Total PE 14079 > Free PE 1695 > Allocated PE 12384 > (the file system is smaller than the pv) > lsblk > NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT > sda 8:0 0 477G 0 disk > ├─sda1 8:1 0 243M 0 part /boot > ├─sda2 8:2 0 1K 0 part > └─sda5 8:5 0 476.7G 0 part > ├─mycomp--vg-root 254:0 0 8.4G 0 lvm / > ├─mycomp--vg-var 254:1 0 2.8G 0 lvm /var > ├─mycomp--vg-swap_1 254:2 0 31.9G 0 lvm [SWAP] > ├─mycomp--vg-tmp 254:3 0 380M 0 lvm /tmp > └─mycomp--vg-home 254:4 0 5G 0 lvm /home > >
[toc] | [prev] | [next] | [standalone]
| From | Pascal Hambourg <pascal@plouf.fr.eu.org> |
|---|---|
| Date | 2015-10-26 10:00 +0100 |
| Subject | Re: How to Resize Partition on LVM |
| Message-ID | <qnLNg-63Y-19@gated-at.bofh.it> |
| In reply to | #159784 |
ray wrote : > > Displaying the resize pv: > # pvdisplay -v -m > DEGRADED MODE. Incomplete RAID LVs will be processed. Hmm. Not sure wha that means. Was there anothed disk in the VG ? > Scanning for physical volume names > --- Physical volume --- > PV Name /dev/sda5 > VG Name mycomp-vg > PV Size 55.00 GiB / not usable 3.00 MiB > Allocatable yes > PE Size 4.00 MiB > Total PE 14079 > Free PE 1695 > Allocated PE 12384 > (the file system is smaller than the pv) > lsblk > NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT > sda 8:0 0 477G 0 disk > ├─sda1 8:1 0 243M 0 part /boot > ├─sda2 8:2 0 1K 0 part > └─sda5 8:5 0 476.7G 0 part > ├─mycomp--vg-root 254:0 0 8.4G 0 lvm / > ├─mycomp--vg-var 254:1 0 2.8G 0 lvm /var > ├─mycomp--vg-swap_1 254:2 0 31.9G 0 lvm [SWAP] > ├─mycomp--vg-tmp 254:3 0 380M 0 lvm /tmp > └─mycomp--vg-home 254:4 0 5G 0 lvm /home The sizes don't match. The size of /dev/sda5 is 476 GiB but the PV within claims its size is only 55 GiB and is almost full. Did you reduce the PV size in /dev/sda5 with pvresize ? Now you need to explain what you want to do exactly, because you have been unclear so far. Do you want to reduce the partition /dev/sda5 and create a new plain partition for whatever use (filesystem, new PV for existing or new VG) ? Then you must reduce /dev/sda5 with whatever partitioning tool, to a size of at least the PV size, 55 GiB (*not* 55 GB which is only 51.2 GiB, beware if using parted). In the free space on the disk you can create a new partition. Or do you want to create a new LV in the existing VG ? Then, if the new LV size is less than the remaining free space in the VG (about 6.5 GiB), just use lvcreate to create the LV. If its size must be bigger than the available free space, then you need to resize the PV first, up to the size of /dev/sda5.
[toc] | [prev] | [next] | [standalone]
| From | Mario Castelán Castro <marioxcc.MT@yandex.com> |
|---|---|
| Date | 2015-10-26 15:20 +0100 |
| Subject | Re: How to Resize Partition on LVM |
| Message-ID | <qnQMW-QQ-33@gated-at.bofh.it> |
| In reply to | #159793 |
> Then you must reduce /dev/sda5 with whatever partitioning tool, to a > size of at least the PV size, 55 GiB (*not* 55 GB which is only 51.2 > GiB, beware if using parted). In the free space on the disk you can > create a new partition. That is why I recommended using complete sizes in bytes.
[toc] | [prev] | [next] | [standalone]
| From | ray <ray@aarden.us> |
|---|---|
| Date | 2015-10-27 05:10 +0100 |
| Subject | Re: How to Resize Partition on LVM |
| Message-ID | <qo3K9-wM-3@gated-at.bofh.it> |
| In reply to | #159804 |
I would like to thank everyone to helping. Looks like it is working. Here is the action: With Live GParted, reduce sda5 to minimum ~ 60GB. Create new partition, sda6 ~420GB. Booted back to Debian. pvcreate /dev/sda6 vgcreate xenvg /dev/sda6 lvcreate -l +100%FREE xenvg -n xenlv mkfs.ext4 -m 0 /dev/xenvg/xenlv Updated /etc/fstab last line: /dev/mapper/xenvg-xenlv /xenfs ext4 defaults 0 # mount -a # ls -a /xenfs . .. lost+found # df -h Filesystem Size Used Avail Use% Mounted on <snip> /dev/sda1 236M 49M 176M 22% /boot /dev/mapper/mycomp--vg-tmp 360M 2.1M 335M 1% /tmp /dev/mapper/mycomp--vg-var 2.7G 366M 2.2G 15% /var /dev/mapper/mycomp--vg-home 4.8G 143M 4.4G 4% /home <snip> /dev/mapper/xenvg-xenlv 413G 71M 412G 1% /xenfs
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web