aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSilvino Silva <silvino@bk.ru>2016-09-29 06:00:51 +0100
committerSilvino Silva <silvino@bk.ru>2016-09-29 06:00:51 +0100
commit06cdcb2394536ef134907e658dc1d558a09a277e (patch)
tree3fda22d99e09005a8f3ff7dc43e8f9bcf293262d /tools
parent17bc450495c9ab6933590fb825dbd80b0af64a66 (diff)
parent68834c562daf06b8625eea5c5b18430f594cea17 (diff)
downloaddoc-06cdcb2394536ef134907e658dc1d558a09a277e.tar.gz
Merge branch 'f-lvm' into develop
Diffstat (limited to 'tools')
-rw-r--r--tools/index.html12
-rw-r--r--tools/lvm.html151
-rw-r--r--tools/storage.html345
3 files changed, 169 insertions, 339 deletions
diff --git a/tools/index.html b/tools/index.html
index 407d212..d20ccfa 100644
--- a/tools/index.html
+++ b/tools/index.html
@@ -78,9 +78,15 @@
</li>
<li><a href="storage.html">Storage</a>
<ul>
- <li><a href="storage.html#mv">Moving partitions</a></li>
- <li><a href="storage.html#lvm">LVM</a></li>
- <li><a href="storage.html#btrfs">BTRFS</a></li>
+ <li><a href="lvm.html">LVM</a>
+ <ul>
+ <li><a href="lvm.html#lvmpart">1. LVM partition</a></li>
+ <li><a href="lvm.html#pv">2. Create physical volume</a></li>
+ <li><a href="lvm.html#vg">3. Create volume group</a></li>
+ <li><a href="lvm.html#lv">4. Create logical volume</a></li>
+ <li><a href="lvm.html#maint">5. Maintenance</a></li>
+ </ul>
+ </li>
</ul>
</li>
<li><a href="syslog-ng.html">Syslog-ng</a>
diff --git a/tools/lvm.html b/tools/lvm.html
new file mode 100644
index 0000000..8b1624a
--- /dev/null
+++ b/tools/lvm.html
@@ -0,0 +1,151 @@
+<!DOCTYPE html>
+<html dir="ltr" lang="en">
+ <head>
+ <meta charset='utf-8'>
+ <title>LVM</title>
+ </head>
+ <body>
+
+ <a href="index.html">Tools Index</a>
+
+ <h1>LVM</h1>
+
+ <p>Read <a href="https://raid.wiki.kernel.org/index.php/RAID_setup">Raid Setup</a>,
+ the only thing you will need outside system is:
+ "Patience, Pizza, and your favorite caffeinated beverage.".
+ <a href="https://wiki.archlinux.org/index.php/Software_RAID_and_LVM">Arch Wiki</a>
+ article about Sofware RAID and LVM.</p>
+
+ <p>Basic idea behind RAID is to deal with independent disks
+ as an array of drives. Raid 0 uses two or more disks as one,
+ with performance gains without fault-tolerance. From raid 1
+ to 6 they offer diferent fault tolerance mechanisms.</p>
+
+ <p>LVM or Logic Volume Manager bring one more layer, read
+ <a href="http://www.tuxradar.com/content/lvm-made-easy">Lvm made easy</a>.
+ Partitions under lvm are easy to be resized, moved and there is
+ a tool to help encrypt. There is more freedom to name physical
+ disk names exp; production, development, backups...</p>
+
+
+ <p>Until now "from install" there is only one partition,
+ it is good idea to have a system with diferent partitions for each
+ propos. If is a "fresh install";</p>
+
+ <pre>
+ # cd /iso/crux/opt/
+ # pkgadd lvm2#2.02.107-1.pkg.tar.xz
+ #
+ </pre>
+
+ <h2 id="lvmpart">1. LVM Partition</h2>
+
+ <p>Create a LVM partition, fdisk should
+ show something like this;</p>
+
+ <pre>
+ # parted /dev/sda
+ </pre>
+
+ <p>I use defaults unless to define system partition last sector,
+ where in this example is size, +80G</p>
+
+
+ <h2 id="pv">2. Create physical volume</h2>
+
+ <pre>
+ # pvcreate /dev/sdb3
+ Physical volume "/dev/sdb3" successfully created
+ </pre>
+
+ <h2 id="vg">3. Create volume group</h2>
+
+ <pre>
+ # vgcreate vg_system /dev/sdb3
+ Volume group "vg_system" successfully created
+ # vgcreate homevg /dev/sdb4
+ Volume group "homevg" successfully created
+ #
+ </pre>
+
+ <h3>3.1. Search Volume Groups</h3>
+
+ <pre>
+ # vgscan
+ Reading all physical volumes. This may take a while...
+ Found volume group "homevg" using metadata type lvm2
+ Found volume group "vg_system" using metadata type lvm2
+ #
+ </pre>
+
+ <h2 id="lv">4. Create logical volume</h2>
+
+ <pre>
+ # lvcreate -L 15G -n distfileslv vg_system
+ Logical volume "distfileslv" created.
+ # lvcreate -L 8G -n packageslv vg_system
+ Logical volume "packageslv" created.
+ # lvcreate -L 4G -n swaplv vg_system
+ Logical volume "swaplv" created.
+ # lvcreate -L 80G -n homelv homevg
+ Logical volume "homelv" created.
+ #
+ </pre>
+
+ <pre>
+ # mkfs.ext4 /dev/vg_system/distfileslv
+ # mkfs.ext4 /dev/vg_system/packageslv
+ # mkswap /dev/vg_system/swaplv
+ # mkfs.ext4 /dev/homevg/homelv
+ </pre>
+
+ <h3>4.1. Activate Deactivate</h3>
+
+ <p>Deactivate logical volumes;</p>
+
+ <pre>
+ # lvchange -a -n /dev/vg_system/packageslv
+ # lvchange -a -n /dev/vg_system/distfileslv
+ # swapoff /dev/vg_system/sawplv
+ # lvchange -a -n /dev/vg_system/swaplv
+ </pre>
+
+ <p>Deactivate volume group;</p>
+
+ <pre>
+ # vgchange -a n vg_system
+ 0 logical volume(s) in volume group "vg_system" now active
+ #
+ </pre>
+
+ <p>Activate volume group;</p>
+ <pre>
+ # vgchange -a y vg_system
+ 3 logical volume(s) in volume group "vg_system" now active
+ #
+ </pre>
+
+ <h2 id="maint">5. Maintenance</h2>
+
+ <pre>
+ # smartctl -t long /dev/sdb1
+ # smartctl -a /dev/sdb1 | less
+ </pre>
+
+ <p><a href="https://wiki.archlinux.org/index.php/Badblocks">Non Destructive Test;</a></p>
+
+ <pre>
+ # badblocks -nsv /dev/sdb1
+ </pre>
+
+ <h2 id="encrypt">7. Encryption</h2>
+
+ <a href="index.html">Tools Index</a>
+ <p>
+ This is part of the c9-doc Manual.
+ Copyright (C) 2016
+ c9 team.
+ See the file <a href="../fdl-1.3-standalone.html">Gnu Free Documentation License</a>
+ for copying conditions.</p>
+ </body>
+</html>
diff --git a/tools/storage.html b/tools/storage.html
index 121c802..97b73b0 100644
--- a/tools/storage.html
+++ b/tools/storage.html
@@ -6,28 +6,11 @@
</head>
<body>
- <a href="index.html">Systools Index</a>
+ <a href="index.html">Tools Index</a>
<h1>Storage</h1>
- <h2 id="mv">Moving partitions</h2>
-
- <pre>
- var
- (parted) mkpart primary ext4 57GiB 200GiB
- </pre>
- <pre>
- swap
- (parted) mkpart primary linux-swap 29GiB 57GiB
- </pre>
- <pre>
- home
- (parted) mkpart primary ext4 57GiB 200GiB
- </pre>
- <pre>
- srv
- (parted) mkpart primary ext4 200GiB 100%
- </pre>
+ <h2 id="mv">1. Moving partitions</h2>
<p>Reboot into single-user mode where services aren't started and networking is offline.<p>
<pre>
@@ -35,13 +18,16 @@
</pre>
<p>Copy the data:</p>
- cp -apx /srv/* /mnt/srv
+
+ <pre>
+ # cp -apx /srv/* /mnt/srv
+ </pre>
<p>Rename directory, for later backup;</p>
<pre>
- mv /srv /srv.old
- mkdir /srv
+ # mv /srv /srv.old
+ # mkdir /srv
</pre>
<p>Edit the <a href="../conf/etc/fstab">/etc/fstab</a>file:</p>
@@ -53,320 +39,7 @@
<p>Reboot in normal mode.</p>
- <h2 id="lvm">1.2. LVM</h2>
-
- <p>Read <a href="https://raid.wiki.kernel.org/index.php/RAID_setup">Raid Setup</a>,
- the only thing you will need outside system is:
- "Patience, Pizza, and your favorite caffeinated beverage.".
- <a href="https://wiki.archlinux.org/index.php/Software_RAID_and_LVM">Arch Wiki</a>
- article about Sofware RAID and LVM.</p>
-
- <p>Basic idea behind RAID is to deal with independent disks
- as an array of drives. Raid 0 uses two or more disks as one,
- with performance gains without fault-tolerance. From raid 1
- to 6 they offer diferent fault tolerance mechanisms.</p>
-
- <p>LVM or Logic Volume Manager bring one more layer, read
- <a href="http://www.tuxradar.com/content/lvm-made-easy">Lvm made easy</a>.
- Partitions under lvm are easy to be resized, moved and there is
- a tool to help encrypt. There is more freedom to name physical
- disk names exp; production, development, backups...</p>
-
-
- <p>Until now "from install" there is only one partition,
- it is good idea to have a system with diferent partitions for each
- propos. If is a "fresh install";</p>
-
- <pre>
- # cd /iso/crux/opt/
- # pkgadd lvm2#2.02.107-1.pkg.tar.xz
- #
- </pre>
-
- <h3>Multiple Partition</h3>
-
- <p>Create a LVM partition, fdisk should
- show something like this;</p>
-
- <pre>
- # fdisk /dev/sdb
-
- Welcome to fdisk (util-linux 2.26.1).
- Changes will remain in memory only, until you decide to write them.
- Be careful before using the write command.
-
-
- Command (m for help): p
- Disk /dev/sdb: 232.9 GiB, 250059350016 bytes, 488397168 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
- Disklabel type: gpt
- Disk identifier: E37FE96F-9845-45A4-B6DA-BF3F8E47511A
-
- Device Start End Sectors Size Type
- /dev/sdb1 2048 8056 6009 3M BIOS boot
- /dev/sdb2 8192 18440191 18432000 8.8G Linux filesystem
-
- Command (m for help):
- </pre>
-
- <p>I use defaults unless to define system partition last sector,
- where in this example is size, +80G</p>
-
- <pre>
- Command (m for help): n
- Partition number (3-128, default 3):
- First sector (8057-488397134, default 18440192):
- Last sector, +sectors or +size{K,M,G,T,P} (18440192-488397134, default 488397134): +80G
-
- Created a new partition 3 of type 'Linux filesystem' and of size 80 GiB.
-
- Command (m for help):
-
- Command (m for help): t
- Partition number (1-3, default 3):
- Hex code (type L to list all codes): 23
-
- Changed type of partition 'Linux filesystem' to 'Linux LVM'.
-
- Command (m for help): n
- Partition number (4-128, default 4):
- First sector (8057-488397134, default 186212352):
- Last sector, +sectors or +size{K,M,G,T,P} (186212352-488397134, default 488397134):
-
- Created a new partition 4 of type 'Linux filesystem' and of size 144.1 GiB.
-
- Command (m for help): t
- Partition number (1-4, default 4):
- Hex code (type L to list all codes): 23
-
- Changed type of partition 'Linux filesystem' to 'Linux LVM'.
-
- Command (m for help): w
- The partition table has been altered.
- Calling ioctl() to re-read partition table.
- Syncing disks.
-
- #
- </pre>
-
- <h3>Create Phisical Volume</h3>
-
-
- <pre>
- # pvcreate /dev/sdb3
- Physical volume "/dev/sdb3" successfully created
- #
- # pvcreate /dev/sdb4
- Physical volume "/dev/sdb4" successfully created
- #
- </pre>
-
- <h3>Create Volume Group</h3>
-
- <pre>
- # vgcreate systemvg /dev/sdb3
- Volume group "systemvg" successfully created
- # vgcreate homevg /dev/sdb4
- Volume group "homevg" successfully created
- #
- </pre>
-
- <h3>Create Logical Volume</h3>
-
- <pre>
- # lvcreate -L 15G -n distfileslv systemvg
- Logical volume "distfileslv" created.
- # lvcreate -L 8G -n packageslv systemvg
- Logical volume "packageslv" created.
- # lvcreate -L 4G -n swaplv systemvg
- Logical volume "swaplv" created.
- # lvcreate -L 80G -n homelv homevg
- Logical volume "homelv" created.
- #
- </pre>
-
- <pre>
- # mkfs.ext4 /dev/systemvg/distfileslv
- # mkfs.ext4 /dev/systemvg/packageslv
- # mkswap /dev/systemvg/swaplv
- # mkfs.ext4 /dev/homevg/homelv
- </pre>
-
- <h3>Activate Deactivate</h3>
-
- <p>Deactivate logical volumes;</p>
-
- <pre>
- # lvchange -a -n /dev/systemvg/packageslv
- # lvchange -a -n /dev/systemvg/distfileslv
- # swapoff /dev/systemvg/sawplv
- # lvchange -a -n /dev/systemvg/swaplv
- </pre>
-
- <p>Deactivate volume group;</p>
-
- <pre>
- # vgchange -a n systemvg
- 0 logical volume(s) in volume group "systemvg" now active
- #
- </pre>
-
- <p>Activate volume group;</p>
- <pre>
- # vgchange -a y systemvg
- 3 logical volume(s) in volume group "systemvg" now active
- #
- </pre>
-
- <h3>Search Volume Groups</h3>
-
- <pre>
- # vgscan
- Reading all physical volumes. This may take a while...
- Found volume group "homevg" using metadata type lvm2
- Found volume group "systemvg" using metadata type lvm2
- #
- </pre>
-
- <h3>Reconfigure System</h3>
-
- <p>Start by mounting distfileslv and packageslv;</p>
-
- <pre>
- # mkdir -p /var/ports/distfiles
- # mkdir -p /var/ports/packages
- # mkdir -p /var/ports/work
- # mkdir -p /var/ports/pkgbuild
- # chown -R pkgmk:pkgmk /var/ports
- #
- </pre>
-
- <pre>
- # vim /etc/pkgmk.conf
-
- # PKGMK_SOURCE_MIRRORS=()
- PKGMK_SOURCE_DIR="/var/ports/distfiles"
- PKGMK_PACKAGE_DIR="/var/ports/packages"
- PKGMK_WORK_DIR="/var/ports/work/$name
- </pre>
-
- <p>Edit /etc/prt-get.conf;</p>
-
- <pre>
- ### log options:
- writelog enabled # (enabled|disabled)
- logmode overwrite # (append|overwrite)
- rmlog_on_success yes # (no|yes)
- logfile /var/ports/pkgbuild/%n.log
- </pre>
-
- <pre>
- #
- # /etc/fstab: static file system information
- #
- # <file system> <dir> <type> <options> <dump> <pass>
-
- UUID=49031e4e-f899-499d-ac83-401ad12635f5 / ext4 defaults,errors=remount-ro,noatime 0 1
-
- #/dev/mapper/homevg-homelv:
- UUID=c3158626-de78-4bfa-ab8a-9e7e157eca88 /home ext4 defaults,noatime 0 2
-
- #/dev/mapper/systemvg-distfileslv:
- UUID=0aba2d28-8e3a-4a89-bff5-1698708e13d0 /var/ports/distfiles ext4 defaults,noatime 0 2
- #/dev/mapper/systemvg-packageslv:
- UUID=b5a38930-2827-4f00-809a-a0c4d5488aa8 /var/ports/packages ext4 defaults,noatime 0 2
-
- #/dev/mapper/systemvg-swaplv:
- UUID=08295a67-a056-4dea-9462-209f151e4cdf swap swap defaults 0 0
- devpts /dev/pts devpts noexec,nosuid,gid=tty,mode=0620 0 0
- tmp /tmp tmpfs defaults 0 0
- shm /dev/shm tmpfs defaults 0 0
-
- pkgmk /var/ports/work tmpfs size=1G,uid=100,defaults 0 0
- # End of file
- </pre>
-
- <p>You can move home directory to new one with
- just one command; "usermod -m -d /home/new user".</p>
-
- <pre>
- # mount /var/ports/distfiles
- # mount /var/ports/packages
- # umount /home/pkgmk/work
- # mount /var/ports/work
- # mv /home/pkgmk/distfiles/* /var/ports/distfiles/
- # mv /home/pkgmk/packages/* /var/ports/packages/
- # rm -R /home/pkgmk
- # usermod -d /var/ports pkgmk
- </pre>
-
- <p>Check ownership, you may need recursive if partition
- has bin used on another system.</p>
-
- <pre>
- # chown pkgmk:pkgmk /var/ports/distfiles
- # chown pkgmk:pkgmk /var/ports/packages
- #
- </pre>
-
- <pre>
- # mkdir /home/tmp
- # mount /dev/homevg/homelv /home/tmp
- # mv /home/user /home/tmp
- # umount /home/tmp
- # rmdir /home/tmp
- # rm -R /home/user
- </pre>
-
- <h2>Maintenance</h2>
-
- <pre>
- # smartctl -t long /dev/sdb1
- # smartctl -a /dev/sdb1 | less
- </pre>
-
-
- <p><a href="https://wiki.archlinux.org/index.php/Badblocks">Non Destructive Test;</a></p>
-
- <pre>
- # badblocks -nsv /dev/sdb1
- </pre>
-
-
- <h2>Example gitolite volume</h2>
-
- <p>Lets create new lvm volume for repositories data;</p>
-
- <pre>
- # lvcreate -L 15G -n gitlv homevg
- Logical volume "gitlv" created.
-
- # mkfs.ext4 /dev/homevg/gitlv
- mke2fs 1.42.12 (29-Aug-2014)
- Creating filesystem with 3932160 4k blocks and 983040 inodes
- Filesystem UUID: 54c7dca5-1558-4f90-8d81-c01e4e50c6ae
- Superblock backups stored on blocks:
- 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
-
- Allocating group tables: done
- Writing inode tables: done
- Creating journal (32768 blocks): done
- Writing superblocks and filesystem accounting information: done
-
- #
- </pre>
-
- <p>Edit fstab</p>
-
- <pre>
- UUID=54c7dca5-1558-4f90-8d81-c01e4e50c6ae /srv/git ext4 defaults,noatime 0 2
- </pre>
-
- <h2 id="btrfs">1.3. BTRFS</h2>
-
- <a href="index.html">Systools Index</a>
+ <a href="index.html">Tools Index</a>
<p>
This is part of the c9-doc Manual.
Copyright (C) 2016