These commands create a single partition that fills the entire disk /dev/sde:

# parted /dev/sde mklabel msdos# parted -- /dev/sdemkpart primary ext2 1 -1

In this case, the partition will be /dev/sde1.

You can then add that PV to an existing volume group:

# vgextend main /dev/sde1

Volume group 'main' successfully extended

6.1.1.3.9. Removing a partition

The vgreduce command is used to reduce the size of a volume group by removing a physical volume. It will fail if any space on the PV is in use:

# vgreduce main /dev/sdb1

Physical volume '/dev/sdb1' still in use

In this case, an attempt to remove /dev/sdb1 from the volume group main failed. To move the data off a PV (assuming that there is sufficient space available on other PVs in the volume group), use the pvmove command:

# pvmove /dev/sde1 /dev/sde1: Moved: 100.0%

Depending on the amount of date to be moved, this operation can take quite a while to run. When it is complete, you can remove the physical volume:

# vgreduce main /dev/sdb1

Removed '/dev/sdb1' from volume group 'test'

You can then use that partition for other uses. If you want to erase the LVM disk label, use the pvremove command:

# pvremove /dev/sde1

Labels on physical volume '/dev/sde1' successfully wiped

6.1.1.4. Managing LVM in single-user mode

Some filesystems, such as those containing /var or /etc , may be in use anytime the system is booted normally. This prevents the use of resize2fs to shrink ext2 and ext3 filesystems or to grow them large enough to exceed the block group descriptor table.

To use resize2fs on these filesystems, you must use runlevel s , which is single-user mode. Boot your system, and press the spacebar when the GRUB boot screen appears. Press the A key to append text to the boot line; then type s and press Enter. After a few seconds, a root shell prompt will appear ( sh-3.1# ).

At this shell prompt you can unmount the filesystem, then use fsck , resize2fs , and lvreduce (or lvextend ). For example, to reduce the size of /home to 925 MB:

sh-3.1# umount /home

sh-3.1# fsck -f /dev/main/home

e2fsck 1.38 (30-Jun-2005)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/main/home: 121/256000 files (2.5% non-contiguous), 12704/262144 blocks

sh-3.1# resize2fs /dev/main/home 900M

resize2fs 1.38 (30-Jun-2005)

Resizing the filesystem on /dev/main/home to 230400 (4k) blocks.

The filesystem on /dev/main/home is now 229376 blocks long.

sh-3.1# lvreduce /dev/main/home --size 950 M

Rounding up size to full physical extent 952.00 MB

WARNING: Reducing active logical volume to 952.00 MB

THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce home? [y/n]: y

Reducing logical volume home to 952.00 MB

Logical volume home successfully resized

sh-3.1# resize2fs /dev/main/home

resize2fs 1.38 (30-Jun-2005)

Resizing the filesystem on /dev/main/home to 243712 (4k) blocks.

The filesystem on /dev/main/home is now 243712 blocks long.

The warning message displayed by lvreduce is accurate: if you set the logical volume size smaller than the filesystem size, you will lose data! Be extremely careful when resizing volumes; it's a good idea to back up your data first.

If your system has the default Volume Group and Logical Volume names, substitute the correct name (such as /dev/VolGroup00/LogVol00) for /dev/main/home. The problem is that it's hard to keep the logical volume names straightwhich is why I recommend using more meaningful names. 

Note that, as before, the filesystem was resized to be slightly smaller than the desired size, then expanded to fill the LV after the LV was resized.

When you're done, type reboot or press Ctrl-Alt-Delete to restart the system.

Вы читаете Fedora Linux
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату