Hot answers tagged

175

In solving this issue, the information provided at http://www.ivarch.com/blogs/oss/2007/01/resize-a-live-root-fs-a-howto.shtml was pivotal. However, that guide is for a very old version of RHEL, and various information was obsolete. The instructions below are crafted to work with CentOS 7, but they should be easily enough transferable to any distro that ...


57

How mature and featureful is LVM RAID? LVM-RAID is actually mdraid under the covers. It basically works by creating two logical volumes per RAID device (one for data, called "rimage"; one for metadata, called "rmeta"). It then passes those off to the existing mdraid drivers. So things like handling disk read errors, I/O load balancing, etc. should be fairly ...


45

You can do this fairly simply. Kinda surprised there wasn't an answer for this here already. You can do this entire process while running on the filesystem you want to resize (yes, it's safe and fully supported). There is no need for rescue CDs or alternate operating systems. Resize the partition (again, you can do this with the system running). GParted is ...


38

I just had a similar problem to what you describe, though for me it happened when I was attempting to install the new Ubuntu 11.10 Oneiric Ozelot to an LVM volume. I had done the following to set lvm up on a live boot system (the logical volumes I needed were already present): apt-get install lvm2 vgscan --mknodes -v Now lvscan -v showed my volumes but ...


34

Of course the primary goal is not to have the need to use swap in the first place... The main thing is to create the swap LVM volume when the system is still quite fresh, the same as when you create a swap file, as swap space performs best when it is contiguous, or enforce that with lvcreate -C option. You don't want to actual disk blocks that make up the ...


33

The entries in /dev/mapper are LVM logical volumes. You can think of these as Linux's native partition type. Linux can also use other partition types, such as PC (MBR or GPT) partitions. Your disk is divided in MBR partitions, one of which (/dev/sda2) is an LVM physical volume. The LVM physical volume is the single constituent of the volume group ...


32

A few more steps are needed when mounting an LVM partition vs. a non-LVM partition. sudo apt-get install lvm2 #This step may or may not be required. sudo pvscan #Use this to verify your LVM partition(s) is/are detected. sudo vgscan #Scans for LVM Volume Group(s) sudo vgchange -ay #Activates LVM Volume Group(s) ...


31

You can use pvmove to move those extents to the beginning of the device or another device: sudo pvmove --alloc anywhere /dev/device:60000-76182 Then pvmove chooses where to move the extents to, or you can specify where to move them. See pvs -v --segments /dev/device to see what extents are currently allocated.


29

These are the steps required to resize an LVM or LVM2 partition: sudo lvresize --verbose --resizefs -L -150G /dev/ubuntu/root sudo pvresize --setphysicalvolumesize {any size here} /dev/sda5 The last command, pvresize, may yield the error /dev/sda5: cannot resize to xxxxx extents as later ones are allocated. You have to rearrange the unallocated space at ...


29

From this link: Normally, each LVM command issues a disk scan to find all relevant physical volumes and to read volume group metadata. However, if the metadata daemon is running and enabled, this expensive scan can be skipped ... This can save a significant amount of I/O and reduce the time required to complete LVM operations, particularly on systems ...


25

For newer versions of ubuntu, for example, 14.04, I found a combination of @dragly and this blogposts' answers very helpful. To paraphrase: (On server) Install Dropbear sudo apt-get install dropbear (On server) Copy and assign permissions for root public/private key login sudo cp /etc/initramfs-tools/root/.ssh/id_rsa ~/. sudo chown user:user ~/id_rsa ...


25

There're handy dmsetup ls --tree and lsblk utils.


23

A guide to do such a setup with BusyBox and Dropbear is shown in this blog post. early-ssh didn't work for me and is apparently not needed anymore. I have summarized what you need to do in the following. For more details, have a look at the post above: Install BusyBox and Dropbear on your server sudo apt-get install dropbear busybox Update your initramfs ...


23

