Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/blocksPublic

Enable bcache or LVM on existing block devices

License

NotificationsYou must be signed in to change notification settings

g2p/blocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conversion tools for block devices.

Convert between raw partitions, logical volumes, and bcache deviceswithout moving data.blocks shuffles blocks and sprouts superblocks.

LVM conversion

blocks to-lvm (alias:lvmify) takes a block device (partition orwhole disk) containing a filesystem, shrinks the filesystem by a smallamount, and converts it to LVM in place.

The block device is converted to a physical volume and the filesystem isconverted to a logical volume. If--join=<VG> is used the volumesjoin an existing volume group.

An LVM conversion can be followed by other changes to the volume,growing it to multiple disks withvgextend andlvextend, orconverting it to various RAID levels withlvconvert --type=raidN -m<extra-copies>.

bcache conversion

blocks to-bcache converts a block device (partition, logical volume,LUKS device) to use bcache. If--join=<cset-uuid> is used the devicejoins an existing cache set. Otherwise you will need tocreateand attach the cache devicemanually.

blocks will pick one of several conversion strategies:

  • one for partitions, which requires a shrinkable filesystem or free spaceimmediately before the partition to convert. Converting alogical partitionto bcache is not supported: ifblocks complains about overlapping metadatain the middle of the disk, pleaseuse gdisk to convert your MBR disk to GPTand reinstall your bootloader before proceeding with the bcache conversion.
  • one for LUKS volumes
  • one for LVM logical volumes

When the first two strategies are unavailable, you can still convertto bcache by converting to LVM first, then converting the new LV tobcache.

You will need to install bcache-tools, which is available here:

Conversion makes no demands on the kernel, but to use bcache, you needLinux 3.10 or newer.My own branch currently addsresizing support on top ofKent Overstreet's upstream branch.

maintboot mode

Maintboot mode (blocks to-bcache --maintboot) is an easier wayto convert in-use devices that doesn't require a LiveCD.maintboot will runthe conversion from an in-memory boot environment.This is currently tested on Ubuntu; ports to otherdistributions are welcome.

Ubuntu PPA (13.10 and newer)

You can install python3-blocks from a PPA and skip the restof the installation section.

sudo apt-get install software-properties-commonsudo add-apt-repository ppa:g2p/storagesudo apt-get updatesudo apt-get install python3-blocks bcache-tools

Requirements

Python 3.3, pip and Git are required before installing.

You will also need libparted (2.3 or newer, library and headers) andlibaugeas (library only, 1.0 or newer).

On Debian/Ubuntu (Ubuntu 13.04 or newer is recommended):

sudo aptitude install python3.3 python3-pip git libparted-dev libaugeas0 \    pkg-config libpython3.3-dev gccsudo aptitude install cryptsetup lvm2 liblzo2-dev \    nilfs-tools reiserfsprogs xfsprogs e2fsprogs btrfs-tools  # optionaltype pip-3.3 || alias pip-3.3='python3.3 -m pip.runner'

Command-line tools for LVM2, LUKS, bcache (see above), filesystemresizing (see below for btrfs) are needed if those formats are involved.Kernel support isn't required however, so you can do bcache conversionsfrom a live-cd/live-usb for example.

For btrfs resizing, you need a package that providesbtrfs-show-super,or you can install from source:

Installation

pip-3.3 install --user -r <(wget -O- https://raw.github.com/g2p/blocks/master/requirements.txt)cp -lt ~/bin ~/.local/bin/blocks

Usage

Converting your root filesystem to LVM

Install LVM.

Edit your/etc/fstab to refer to filesystems by UUID, and regenerateyour initramfs so that it picks up the new tools.

With grub2, you don't need to switch to a separate bootpartition, but make sure grub2 installslvm.mod inside your/boot.

Make sure your backups are up to date, boot to live media (Ubuntu raringliveusb is a goodchoice), install blocks, and convert.

Converting your root filesystem to bcache

Install bcache-tools and a recent kernel (3.10 or newer).If your distribution uses Dracut (Fedora), you need Dracut 0.31 or newer.

Edit your/etc/fstab to refer to filesystems by UUID, and regenerateyour initramfs so that it picks up the new tools.On Debian and Ubuntu, this is done withupdate-initramfs -u -k all.With Dracut (Fedora), this is done withdracut -f.Arch Linux users should enable the bcache hook inmkinitcpio.confand rerunmkinitcpio.If you don't see your distribution in this list, you are welcome toportthis hookto your distribution's preferred tools and contribute a patch to bcache-tools.Having working bcache support in your initramfs is important, as your systemwill be unbootable without.

Edit yourgrub.cfg to refer to filesystems by UUID on the kernelcommand-line (this is often the case, except when you are already usingLVM, in which caseupdate-grub tends to write a logical path). Makesure you have a separate/boot partition.

  1. If you don't have a cache device yet, create it on an empty SSD (or on aproperly aligned partition or LV on top of it; LVM's 4MiB alignment issufficient, as is the 1MiB alignment of modern partitioning tools).

     sudo make-bcache -C /dev/<cache-device>

    This will give you a cache-set uuid.

  2. If you already have a cache device

     ls /sys/fs/bcache

    And copy the cache-set uuid.

  3. Finally, if you have a maintboot-compatible distribution, run:

     sudo blocks to-bcache --maintboot /dev/<root-device> --join <cset-uuid>

    If you are using encryption, use the encrypted device as the root device sothat cache contents are also encrypted.

  4. Otherwise,make sure your backups are up to date, boot to live media (Ubuntu raringliveusb is a goodchoice), install blocks, and convert.

bcache on a fresh install

When using a distribution installer that doesn't support bcacheat the partitioning stage, make sure the installer creates aseparate/boot partition. Install everything on the HDD,using whatever layout you prefer (but I suggest LVM if you wantmultiple partitions).

Once the installer is done, you can follow the steps atconverting your root filesystem to bcache.

Subcommand help

blocks --helpblocks <subcommand> --help

Ifblocks isn't in the shell's command path, replace with:

sudo python3.3 -m blocks

Build status

Build Status

About

Enable bcache or LVM on existing block devices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp