You are not logged in.
Hello everyone,
I am writing because I would like to slightly diminish the size of my root partition in order to give more room to my "Virtual" partition, where I keep my VMBox Windows 7.
I have been reading some posts, in particular this on archlinux, but since it is quite a tricky thing, I prefer to ask you all for advice.
Doing
sudo fdisk -l
I get
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0008b208
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 976895 487424 83 Linux
/dev/sda2 976896 1855858687 927440896 8e Linux LVM
/dev/sda3 1855858688 1953523711 48832512 83 Linux
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ca9c3
Device Boot Start End Blocks Id System
/dev/sdb1 2048 976773119 488385536 83 Linux
Disk /dev/mapper/Homepc-root: 50.0 GB, 49996103680 bytes
255 heads, 63 sectors/track, 6078 cylinders, total 97648640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/Homepc-root doesn't contain a valid partition table
Disk /dev/mapper/Homepc-swap: 7998 MB, 7998537728 bytes
255 heads, 63 sectors/track, 972 cylinders, total 15622144 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/Homepc-swap doesn't contain a valid partition table
Disk /dev/mapper/Homepc-home: 891.7 GB, 891700641792 bytes
255 heads, 63 sectors/track, 108409 cylinders, total 1741602816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/Homepc-home doesn't contain a valid partition table
Basically, when I look at things on Gparted, I have one drive, which is divided in three sections sda1, which is boot, sda2, which is lvm2 pv with Vanilla Debian plus Xfce (which gparted says is all full, but i actually have inside more than a 100 GB) and sda3 which is the xfs Virtual partition where I have the VMbox files. I also have another drive, sdb, where I keep media files.
If I load Windows 7 on the VMBox everything works well, and it gives me 11GB of free space, but in the same Virtual partition I also have a shared folder (that I use to share files with Debian, I haven't tired Samba yet), which is a bit too tiny, and now that I have installed some new software the VMBox doesn't let me take a snapshot of the system, so basically I have to boot the virtual OS every time.
What do you think would be the best thing to do in a situation like mine?
Are there ways to avoid having to resize all?
Thank you
Last edited by clemens (2016-01-30 10:17:44)
Offline
Thank you,
I will try as you suggest, it seems a much saver option
By the way, lsblk gives
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part /media/9d30e191-ddb7-4f6f-9e8
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 476M 0 part /boot
├─sda2 8:2 0 884.5G 0 part
│ ├─Homepc-root (dm-0) 254:0 0 46.6G 0 lvm /
│ ├─Homepc-swap (dm-1) 254:1 0 7.5G 0 lvm [SWAP]
│ └─Homepc-home (dm-2) 254:2 0 830.5G 0 lvm /home
└─sda3 8:3 0 46.6G 0 part /Virtual
Offline
Hello, I am about to try what you kindly suggested
Suggestion: Move the contents of sda3 onto sdb or an external disk, make sda3 a LVM PV and extend your original VG using it, shrink whatever LV in the VG you can, and create a new LV on which you put XFS on the newly freed space in the volume group plus on whatever space the old sda3 partition took.
I am writing the process here a little bit less concisely, to see if I understood correctly and eventually to help other newbies like me.
1. copy the /Virtual partition elsewhere safe
2. delete? the contents of the sda3 /Virtual partition
3. change the sda3 /Virtual partition from its original xfs form to a lvm2 pv
4. extend sda2 (which is lvm2 pv and has 3 logical volumes: root, home and swap) over sda3
5. ?? shrink whatever LV in the VG you can ?? does it mean to put all the LV inside the same VG? What would that be in my case?
6. create, inside sda2, a new logical volume with a xfs file system, as big as necessary to use the Virtual Box and the shared files without problems
7. copy in the new xfs logical volume the folders originally in the /Virtual partition
Thank you
Offline
Thank you for the extra information, now I understand better. By the way is there a way to do what you suggest with a GUI (GParted?) and not through command line?
And do I need to unmount the volume, i.e. boot in live mode to do the changes?
Thank you
Offline
Hello, still on the same thing, just a bit unsure.
I did all you kindly advised up until point 4 above (changing the sda3 and adding it to the volume group, using first the command and then a software called logical Volume Management).
I am ready to run the live version to do the other changes, but I am perplexed by the fact that sda3 is now listed as "part" not lvm.
On the logical Volum Management screen, I get sda3 as Unused Space.
Furthermore, if I navigate in /Virtual with Thunar, I see Free Space:4,8 GB. If I check with GParted, I see xfs_db:/dev/sda3 is not a valid XFS filesystem (unexpected SB magic number 0x00000000), which i guess is normal given that I changed it. The size also seems correct, 46,57 GB
root@Homepc:/home/homepc# pvcreate /dev/sda3
Writing physical volume data to disk "/dev/sda3"
Physical volume "/dev/sda3" successfully created
root@Homepc:/home/homepc# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 476M 0 part /boot
├─sda2 8:2 0 884.5G 0 part
│ ├─Homepc-root (dm-0) 254:0 0 46.6G 0 lvm /
│ ├─Homepc-swap (dm-1) 254:1 0 7.5G 0 lvm [SWAP]
│ └─Homepc-home (dm-2) 254:2 0 830.5G 0 lvm /home
└─sda3 8:3 0 46.6G 0 part
sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part /media/9d30e191-ddb7-4f6f-9e8
Last edited by clemens (2016-01-30 21:14:04)
Offline
Strangely, even after the commands you suggest, I get:
sudo vgdisplay
--- Volume group ---
VG Name Homepc
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 931.04 GiB
PE Size 4.00 MiB
Total PE 238346
Alloc PE / Size 226425 / 884.47 GiB
Free PE / Size 11921 / 46.57 GiB
VG UUID 0Qwnnm-LQIJ-JLuL-gDPt-BOQm-pGLy-uTgRlw
Which I guess is the original VG plus the new part (sda3)
Last edited by clemens (2016-01-31 12:45:27)
Offline
Yes. That seems to add up:
sda1: 0.5 GiB
sda2: 885 GiB
sda3: 46 GiB
------- ----------
total 931 GiB
Check (or post) your /etc/fstab please.
Offline
Thank you again for your patience and help.
the fstab is
# /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>
/dev/mapper/Homepc-root / ext4 errors=remount-ro 0 1
# /Virtual was on /dev/sda3 during installation
UUID=30bdf9f5-053b-400b-a5c7-8a2c013c183e /Virtual xfs defaults 0 2
# /boot was on /dev/sda1 during installation
UUID=fdbe8bc1-9484-4030-98fa-5eed47434721 /boot ext4 defaults 0 2
/dev/mapper/Homepc-home /home ext4 defaults 0 2
/dev/mapper/Homepc-swap none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/sdb1 /media/9d30e191-ddb7-4f6f-9e87-7dcc1effea7e ext4 defaults 0 2
Offline
Your fstab is still set to mount /dev/sda3 on /Virtual.
You would create a new logical volume on the volume group the space of which is now being provided by both sda2 and sda3 instead of just sda2. On the new logical volume, you would, as you said, create a XFS file system.
Do the above, then
change your fstab to mount the new logical volume on /Virtual.
Then you should be able to restore your data to /Virtual.
Offline
Thank you.
I hope I don't look too pedantic or dull, I am simply scared since it's the first time and don't have the option of backing up 1TB of stuff.
Just to make sure:
1. I should now reboot on a live CD and shrink the LV home and expand the unused space
I am not exactly sure how to do it, especially the distinction between shrinking the filesystem and the block (http://www.microhowto.info/howto/reduce_the_size_of_an_ext2_ext3_or_ext4_filesystem.html the first line in bold is quite scary!!)
2. Reboot normally, hopefully the home volume is intact and smaller, and the Unused Space part should now be bigger
3. Create in this unused part a new logical volume with a xfs filesystem and call it /Virtual
4. Change the fstab section
# /Virtual was on /dev/sda3 during installation
UUID=30bdf9f5-053b-400b-a5c7-8a2c013c183e /Virtual xfs defaults 0 2
to
/dev/mapper/Homepc-virtual /Virtual xfs defaults 0 2
I am not exactly sure about the Homepc-virtual bit, but I thought like that because it belongs to the same VG.
Thank you
Last edited by clemens (2016-01-31 16:23:57)
Offline
I am still scared to start, I have to properly understand the filesystem and block shrinking and the filesystem check. in the meantime I am backing up as much as possible.
Just to see what would happen, I tried running the Virtual Box, which was in /Virtual and curiously it still works, even if I don't find anything in the folder with Thuanar. The shared folder (to use files with Debian and Windows) disappeared.
Offline
Thank you all for your help and patience.
After doing lots of reading and backing up as much as possible, I am now actually trying!!
Here is a link to the process of reducing the size of a LVM: in my opinion it is the easiest to follow for newbies such as myself and I hope it can be useful to others as well.
http://www.tecmint.com/extend-and-reduce-lvms-in-linux/
One good thing to remember, taken from here, is that
When we reduce the size of the actual volume in the next step, it’s critical that the new size is greater than or equal to the size of the file system. After reading the documentation for both resizefs and lvreduce, I still haven’t been able to find out whether they’re using standard computer gigabytes (1024^3 bytes) or drive manufacturer gigabytes (1000^3 bytes). In this case, the difference is very important. To be on the safe side, we’ll just shrink the file system a bit more than necessary and expand it to use the full space available later.
I am keeping track of all the passages copying from the terminal, in case something goes wrong (hopefully nothing bad will happen) I will post the data here.
Cheers
by the way, from here
Definitions
PV : Hard disk, hard disk partitions , RAID or LUNs from a SAN form "physical volumes" ( or PV).
VG : for "volume groups" corresponds to PV groups.
LV : is under volumes of VG , it is a virtual partition.
PE : to be manipulated, datas are divided by block of data called Physical Extents.
LE : same things than the PE but at logical level (Logical Extent). The size of blocks are the same for each logical volume (LV) in a same volume group (VG).
Last edited by clemens (2016-02-01 17:47:45)
Offline
Everything seems to have gone well.
I will now reboot and then I just have to figure out how to make the /Virtual lvm out of the unused space in sda2 and sda3.
EDIT: Hurray, I managed.
After rebooting, I started system-config-lvm, which has a nice and easy to understand gui that can be used quite intuitively.
I went to the Logical View section, which is colored light blue, and selected "Create New Logical Volume". I chose to use all the available space, to have a XFS file system and to mount on /Virtual, as the previous partition.
Now I just need to copy everything back and try it.
EDIT2: Yes, all worked fine!!
Thank you all for your help.
Last edited by clemens (2016-02-01 21:26:42)
Offline