I suggest using a different testing method. hdparm is a bit weird as it gives device addresses rather than filesystem addresses, and it doesn't say which device those addresses relate to (e.g. it resolves partitions, but not devicemapper targets, etc.). Much easier to use something that sticks with filesystem addresses, that way it's consistent (maybe except ...


22

I ran across the same issue just now, and found another workaround. Basically, it involves making the hosts /run directory available to the guest. First, we mount /run where it can be accessed by the guest. I will assume that your install partition is mounted at /mnt mkdir /mnt/hostrun mount --bind /run /mnt/hostrun Then, we chroot into the guest, and ...


21

"It depends." If you are on an environment that you control (vmware or kvm or whatever), and can make your own decisions about disk performance QoS, then I'd recommend not using LVM inside your VMs. It doesn't buy you much flexibility that you couldn't get at the hypervisor level. Remember, the hypervisor is already effectively performing these tasks. If ...


20

If you are using lvm and systemd do: systemctl enable lvm2-lvmetad.service systemctl enable lvm2-lvmetad.socket systemctl start lvm2-lvmetad.service systemctl start lvm2-lvmetad.socket BTW this is grub related as well. I think grub gets kernel parameter root from /run/lvm/lvmetad.socket. Wasn't patient to test all this in detail as it worked out to ...


19

RHEL6 LVM Admin Guide According to the RHEL 6 Logical Volume Administration Guide it's recommended that if you're going to use an entire drive as a physical volume in a LVM volume group, that you should still partition it: excerpt from the guide "RHEL6 Logical Volume Manager Administration LVM Administrator Guide" 2.1.2. Multiple Partitions on a Disk ...


17

One volume group solution: pvcreate /dev/sdb vgextend vg0 /dev/sdb pvmove -n /dev/vg0/bar /dev/sda /dev/sdb Two volume group solution: pvcreate /dev/sdb vgcreate vg1 /dev/sdb lvcreate -l100%FREE vg1 mkfs -t ext4 /dev/vg1/lvol1 mount /dev/vg1/lvol1 /mnt Now difficult part, all activities MUST stop on /bar: cd /mnt ; ( cd /bat ; tar cf - * ) | ...


17

It is not something I would do online but I think it is possible. I guess you are using ext4. umount /home $ umount /home shrink the /home filesystem $ fsck -f /dev/mapper/VolGroup-lv_home $ resize2fs /dev/mapper/VolGroup-lv_home 80G shrink the /home logical volume $ lvreduce -L -40G /dev/mapper/VolGroup-lv_home resize the /home partition to the size ...


16

Have a look at the cryptsetup readme for this in /usr/share/doc/cryptsetup/README.remote.gz (Ubuntu package cryptsetup). In there is a full guide to accomplish this. It is similar to dragly's answer, but I think this is a bit more elegant. (Dropbear formatted keys, passing the passphrase via a FIFO rather than a fragile shell script, etc.) unlocking ...


15

You have to pay attention to UUIDs . For instance, this is my configuration: # lsblk -o name,uuid,mountpoint ├─sda2 727fa348-8804-4773-ae3d-f3e176d12dac │ └─sda2_crypt (dm-0) P1kvJI-5iqv-s9gJ-8V2H-2EEO-q4aK-sx4aDi │ ├─debian_crypt-swap (dm-1) 3f9f24d7-86d1-4e21-93e9-f3c181d05cf0 [SWAP] │ ├─debian_crypt-tmp (dm-2) ...


14

On Debian (and hopefully your distro as well) all the LVM metadata is already loaded into udev (by some of the rules in /lib/udev/rules.d). So you can use a rules file like this: $ cat /etc/udev/rules.d/92-local-oracle-permissions.rules ENV{DM_VG_NAME}=="vgRandom" ENV{DM_LV_NAME}=="ora_users_*" OWNER="oracle" ENV{DM_VG_NAME}=="vgRandom" ENV{DM_LV_NAME}=="...


14

When you're using ext4, you can check for badblocks with the command e2fsck -c /dev/sda1 or whatever. This will "blacklist" the blocks by adding them to the bad block inode. e2fsck -c runs badblocks on the underlying hard disk. You can use the badblocks command directly on a LVM physical volume (assuming that the PV is in fact a hard disk, and not some ...


14

Does pvcreate /dev/sdb write any metadata to /dev/sdb? if so what is written? Yes, but it's not much more than some header and identification data to mark the block device as an LVM PV. The "real" metadata comes when you create volume groups. Where does vgcreate data /dev/sdb /dev/sdc store configuration of the volume group? On each physical volume that ...


14

Same as you would with any other block device. e.g. file -s /dev/vg1/lv1 If it's ext4, it'll say something like: /dev/vg1/lv1: Linux rev 1.0 ext4 filesystem data, UUID=xxxx, volume name "yyyy" (needs journal recovery) (extents) (large files) (huge files) Alternatively, you could run blkid /dev/vg1/lv1. That would report something like: /dev/vg1/lv1: ...


13

You don't have to export the VG, that's used to migrate a VG from one system to another. Simply vgchange -an vgname to deactivate all logical volumes on the volume group you wish to unplug. Later, after plugging the device back in, vgchange -ay vgname will reactivate all logical volumes in your vgname VG and then you can mount LVs and use. Device ...


13

A volume group consists of whole physical volumes. A physical volume consists of many extents (an extent is typically 4MB); each extent may belong to a different logical volume. To transfer a logical volume to a different group, you cannot simply transfer extents, because that might split the physical volume between the source VG and the target VG. What you ...


13

Well, that was embarrassing. BTRFS needs to be mounted to be able to resize the partition. How do I resize a partition? (shrink/grow) In order to demonstrate and test the back references, Btrfs devel team has added an online resizer, which can both grow and shrink the filesystem via the btrfs commands. First, ensure that your filesystem is ...


Only top voted, non community-wiki answers of a minimum length are eligible