how to resize / lvm partition
up vote
1
down vote
favorite
I have a debian linux with this output of df command:
root@debian:~# df -Th
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 973M 0 973M 0% /dev
tmpfs tmpfs 198M 3.0M 195M 2% /run
/dev/mapper/debian--vg-root ext4 17G 1.3G 15G 9% /
tmpfs tmpfs 987M 0 987M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 987M 0 987M 0% /sys/fs/cgroup
/dev/sda1 ext2 236M 77M 147M 35% /boot
/dev/mapper/debian--vg-home ext4 31G 49M 29G 1% /home
tmpfs tmpfs 198M 0 198M 0% /run/user/0
How can I reduce or expand the size of / partition. I am not allowed to use umount command. How is it possible?
Update
You see I can't use umount command here. So this is not possible to use e2fsck and resize2fs commands.
Update2
This is the more detailed:
root@debian:~# vgs
VG #PV #LV #SN Attr VSize VFree
debian-vg 1 3 0 wz--n- <49.76g 0
root@debian:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 49.8G 0 part
├─debian--vg-root 254:0 0 16.6G 0 lvm /
├─debian--vg-swap_1 254:1 0 2G 0 lvm [SWAP]
└─debian--vg-home 254:2 0 31.2G 0 lvm /home
sr0 11:0 1 319M 0 rom
linux debian ubuntu partition lvm
|
show 6 more comments
up vote
1
down vote
favorite
I have a debian linux with this output of df command:
root@debian:~# df -Th
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 973M 0 973M 0% /dev
tmpfs tmpfs 198M 3.0M 195M 2% /run
/dev/mapper/debian--vg-root ext4 17G 1.3G 15G 9% /
tmpfs tmpfs 987M 0 987M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 987M 0 987M 0% /sys/fs/cgroup
/dev/sda1 ext2 236M 77M 147M 35% /boot
/dev/mapper/debian--vg-home ext4 31G 49M 29G 1% /home
tmpfs tmpfs 198M 0 198M 0% /run/user/0
How can I reduce or expand the size of / partition. I am not allowed to use umount command. How is it possible?
Update
You see I can't use umount command here. So this is not possible to use e2fsck and resize2fs commands.
Update2
This is the more detailed:
root@debian:~# vgs
VG #PV #LV #SN Attr VSize VFree
debian-vg 1 3 0 wz--n- <49.76g 0
root@debian:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 49.8G 0 part
├─debian--vg-root 254:0 0 16.6G 0 lvm /
├─debian--vg-swap_1 254:1 0 2G 0 lvm [SWAP]
└─debian--vg-home 254:2 0 31.2G 0 lvm /home
sr0 11:0 1 319M 0 rom
linux debian ubuntu partition lvm
ext4will allow you to grow the file system while mounted. Shrinking requires the file system to be unmounted. Do you want to grow the partition, or shrink it?
– Haxiel
Dec 4 at 11:13
@Haxiel, thank you for response. Would you please tell me both growing and shrinking solutions?
– yasin
Dec 4 at 11:37
2
You cannot shrink the root filesystem online. You will need to boot from some rescue medium so that you can access the root filesystem while it is not mounted.
– wurtel
Dec 4 at 12:34
1
@Panki. This is fairly easy. You need to boot from aLive USBor aLive CD. This doesn't have to match your current OS though. Then once you've booted you can just runlvresize -r -L -5G /dev/mapper/debian-vg-rootThis will perform the shrinking of the file system as well as the disk size
– Valentin Bajrami
Dec 4 at 12:36
1
Where-5Gis your desired number of gibibytes to shrink!
– Valentin Bajrami
Dec 4 at 12:37
|
show 6 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a debian linux with this output of df command:
root@debian:~# df -Th
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 973M 0 973M 0% /dev
tmpfs tmpfs 198M 3.0M 195M 2% /run
/dev/mapper/debian--vg-root ext4 17G 1.3G 15G 9% /
tmpfs tmpfs 987M 0 987M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 987M 0 987M 0% /sys/fs/cgroup
/dev/sda1 ext2 236M 77M 147M 35% /boot
/dev/mapper/debian--vg-home ext4 31G 49M 29G 1% /home
tmpfs tmpfs 198M 0 198M 0% /run/user/0
How can I reduce or expand the size of / partition. I am not allowed to use umount command. How is it possible?
Update
You see I can't use umount command here. So this is not possible to use e2fsck and resize2fs commands.
Update2
This is the more detailed:
root@debian:~# vgs
VG #PV #LV #SN Attr VSize VFree
debian-vg 1 3 0 wz--n- <49.76g 0
root@debian:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 49.8G 0 part
├─debian--vg-root 254:0 0 16.6G 0 lvm /
├─debian--vg-swap_1 254:1 0 2G 0 lvm [SWAP]
└─debian--vg-home 254:2 0 31.2G 0 lvm /home
sr0 11:0 1 319M 0 rom
linux debian ubuntu partition lvm
I have a debian linux with this output of df command:
root@debian:~# df -Th
Filesystem Type Size Used Avail Use% Mounted on
udev devtmpfs 973M 0 973M 0% /dev
tmpfs tmpfs 198M 3.0M 195M 2% /run
/dev/mapper/debian--vg-root ext4 17G 1.3G 15G 9% /
tmpfs tmpfs 987M 0 987M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 987M 0 987M 0% /sys/fs/cgroup
/dev/sda1 ext2 236M 77M 147M 35% /boot
/dev/mapper/debian--vg-home ext4 31G 49M 29G 1% /home
tmpfs tmpfs 198M 0 198M 0% /run/user/0
How can I reduce or expand the size of / partition. I am not allowed to use umount command. How is it possible?
Update
You see I can't use umount command here. So this is not possible to use e2fsck and resize2fs commands.
Update2
This is the more detailed:
root@debian:~# vgs
VG #PV #LV #SN Attr VSize VFree
debian-vg 1 3 0 wz--n- <49.76g 0
root@debian:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 49.8G 0 part
├─debian--vg-root 254:0 0 16.6G 0 lvm /
├─debian--vg-swap_1 254:1 0 2G 0 lvm [SWAP]
└─debian--vg-home 254:2 0 31.2G 0 lvm /home
sr0 11:0 1 319M 0 rom
linux debian ubuntu partition lvm
linux debian ubuntu partition lvm
edited Dec 4 at 13:00
Valentin Bajrami
5,80411627
5,80411627
asked Dec 4 at 10:25
yasin
255
255
ext4will allow you to grow the file system while mounted. Shrinking requires the file system to be unmounted. Do you want to grow the partition, or shrink it?
– Haxiel
Dec 4 at 11:13
@Haxiel, thank you for response. Would you please tell me both growing and shrinking solutions?
– yasin
Dec 4 at 11:37
2
You cannot shrink the root filesystem online. You will need to boot from some rescue medium so that you can access the root filesystem while it is not mounted.
– wurtel
Dec 4 at 12:34
1
@Panki. This is fairly easy. You need to boot from aLive USBor aLive CD. This doesn't have to match your current OS though. Then once you've booted you can just runlvresize -r -L -5G /dev/mapper/debian-vg-rootThis will perform the shrinking of the file system as well as the disk size
– Valentin Bajrami
Dec 4 at 12:36
1
Where-5Gis your desired number of gibibytes to shrink!
– Valentin Bajrami
Dec 4 at 12:37
|
show 6 more comments
ext4will allow you to grow the file system while mounted. Shrinking requires the file system to be unmounted. Do you want to grow the partition, or shrink it?
– Haxiel
Dec 4 at 11:13
@Haxiel, thank you for response. Would you please tell me both growing and shrinking solutions?
– yasin
Dec 4 at 11:37
2
You cannot shrink the root filesystem online. You will need to boot from some rescue medium so that you can access the root filesystem while it is not mounted.
– wurtel
Dec 4 at 12:34
1
@Panki. This is fairly easy. You need to boot from aLive USBor aLive CD. This doesn't have to match your current OS though. Then once you've booted you can just runlvresize -r -L -5G /dev/mapper/debian-vg-rootThis will perform the shrinking of the file system as well as the disk size
– Valentin Bajrami
Dec 4 at 12:36
1
Where-5Gis your desired number of gibibytes to shrink!
– Valentin Bajrami
Dec 4 at 12:37
ext4 will allow you to grow the file system while mounted. Shrinking requires the file system to be unmounted. Do you want to grow the partition, or shrink it?– Haxiel
Dec 4 at 11:13
ext4 will allow you to grow the file system while mounted. Shrinking requires the file system to be unmounted. Do you want to grow the partition, or shrink it?– Haxiel
Dec 4 at 11:13
@Haxiel, thank you for response. Would you please tell me both growing and shrinking solutions?
– yasin
Dec 4 at 11:37
@Haxiel, thank you for response. Would you please tell me both growing and shrinking solutions?
– yasin
Dec 4 at 11:37
2
2
You cannot shrink the root filesystem online. You will need to boot from some rescue medium so that you can access the root filesystem while it is not mounted.
– wurtel
Dec 4 at 12:34
You cannot shrink the root filesystem online. You will need to boot from some rescue medium so that you can access the root filesystem while it is not mounted.
– wurtel
Dec 4 at 12:34
1
1
@Panki. This is fairly easy. You need to boot from a
Live USB or a Live CD. This doesn't have to match your current OS though. Then once you've booted you can just run lvresize -r -L -5G /dev/mapper/debian-vg-root This will perform the shrinking of the file system as well as the disk size– Valentin Bajrami
Dec 4 at 12:36
@Panki. This is fairly easy. You need to boot from a
Live USB or a Live CD. This doesn't have to match your current OS though. Then once you've booted you can just run lvresize -r -L -5G /dev/mapper/debian-vg-root This will perform the shrinking of the file system as well as the disk size– Valentin Bajrami
Dec 4 at 12:36
1
1
Where
-5G is your desired number of gibibytes to shrink!– Valentin Bajrami
Dec 4 at 12:37
Where
-5G is your desired number of gibibytes to shrink!– Valentin Bajrami
Dec 4 at 12:37
|
show 6 more comments
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Ok, so here is a recap.
First download a Live ISO so you can boot from. For example if you are using a Debian operating system you could e.g download a CentOS Live iso to boot from.
Once you've booted just become super user by typing sudo su
To locate your exact Logical volume name issue the following commands (as displayed in your question):
lvs && lsblk
The lvresize utility has an option -r that kills two birds with one stone! It shrinks the file system and the disk size on the same run. The -r option stands for resizefs and the long option is --resizefs. By passing -L -5G option you tell lvresize to shrink the file system by 5GB.
Since you are using ext4 file system for your / root partition, shrinking is possible! For the XFS file system, this is not the case.
Reboot the system and you'll see that / has shrunk.
Since you wanted to assign the remaining space of the volume group debian-vg to /home then you'd run the following command to extend /home
lvresize -r -l +100%FREE /dev/mapper/debian-vg-home
Thanks a lot. I just wanted to be sure this is not possible in my machine and I have to use live one.
– yasin
Dec 4 at 12:54
You are welcome! In addition. If you wanted to extend the/file system you can do this on the fly.
– Valentin Bajrami
Dec 4 at 12:59
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Ok, so here is a recap.
First download a Live ISO so you can boot from. For example if you are using a Debian operating system you could e.g download a CentOS Live iso to boot from.
Once you've booted just become super user by typing sudo su
To locate your exact Logical volume name issue the following commands (as displayed in your question):
lvs && lsblk
The lvresize utility has an option -r that kills two birds with one stone! It shrinks the file system and the disk size on the same run. The -r option stands for resizefs and the long option is --resizefs. By passing -L -5G option you tell lvresize to shrink the file system by 5GB.
Since you are using ext4 file system for your / root partition, shrinking is possible! For the XFS file system, this is not the case.
Reboot the system and you'll see that / has shrunk.
Since you wanted to assign the remaining space of the volume group debian-vg to /home then you'd run the following command to extend /home
lvresize -r -l +100%FREE /dev/mapper/debian-vg-home
Thanks a lot. I just wanted to be sure this is not possible in my machine and I have to use live one.
– yasin
Dec 4 at 12:54
You are welcome! In addition. If you wanted to extend the/file system you can do this on the fly.
– Valentin Bajrami
Dec 4 at 12:59
add a comment |
up vote
1
down vote
accepted
Ok, so here is a recap.
First download a Live ISO so you can boot from. For example if you are using a Debian operating system you could e.g download a CentOS Live iso to boot from.
Once you've booted just become super user by typing sudo su
To locate your exact Logical volume name issue the following commands (as displayed in your question):
lvs && lsblk
The lvresize utility has an option -r that kills two birds with one stone! It shrinks the file system and the disk size on the same run. The -r option stands for resizefs and the long option is --resizefs. By passing -L -5G option you tell lvresize to shrink the file system by 5GB.
Since you are using ext4 file system for your / root partition, shrinking is possible! For the XFS file system, this is not the case.
Reboot the system and you'll see that / has shrunk.
Since you wanted to assign the remaining space of the volume group debian-vg to /home then you'd run the following command to extend /home
lvresize -r -l +100%FREE /dev/mapper/debian-vg-home
Thanks a lot. I just wanted to be sure this is not possible in my machine and I have to use live one.
– yasin
Dec 4 at 12:54
You are welcome! In addition. If you wanted to extend the/file system you can do this on the fly.
– Valentin Bajrami
Dec 4 at 12:59
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Ok, so here is a recap.
First download a Live ISO so you can boot from. For example if you are using a Debian operating system you could e.g download a CentOS Live iso to boot from.
Once you've booted just become super user by typing sudo su
To locate your exact Logical volume name issue the following commands (as displayed in your question):
lvs && lsblk
The lvresize utility has an option -r that kills two birds with one stone! It shrinks the file system and the disk size on the same run. The -r option stands for resizefs and the long option is --resizefs. By passing -L -5G option you tell lvresize to shrink the file system by 5GB.
Since you are using ext4 file system for your / root partition, shrinking is possible! For the XFS file system, this is not the case.
Reboot the system and you'll see that / has shrunk.
Since you wanted to assign the remaining space of the volume group debian-vg to /home then you'd run the following command to extend /home
lvresize -r -l +100%FREE /dev/mapper/debian-vg-home
Ok, so here is a recap.
First download a Live ISO so you can boot from. For example if you are using a Debian operating system you could e.g download a CentOS Live iso to boot from.
Once you've booted just become super user by typing sudo su
To locate your exact Logical volume name issue the following commands (as displayed in your question):
lvs && lsblk
The lvresize utility has an option -r that kills two birds with one stone! It shrinks the file system and the disk size on the same run. The -r option stands for resizefs and the long option is --resizefs. By passing -L -5G option you tell lvresize to shrink the file system by 5GB.
Since you are using ext4 file system for your / root partition, shrinking is possible! For the XFS file system, this is not the case.
Reboot the system and you'll see that / has shrunk.
Since you wanted to assign the remaining space of the volume group debian-vg to /home then you'd run the following command to extend /home
lvresize -r -l +100%FREE /dev/mapper/debian-vg-home
edited Dec 4 at 13:02
answered Dec 4 at 12:50
Valentin Bajrami
5,80411627
5,80411627
Thanks a lot. I just wanted to be sure this is not possible in my machine and I have to use live one.
– yasin
Dec 4 at 12:54
You are welcome! In addition. If you wanted to extend the/file system you can do this on the fly.
– Valentin Bajrami
Dec 4 at 12:59
add a comment |
Thanks a lot. I just wanted to be sure this is not possible in my machine and I have to use live one.
– yasin
Dec 4 at 12:54
You are welcome! In addition. If you wanted to extend the/file system you can do this on the fly.
– Valentin Bajrami
Dec 4 at 12:59
Thanks a lot. I just wanted to be sure this is not possible in my machine and I have to use live one.
– yasin
Dec 4 at 12:54
Thanks a lot. I just wanted to be sure this is not possible in my machine and I have to use live one.
– yasin
Dec 4 at 12:54
You are welcome! In addition. If you wanted to extend the
/ file system you can do this on the fly.– Valentin Bajrami
Dec 4 at 12:59
You are welcome! In addition. If you wanted to extend the
/ file system you can do this on the fly.– Valentin Bajrami
Dec 4 at 12:59
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f485867%2fhow-to-resize-lvm-partition%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
ext4will allow you to grow the file system while mounted. Shrinking requires the file system to be unmounted. Do you want to grow the partition, or shrink it?– Haxiel
Dec 4 at 11:13
@Haxiel, thank you for response. Would you please tell me both growing and shrinking solutions?
– yasin
Dec 4 at 11:37
2
You cannot shrink the root filesystem online. You will need to boot from some rescue medium so that you can access the root filesystem while it is not mounted.
– wurtel
Dec 4 at 12:34
1
@Panki. This is fairly easy. You need to boot from a
Live USBor aLive CD. This doesn't have to match your current OS though. Then once you've booted you can just runlvresize -r -L -5G /dev/mapper/debian-vg-rootThis will perform the shrinking of the file system as well as the disk size– Valentin Bajrami
Dec 4 at 12:36
1
Where
-5Gis your desired number of gibibytes to shrink!– Valentin Bajrami
Dec 4 at 12:37