From Wildsong Wiki
Jump to: navigation, search

Set up two thumb drives as one volume. (For Ray)

Find out where the drives are mounted using df I can see that the system software is on /dev/sda1

Looks like you already started doing a few things because I can see

 PV /dev/sdb1   VG 128flash1   lvm2 [116.37 GiB / 0    free]
 PV /dev/sdd1   VG 128flash1   lvm2 [116.37 GiB / 760.00 MiB free]
 Total: 2 [232.74 GiB] / in use: 2 [232.74 GiB] / in no VG: 0 [0   ]

shows me that the 2 flash drives have already been put in the volume group "128flash1" and with

  ACTIVE            '/dev/128flash1/Two128GB_as_One' [232.00 GiB] inherit

I can see there is a logical volume called "Two128GB_as_One" and the logical volume is mounted at

/dev/mapper/128flash1-Two128GB_as_One on /media/256GB_as_One type ext4 (rw)

So I guess this section is "for Brian"! If there were nothing set up already

Recipe to set up two thumb drives as a single volume using LVM

1. Mark the drives are physical volumes to be used by LVM

pvcreate /dev/sdb1
pvcreate /dev/sdd1

2. Add the drives to a volume group, choose a name to identify the group (Ray used "128flash1")

vgcreate 128flash1 /dev/sdb1 /dev/sdd1

3. Create a logical volume; thats a lower case L in the option -l and 100%VG says "use all the space in the volume group"

lvcreate Two128GB_as_One -l100%VG 128flash1

4. Now you should be able to use it just like a single drive with

mkfs.ext4 /dev/128flash1/Two128GB_as_One
mkdir /data
mount /dev/128flash1/Two128GB_as_One /data

It looks like in your case the device mapper found it and put it at /media/Two128GB_as_One; that works too.

Add a drive to an existing logical volume

I have not done this yet and can't test right now... TEST IT YOURSELF seems like you should be able to add a drive to the volume group and then expand the file system to fill the larger drive?

Say you added /dev/sdg (and it is already partitioned), so make a new physical volume

pvcreate /dev/sdg1

then add it to the volume group

vgextend 128flash1 /dev/sdg1

then expand the logical volume (which no longer has a meaningful name!)

lvextend -l100%VG Two128GB_as_One

then resize the filesystem to fill the new space

resize2fs /dev/128flash1/Two128GB_as_One

Recipe to examine system

For example, you know LVM is in use but don't know how it's set up.

[email protected]:/mnt# pvscan
  PV /dev/md127   VG vg_mirror   lvm2 [1.82 TiB / 0    free]
  Total: 1 [1.82 TiB] / in use: 1 [1.82 TiB] / in no VG: 0 [0   ]
[email protected]:/mnt# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_mirror" using metadata type lvm2
[email protected]:/mnt# lvscan
  ACTIVE            '/dev/vg_mirror/lv_mirror' [1.82 TiB] inherit
mount /dev/vg_mirror/lv_mirror /mnt

Recipe to rename a volume group

I have two disks (one is a 'dd' copy of the other) and so they have identical volume names '/dev/magnia'. How do I change one?

Short answer: It is impossible. Using the UUID does not work!

Long answer: you have to have only one drive hooked up, boot from a rescue disk, and do it there. This sucks.

How do I shrink everything to fit on a smaller hard drive?

Figure out what space you want to make the partition before you start.

Preen: fsck /dev/magniatmp/root

Remove journal, turning the filesystem from ext3 to ext2

tune2fs -O ^has_journal /dev/magniatmp/root

Preen again:

e2fsck -f /dev/magniatmp/root

Resize the filesystem:

resize2fs /dev/magniatmp/root 10000M

Note the block count and size returned by resize command: 2560000 and 4k

There is also a swap space on this volume group, I can remove it for now and recreate it later.

lvremove /dev/magniatmp/swap_1

Figure out the new size

bc 2560000*4

Resize the logical volume

lvresize -L 10240000 /dev/magniatmp/root

Create new journal to convert back to ext3:

tune2fs -j /dev/magniatmp/root

Shrink the physical volume

pvresize --setphysicalvolumesize 19G /dev/sdb5

Delete the partitions and re-create them smaller.

fdisk /dev/sdb